I would like to know if there is a possibility to use variables across non-nested begin...end;
blocks.
Because the way Invantive parses scripts that includes create or replace table
and subsequent access to theses created table, I cannot use a unique begin...end;
nor nested ones as discussed here: SQL strange behaviour with a begin + loop + create or replace @inmemorystorage - 7 van forums
For exemple, creating a log, that will be afterwards saved thanks to write_file@Os
-- block1
declare
l_log_txt varchar2;
begin
l_log_txt := l_log_txt + (chr(10) || 'script started at : ' || sysdate);
-- do things here like create or replace a table
end;
--
-- block2
--declare l_log_txt varchar2;
begin
l_log_txt := l_log_txt + (chr(10) || 'script finished at : ' || sysdate);
-- do things here like read, insert or else on the above table
end;
-- block3
--declare l_log_txt varchar2;
begin
insert into write_file@Os
( file_path
, file_contents
)
values
( 'c:\jobs\log\log.txt'
, base64_encode(ascii_to_blob(l_file_content))
);
end;
Of course a workaround could be creating a inmemory table
create or replace table variables@inmemorystorage
( var_name varchar2
, var_value varchar2
);
to store variables. But it is not very easy to manipulate … when inserting, reading and updating values.