fix sqlplus alternative quoting
This commit is contained in:
parent
68f98e08ae
commit
460b3ef5ef
@ -87,7 +87,7 @@ SIGNATURE
|
|||||||
```sql
|
```sql
|
||||||
PACKAGE PLEX AUTHID current_user IS
|
PACKAGE PLEX AUTHID current_user IS
|
||||||
c_plex_name CONSTANT VARCHAR2(30 CHAR) := 'PLEX - PL/SQL Export Utilities';
|
c_plex_name CONSTANT VARCHAR2(30 CHAR) := 'PLEX - PL/SQL Export Utilities';
|
||||||
c_plex_version CONSTANT VARCHAR2(10 CHAR) := '2.2.0.5';
|
c_plex_version CONSTANT VARCHAR2(10 CHAR) := '2.2.0.6';
|
||||||
c_plex_url CONSTANT VARCHAR2(40 CHAR) := 'https://github.com/ogobrecht/plex';
|
c_plex_url CONSTANT VARCHAR2(40 CHAR) := 'https://github.com/ogobrecht/plex';
|
||||||
c_plex_license CONSTANT VARCHAR2(10 CHAR) := 'MIT';
|
c_plex_license CONSTANT VARCHAR2(10 CHAR) := 'MIT';
|
||||||
c_plex_license_url CONSTANT VARCHAR2(60 CHAR) := 'https://github.com/ogobrecht/plex/blob/master/LICENSE.txt';
|
c_plex_license_url CONSTANT VARCHAR2(60 CHAR) := 'https://github.com/ogobrecht/plex/blob/master/LICENSE.txt';
|
||||||
|
|||||||
@ -47,7 +47,7 @@ END;
|
|||||||
prompt Compile package plex (spec)
|
prompt Compile package plex (spec)
|
||||||
CREATE OR REPLACE PACKAGE PLEX AUTHID current_user IS
|
CREATE OR REPLACE PACKAGE PLEX AUTHID current_user IS
|
||||||
c_plex_name CONSTANT VARCHAR2(30 CHAR) := 'PLEX - PL/SQL Export Utilities';
|
c_plex_name CONSTANT VARCHAR2(30 CHAR) := 'PLEX - PL/SQL Export Utilities';
|
||||||
c_plex_version CONSTANT VARCHAR2(10 CHAR) := '2.2.0.5';
|
c_plex_version CONSTANT VARCHAR2(10 CHAR) := '2.2.0.6';
|
||||||
c_plex_url CONSTANT VARCHAR2(40 CHAR) := 'https://github.com/ogobrecht/plex';
|
c_plex_url CONSTANT VARCHAR2(40 CHAR) := 'https://github.com/ogobrecht/plex';
|
||||||
c_plex_license CONSTANT VARCHAR2(10 CHAR) := 'MIT';
|
c_plex_license CONSTANT VARCHAR2(10 CHAR) := 'MIT';
|
||||||
c_plex_license_url CONSTANT VARCHAR2(60 CHAR) := 'https://github.com/ogobrecht/plex/blob/master/LICENSE.txt';
|
c_plex_license_url CONSTANT VARCHAR2(60 CHAR) := 'https://github.com/ogobrecht/plex/blob/master/LICENSE.txt';
|
||||||
@ -1587,7 +1587,7 @@ IS
|
|||||||
v_nls_date_format VARCHAR2(30);
|
v_nls_date_format VARCHAR2(30);
|
||||||
v_nls_timestamp_format VARCHAR2(30);
|
v_nls_timestamp_format VARCHAR2(30);
|
||||||
v_nls_timestamp_tz_format VARCHAR2(30);
|
v_nls_timestamp_tz_format VARCHAR2(30);
|
||||||
c_sqlplus_max_line_length CONSTANT PLS_INTEGER := 4500;
|
c_sqlplus_max_line_length CONSTANT PLS_INTEGER := 4500;
|
||||||
v_line_cache VARCHAR2(4998 CHAR);
|
v_line_cache VARCHAR2(4998 CHAR);
|
||||||
v_line_size PLS_INTEGER := 0;
|
v_line_size PLS_INTEGER := 0;
|
||||||
v_buffer_varchar2 VARCHAR2(32767 CHAR);
|
v_buffer_varchar2 VARCHAR2(32767 CHAR);
|
||||||
@ -1631,39 +1631,50 @@ IS
|
|||||||
----------------------------------------
|
----------------------------------------
|
||||||
|
|
||||||
FUNCTION quote_string (p_string VARCHAR2) RETURN VARCHAR2 IS
|
FUNCTION quote_string (p_string VARCHAR2) RETURN VARCHAR2 IS
|
||||||
|
v_string varchar2(5000 char);
|
||||||
BEGIN
|
BEGIN
|
||||||
if instr(p_string, '''') = 0 then
|
if instr(p_string, '''') = 0 then
|
||||||
return '''' || p_string || '''';
|
v_string := '''' || p_string || '''';
|
||||||
--
|
--
|
||||||
elsif instr(p_string, '^''') = 0 then
|
elsif instr(p_string, '^''') = 0 then
|
||||||
return 'q''^' || p_string || '^''';
|
v_string := 'q''^' || p_string || '^''';
|
||||||
--
|
--
|
||||||
elsif instr(p_string, '`''') = 0 then
|
elsif instr(p_string, '`''') = 0 then
|
||||||
return 'q''`' || p_string || '`''';
|
v_string := 'q''`' || p_string || '`''';
|
||||||
--
|
--
|
||||||
elsif instr(p_string, '#''') = 0 then
|
elsif instr(p_string, '#''') = 0 then
|
||||||
return 'q''#' || p_string || '#''';
|
v_string := 'q''#' || p_string || '#''';
|
||||||
--
|
--
|
||||||
elsif instr(p_string, '|''') = 0 then
|
elsif instr(p_string, '|''') = 0 then
|
||||||
return 'q''|' || p_string || '|''';
|
v_string := 'q''|' || p_string || '|''';
|
||||||
--
|
--
|
||||||
elsif instr(p_string, '!''') = 0 then
|
elsif instr(p_string, '!''') = 0 then
|
||||||
return 'q''!' || p_string || '!''';
|
v_string := 'q''!' || p_string || '!''';
|
||||||
--
|
--
|
||||||
elsif instr(p_string, '}''') = 0 then
|
elsif instr(p_string, '}''') = 0 then
|
||||||
return 'q''{' || p_string || '}''';
|
v_string := 'q''{' || p_string || '}''';
|
||||||
--
|
--
|
||||||
elsif instr(p_string, ']''') = 0 then
|
elsif instr(p_string, ']''') = 0 then
|
||||||
return 'q''[' || p_string || ']''';
|
v_string := 'q''[' || p_string || ']''';
|
||||||
--
|
--
|
||||||
elsif instr(p_string, '>''') = 0 then
|
elsif instr(p_string, '>''') = 0 then
|
||||||
return 'q''<' || p_string || '>''';
|
v_string := 'q''<' || p_string || '>''';
|
||||||
--
|
--
|
||||||
elsif instr(p_string, ')''') = 0 then
|
elsif instr(p_string, ')''') = 0 then
|
||||||
return 'q''(' || p_string || ')''';
|
v_string := 'q''(' || p_string || ')''';
|
||||||
else
|
else
|
||||||
return '''' || replace(p_string, '''', '''''') || '''';
|
v_string := '''' || replace(p_string, '''', '''''') || '''';
|
||||||
end if;
|
end if;
|
||||||
|
|
||||||
|
-- SQL*Plus specific:
|
||||||
|
-- SQL Failed With ORA-1756 In Sqlplus But Works In SQL Developer
|
||||||
|
-- (Doc ID 2377701.1, https://support.oracle.com/epmos/faces/DocumentDisplay?id=2377701.1)
|
||||||
|
if instr(v_string, ';'||chr(10)) = 0 then
|
||||||
|
return v_string;
|
||||||
|
else
|
||||||
|
return ('replace(' || replace(v_string, ';'||chr(10), ';!'||chr(10)) || ','';!''||chr(10),'';''||chr(10))');
|
||||||
|
end if;
|
||||||
|
|
||||||
END quote_string;
|
END quote_string;
|
||||||
|
|
||||||
----------------------------------------
|
----------------------------------------
|
||||||
@ -1831,13 +1842,18 @@ IS
|
|||||||
|
|
||||||
----------------------------------------
|
----------------------------------------
|
||||||
|
|
||||||
|
-- SQL*Plus specific:
|
||||||
|
-- SQL Failed With ORA-1756 In Sqlplus But Works In SQL Developer
|
||||||
|
-- (Doc ID 2377701.1, https://support.oracle.com/epmos/faces/DocumentDisplay?id=2377701.1)
|
||||||
|
|
||||||
PROCEDURE create_header IS
|
PROCEDURE create_header IS
|
||||||
BEGIN
|
BEGIN
|
||||||
util_clob_append('-- Script generated by PLEX version ' || c_plex_version || ' - more infos here: ' || c_plex_url || c_crlf);
|
util_clob_append('-- Script generated by PLEX version ' || c_plex_version || ' - more infos here: ' || c_plex_url || c_crlf);
|
||||||
util_clob_append('-- Performance Hacks by Connor McDonald: https://connor-mcdonald.com/2019/05/17/hacking-together-faster-inserts/' || c_crlf);
|
util_clob_append('-- Performance Hacks by Connor McDonald: https://connor-mcdonald.com/2019/05/17/hacking-together-faster-inserts/' || c_crlf);
|
||||||
|
util_clob_append('-- For strange line end replacements a big thank to SQL*Plus: https://support.oracle.com/epmos/faces/DocumentDisplay?id=2377701.1 (SQL Failed With ORA-1756 In Sqlplus But Works In SQL Developer)' || c_crlf);
|
||||||
util_clob_append('prompt Insert into ' || p_table_name || c_crlf);
|
util_clob_append('prompt Insert into ' || p_table_name || c_crlf);
|
||||||
util_clob_append('timing start inserts' || c_crlf);
|
util_clob_append('timing start inserts' || c_crlf);
|
||||||
util_clob_append('set define off feedback off' || c_crlf);
|
util_clob_append('set define off feedback off sqlblanklines on' || c_crlf);
|
||||||
util_clob_append('alter session set cursor_sharing = force;' || c_crlf);
|
util_clob_append('alter session set cursor_sharing = force;' || c_crlf);
|
||||||
util_clob_append(q'^alter session set nls_numeric_characters = '.,';^' || c_crlf);
|
util_clob_append(q'^alter session set nls_numeric_characters = '.,';^' || c_crlf);
|
||||||
util_clob_append(q'^alter session set nls_date_format = 'yyyy-mm-dd hh24:mi:ss';^' || c_crlf);
|
util_clob_append(q'^alter session set nls_date_format = 'yyyy-mm-dd hh24:mi:ss';^' || c_crlf);
|
||||||
|
|||||||
42
src/PLEX.pkb
42
src/PLEX.pkb
@ -946,7 +946,7 @@ IS
|
|||||||
v_nls_date_format VARCHAR2(30);
|
v_nls_date_format VARCHAR2(30);
|
||||||
v_nls_timestamp_format VARCHAR2(30);
|
v_nls_timestamp_format VARCHAR2(30);
|
||||||
v_nls_timestamp_tz_format VARCHAR2(30);
|
v_nls_timestamp_tz_format VARCHAR2(30);
|
||||||
c_sqlplus_max_line_length CONSTANT PLS_INTEGER := 4500;
|
c_sqlplus_max_line_length CONSTANT PLS_INTEGER := 4500;
|
||||||
v_line_cache VARCHAR2(4998 CHAR);
|
v_line_cache VARCHAR2(4998 CHAR);
|
||||||
v_line_size PLS_INTEGER := 0;
|
v_line_size PLS_INTEGER := 0;
|
||||||
v_buffer_varchar2 VARCHAR2(32767 CHAR);
|
v_buffer_varchar2 VARCHAR2(32767 CHAR);
|
||||||
@ -990,39 +990,50 @@ IS
|
|||||||
----------------------------------------
|
----------------------------------------
|
||||||
|
|
||||||
FUNCTION quote_string (p_string VARCHAR2) RETURN VARCHAR2 IS
|
FUNCTION quote_string (p_string VARCHAR2) RETURN VARCHAR2 IS
|
||||||
|
v_string varchar2(5000 char);
|
||||||
BEGIN
|
BEGIN
|
||||||
if instr(p_string, '''') = 0 then
|
if instr(p_string, '''') = 0 then
|
||||||
return '''' || p_string || '''';
|
v_string := '''' || p_string || '''';
|
||||||
--
|
--
|
||||||
elsif instr(p_string, '^''') = 0 then
|
elsif instr(p_string, '^''') = 0 then
|
||||||
return 'q''^' || p_string || '^''';
|
v_string := 'q''^' || p_string || '^''';
|
||||||
--
|
--
|
||||||
elsif instr(p_string, '`''') = 0 then
|
elsif instr(p_string, '`''') = 0 then
|
||||||
return 'q''`' || p_string || '`''';
|
v_string := 'q''`' || p_string || '`''';
|
||||||
--
|
--
|
||||||
elsif instr(p_string, '#''') = 0 then
|
elsif instr(p_string, '#''') = 0 then
|
||||||
return 'q''#' || p_string || '#''';
|
v_string := 'q''#' || p_string || '#''';
|
||||||
--
|
--
|
||||||
elsif instr(p_string, '|''') = 0 then
|
elsif instr(p_string, '|''') = 0 then
|
||||||
return 'q''|' || p_string || '|''';
|
v_string := 'q''|' || p_string || '|''';
|
||||||
--
|
--
|
||||||
elsif instr(p_string, '!''') = 0 then
|
elsif instr(p_string, '!''') = 0 then
|
||||||
return 'q''!' || p_string || '!''';
|
v_string := 'q''!' || p_string || '!''';
|
||||||
--
|
--
|
||||||
elsif instr(p_string, '}''') = 0 then
|
elsif instr(p_string, '}''') = 0 then
|
||||||
return 'q''{' || p_string || '}''';
|
v_string := 'q''{' || p_string || '}''';
|
||||||
--
|
--
|
||||||
elsif instr(p_string, ']''') = 0 then
|
elsif instr(p_string, ']''') = 0 then
|
||||||
return 'q''[' || p_string || ']''';
|
v_string := 'q''[' || p_string || ']''';
|
||||||
--
|
--
|
||||||
elsif instr(p_string, '>''') = 0 then
|
elsif instr(p_string, '>''') = 0 then
|
||||||
return 'q''<' || p_string || '>''';
|
v_string := 'q''<' || p_string || '>''';
|
||||||
--
|
--
|
||||||
elsif instr(p_string, ')''') = 0 then
|
elsif instr(p_string, ')''') = 0 then
|
||||||
return 'q''(' || p_string || ')''';
|
v_string := 'q''(' || p_string || ')''';
|
||||||
else
|
else
|
||||||
return '''' || replace(p_string, '''', '''''') || '''';
|
v_string := '''' || replace(p_string, '''', '''''') || '''';
|
||||||
end if;
|
end if;
|
||||||
|
|
||||||
|
-- SQL*Plus specific:
|
||||||
|
-- SQL Failed With ORA-1756 In Sqlplus But Works In SQL Developer
|
||||||
|
-- (Doc ID 2377701.1, https://support.oracle.com/epmos/faces/DocumentDisplay?id=2377701.1)
|
||||||
|
if instr(v_string, ';'||chr(10)) = 0 then
|
||||||
|
return v_string;
|
||||||
|
else
|
||||||
|
return ('replace(' || replace(v_string, ';'||chr(10), ';!'||chr(10)) || ','';!''||chr(10),'';''||chr(10))');
|
||||||
|
end if;
|
||||||
|
|
||||||
END quote_string;
|
END quote_string;
|
||||||
|
|
||||||
----------------------------------------
|
----------------------------------------
|
||||||
@ -1190,13 +1201,18 @@ IS
|
|||||||
|
|
||||||
----------------------------------------
|
----------------------------------------
|
||||||
|
|
||||||
|
-- SQL*Plus specific:
|
||||||
|
-- SQL Failed With ORA-1756 In Sqlplus But Works In SQL Developer
|
||||||
|
-- (Doc ID 2377701.1, https://support.oracle.com/epmos/faces/DocumentDisplay?id=2377701.1)
|
||||||
|
|
||||||
PROCEDURE create_header IS
|
PROCEDURE create_header IS
|
||||||
BEGIN
|
BEGIN
|
||||||
util_clob_append('-- Script generated by PLEX version ' || c_plex_version || ' - more infos here: ' || c_plex_url || c_crlf);
|
util_clob_append('-- Script generated by PLEX version ' || c_plex_version || ' - more infos here: ' || c_plex_url || c_crlf);
|
||||||
util_clob_append('-- Performance Hacks by Connor McDonald: https://connor-mcdonald.com/2019/05/17/hacking-together-faster-inserts/' || c_crlf);
|
util_clob_append('-- Performance Hacks by Connor McDonald: https://connor-mcdonald.com/2019/05/17/hacking-together-faster-inserts/' || c_crlf);
|
||||||
|
util_clob_append('-- For strange line end replacements a big thank to SQL*Plus: https://support.oracle.com/epmos/faces/DocumentDisplay?id=2377701.1 (SQL Failed With ORA-1756 In Sqlplus But Works In SQL Developer)' || c_crlf);
|
||||||
util_clob_append('prompt Insert into ' || p_table_name || c_crlf);
|
util_clob_append('prompt Insert into ' || p_table_name || c_crlf);
|
||||||
util_clob_append('timing start inserts' || c_crlf);
|
util_clob_append('timing start inserts' || c_crlf);
|
||||||
util_clob_append('set define off feedback off' || c_crlf);
|
util_clob_append('set define off feedback off sqlblanklines on' || c_crlf);
|
||||||
util_clob_append('alter session set cursor_sharing = force;' || c_crlf);
|
util_clob_append('alter session set cursor_sharing = force;' || c_crlf);
|
||||||
util_clob_append(q'^alter session set nls_numeric_characters = '.,';^' || c_crlf);
|
util_clob_append(q'^alter session set nls_numeric_characters = '.,';^' || c_crlf);
|
||||||
util_clob_append(q'^alter session set nls_date_format = 'yyyy-mm-dd hh24:mi:ss';^' || c_crlf);
|
util_clob_append(q'^alter session set nls_date_format = 'yyyy-mm-dd hh24:mi:ss';^' || c_crlf);
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
CREATE OR REPLACE PACKAGE PLEX AUTHID current_user IS
|
CREATE OR REPLACE PACKAGE PLEX AUTHID current_user IS
|
||||||
c_plex_name CONSTANT VARCHAR2(30 CHAR) := 'PLEX - PL/SQL Export Utilities';
|
c_plex_name CONSTANT VARCHAR2(30 CHAR) := 'PLEX - PL/SQL Export Utilities';
|
||||||
c_plex_version CONSTANT VARCHAR2(10 CHAR) := '2.2.0.5';
|
c_plex_version CONSTANT VARCHAR2(10 CHAR) := '2.2.0.6';
|
||||||
c_plex_url CONSTANT VARCHAR2(40 CHAR) := 'https://github.com/ogobrecht/plex';
|
c_plex_url CONSTANT VARCHAR2(40 CHAR) := 'https://github.com/ogobrecht/plex';
|
||||||
c_plex_license CONSTANT VARCHAR2(10 CHAR) := 'MIT';
|
c_plex_license CONSTANT VARCHAR2(10 CHAR) := 'MIT';
|
||||||
c_plex_license_url CONSTANT VARCHAR2(60 CHAR) := 'https://github.com/ogobrecht/plex/blob/master/LICENSE.txt';
|
c_plex_license_url CONSTANT VARCHAR2(60 CHAR) := 'https://github.com/ogobrecht/plex/blob/master/LICENSE.txt';
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
Loading…
x
Reference in New Issue
Block a user