improve data format INSERT (unfinished)
This commit is contained in:
parent
7734fa7f73
commit
52187ba0a6
@ -1579,6 +1579,7 @@ IS
|
||||
v_col_cnt PLS_INTEGER;
|
||||
v_desc_tab dbms_sql.desc_tab3;
|
||||
v_buffer_varchar2 VARCHAR2(32767 CHAR);
|
||||
v_buffer_number number;
|
||||
v_buffer_date date;
|
||||
v_buffer_timestamp timestamp;
|
||||
v_buffer_timestamp_tz timestamp with time zone;
|
||||
@ -1668,7 +1669,9 @@ BEGIN
|
||||
-- http://bluefrog-oracle.blogspot.com/2011/11/describing-ref-cursor-using-dbmssql-api.html
|
||||
dbms_sql.describe_columns3(v_cursor, v_col_cnt, v_desc_tab);
|
||||
FOR i IN 1..v_col_cnt LOOP
|
||||
IF v_desc_tab(i).col_type = c_date THEN
|
||||
IF v_desc_tab(i).col_type = c_number THEN
|
||||
dbms_sql.define_column(v_cursor, i, v_buffer_number);
|
||||
ELSIF v_desc_tab(i).col_type = c_date THEN
|
||||
dbms_sql.define_column(v_cursor, i, v_buffer_date);
|
||||
ELSIF v_desc_tab(i).col_type = c_timestamp THEN
|
||||
dbms_sql.define_column(v_cursor, i, v_buffer_timestamp);
|
||||
@ -1713,7 +1716,10 @@ BEGIN
|
||||
-- start column
|
||||
util_clob_append(' t(' || v_data_count || ').' || v_desc_tab(i).col_name || ' := ');
|
||||
|
||||
IF v_desc_tab(i).col_type = c_date THEN
|
||||
IF v_desc_tab(i).col_type = c_number THEN
|
||||
dbms_sql.column_value(v_cursor, i, v_buffer_number);
|
||||
util_clob_append(to_char(v_buffer_number));
|
||||
ELSIF v_desc_tab(i).col_type = c_date THEN
|
||||
dbms_sql.column_value(v_cursor, i, v_buffer_date);
|
||||
util_clob_append(q'^to_date('^' || to_char(v_buffer_date, 'yyyy-mm-dd hh24:mi:ss') || q'^','yyyy-mm-dd hh24:mi:ss')^');
|
||||
ELSIF v_desc_tab(i).col_type = c_timestamp THEN
|
||||
|
||||
10
src/PLEX.pkb
10
src/PLEX.pkb
@ -938,6 +938,7 @@ IS
|
||||
v_col_cnt PLS_INTEGER;
|
||||
v_desc_tab dbms_sql.desc_tab3;
|
||||
v_buffer_varchar2 VARCHAR2(32767 CHAR);
|
||||
v_buffer_number number;
|
||||
v_buffer_date date;
|
||||
v_buffer_timestamp timestamp;
|
||||
v_buffer_timestamp_tz timestamp with time zone;
|
||||
@ -1027,7 +1028,9 @@ BEGIN
|
||||
-- http://bluefrog-oracle.blogspot.com/2011/11/describing-ref-cursor-using-dbmssql-api.html
|
||||
dbms_sql.describe_columns3(v_cursor, v_col_cnt, v_desc_tab);
|
||||
FOR i IN 1..v_col_cnt LOOP
|
||||
IF v_desc_tab(i).col_type = c_date THEN
|
||||
IF v_desc_tab(i).col_type = c_number THEN
|
||||
dbms_sql.define_column(v_cursor, i, v_buffer_number);
|
||||
ELSIF v_desc_tab(i).col_type = c_date THEN
|
||||
dbms_sql.define_column(v_cursor, i, v_buffer_date);
|
||||
ELSIF v_desc_tab(i).col_type = c_timestamp THEN
|
||||
dbms_sql.define_column(v_cursor, i, v_buffer_timestamp);
|
||||
@ -1072,7 +1075,10 @@ BEGIN
|
||||
-- start column
|
||||
util_clob_append(' t(' || v_data_count || ').' || v_desc_tab(i).col_name || ' := ');
|
||||
|
||||
IF v_desc_tab(i).col_type = c_date THEN
|
||||
IF v_desc_tab(i).col_type = c_number THEN
|
||||
dbms_sql.column_value(v_cursor, i, v_buffer_number);
|
||||
util_clob_append(to_char(v_buffer_number));
|
||||
ELSIF v_desc_tab(i).col_type = c_date THEN
|
||||
dbms_sql.column_value(v_cursor, i, v_buffer_date);
|
||||
util_clob_append(q'^to_date('^' || to_char(v_buffer_date, 'yyyy-mm-dd hh24:mi:ss') || q'^','yyyy-mm-dd hh24:mi:ss')^');
|
||||
ELSIF v_desc_tab(i).col_type = c_timestamp THEN
|
||||
|
||||
@ -31,7 +31,7 @@ prompt =======================================================
|
||||
-- loop
|
||||
-- execute immediate q'[
|
||||
-- create table plex_test_multiple_datatypes (
|
||||
-- ptmd_id integer generated always as identity,
|
||||
-- ptmd_id integer generated by default on null as identity,
|
||||
-- ptmd_varchar varchar2(15 char) ,
|
||||
-- ptmd_char char(1 char) not null ,
|
||||
-- ptmd_integer integer ,
|
||||
@ -48,8 +48,7 @@ prompt =======================================================
|
||||
-- ptmd_timestamp_tz timestamp with time zone ,
|
||||
-- ptmd_timestamp_ltz timestamp with local time zone ,
|
||||
-- --
|
||||
-- primary key (ptmd_id),
|
||||
-- unique (ptmd_varchar)
|
||||
-- primary key (ptmd_id)
|
||||
-- )
|
||||
-- ]';
|
||||
-- end loop;
|
||||
@ -69,21 +68,21 @@ prompt =======================================================
|
||||
-- end loop;
|
||||
--end;
|
||||
--/
|
||||
--
|
||||
--prompt Insert 100 rows into plex_test_multiple_datatypes
|
||||
--declare
|
||||
-- l_rows_tab plex_test_multiple_datatypes_api.t_rows_tab;
|
||||
-- l_number_records pls_integer := 100;
|
||||
--begin
|
||||
-- l_rows_tab := plex_test_multiple_datatypes_api.t_rows_tab();
|
||||
-- l_rows_tab.extend(l_number_records);
|
||||
-- for i in 1 .. l_number_records loop
|
||||
-- l_rows_tab(i) := plex_test_multiple_datatypes_api.get_a_row;
|
||||
-- end loop;
|
||||
-- plex_test_multiple_datatypes_api.create_rows(l_rows_tab);
|
||||
-- commit;
|
||||
--end;
|
||||
--/
|
||||
|
||||
prompt Insert 1000 rows into plex_test_multiple_datatypes
|
||||
declare
|
||||
l_rows_tab plex_test_multiple_datatypes_api.t_rows_tab;
|
||||
l_number_records pls_integer := 1;
|
||||
begin
|
||||
l_rows_tab := plex_test_multiple_datatypes_api.t_rows_tab();
|
||||
l_rows_tab.extend(l_number_records);
|
||||
for i in 1 .. l_number_records loop
|
||||
l_rows_tab(i) := plex_test_multiple_datatypes_api.get_a_row;
|
||||
end loop;
|
||||
plex_test_multiple_datatypes_api.create_rows(l_rows_tab);
|
||||
commit;
|
||||
end;
|
||||
/
|
||||
|
||||
prompt Run plex.backapp (this can take some time...)
|
||||
BEGIN
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user