Oracle
 sql >> Base de données >  >> RDS >> Oracle

sous-chaîne dans oracle

Quelque chose comme ça, peut-être; mon CTE est le résultat de votre GET_DDL.

with test (col) as 
(select q'[
CREATE OR REPLACE  TRIGGER "owner"."trigger_delete" BEFORE DELETE ON roles FOR EACH ROW
BEGIN
DBMS_APPLICATION_INFO.read_client_info (acct_utils.trigger_enabled);
IF acct_utils.trigger_enabled <> 'F' THEN
  INSERT INTO delete_table (ID, key, object, type, keytype, objecttype, created, deleted, deletedby) VALUES(
    :old.id,
    :old.key,
    'delete',
    null,
    :old.keytype,
    null,
    :old.whencreated,
    (CURRENT_TIMESTAMP AT TIME ZONE 'GMT'),
    SYS_CONTEXT('TMCtx', 'USERKEY')
  );
END IF;
END trigger_delete;]' 
from dual)
select substr(col, 
              instr(upper(col), 'INSERT INTO DELETE_TABLE'),
              --
              instr(col, ';', instr(upper(col), 'INSERT INTO DELETE_TABLE'), 1) -
              instr(upper(col), 'INSERT INTO DELETE_TABLE') + 1
             ) result
from test;