What should I do if a very long SQL statement cannot be executed? See the following solution:
/* ----------------------------------- | The ceo SQL statement, such as the parameter and value is very large ---------------------------------------- */ Create Or Replace Procedure Sp_executelog (ssql In Varchar2 , Slong In Clob) Is Begin Execute Immediate ssql using slong; Commit ; End Sp_executelog; -- Usage Create Table Temptable (ID Number , Str Clob) -- ------------ Example 1: normal method ---------------------------- Begin Sp_executelog ( ' Insert into temptable (ID, STR) values (1,: Str) ' , To_clob ( ' 14 ' )); End ; -- ------------ Example 2, nesting type of quotation marks ---------------------------- Declare Sqlstr Varchar2 ( 32767 ): = ' Update t_table set inetworktype_id = 1, swhererules_cn = '''' , Iuserid = 2804, dupdatedate = to_date ( '' 2012-04-19 '' , '' YYYY-MM-DD '' ), Sperftype = '' Perf_gsmcell '' , Ssql =: Str where stemplateid = '' 37606 ''' ; Val clob: = To_clob ( ' Select to_char (ddate, '''' Yyyy '''' ) Y from table where ddate> = (sysdate-interval '''' 1 '''' Year) ' ); Begin Sp_executelog (sqlstr, Val ); End ;