Hi Tom,
This is my first post here. First of all let me thank you for all the help i got from your site over the years. :)
Now the issue, I am trying to create a view from local DB (11.2.0.3) into remote DB (10.2.0.4).
my code worked for smaller size views till now having size less then 32K. it is failing for a view with 39K+ characters.
I googled and found that i can use following variation of parse, but it gives me error:PLS-00306: wrong number or types of arguments in call to 'PARSE'
DBMS_SQL.PARSE (
c IN INTEGER,
statement IN VARCHAR2A,
lb IN INTEGER,
ub IN INTEGER,
lfflg IN BOOLEAN,
language_flag IN INTEGER);
DECLARE
l_var number;
l_in_cursor NUMBER;
l_stmt VARCHAR2(32000);
g_db_link varchar2(100) := '@ABC.xyz.com';
l_sql CLOB;
l_split_stmt DBMS_SQL.VARCHAR2A;
BEGIN
l_stmt := 'SELECT DBMS_SQL.OPEN_CURSOR'||g_db_link||' FROM DUAL';
EXECUTE IMMEDIATE l_stmt INTO l_in_cursor;
l_var :=l_in_cursor;
SELECT a.query
into L_SQL
FROM test_hlb01_qry a
where program_log_dtls_seq_no=11;
if length(L_SQL)> 25000 then
l_split_stmt(1):= substr(l_sql,1,instr(l_sql, ',', 10000));
l_split_stmt(2):= substr(l_sql,instr(l_sql, ',', 10000)+1,instr(l_sql, ',', 20000));
l_split_stmt(3):= substr(l_sql,instr(l_sql, ',', 20000)+1,instr(l_sql, ',', 30000));
l_split_stmt(4):= substr(l_sql,instr(l_sql, ',', 30000)+1,instr(l_sql, ',', 40000));
DBMS_SQL.PARSE@ABC.xyz.com (l_var,l_split_stmt,1,2,TRUE, dbms_sql.native);
else
DBMS_SQL.PARSE@ABC.xyz.com (l_var,L_SQL, dbms_sql.native);
end if;
DBMS_SQL.CLOSE_CURSOR@ABC.xyz.com(l_var);
END;
/
here else part worked fine till now. the if part is what i added to handle bigger view creating which is failing.
Please Help.!!
you would have to use the remote type as well
l_split_stmt DBMS_SQL.VARCHAR2A;
that uses the "local" type, which is not the same as the "remote type".
but you won't be able to use the remote type, since the db link is not known at compile time. Or is it, I don't know why you are using execute immediate to get the cursor - but then statically reference abc.xyz.com later....
but, in any case, what you would be able to do is build a block of code similar to:
declare
l_cursor number;
l_data dbms_sql.varchar2a;
begin
l_cursor := dbms_sql.open_cursor;
l_data(1) := :bv1;
l_data(2) := :bv2;
l_data(3) := :bv3;
..... if the max statement you want to support is 320k, do that 10 times..... for example ...
dbms_sql.parse( .... );
dbms_sql.close_cursor(l_cursor);
end;
so, that is the sql statement you want to parse at the remote site. parse that remotely, bind to it (binding NULL if there isn't anything to be added at the end - just bind 10 strings) and then execute it.