I have internal system which uses parameters and front-end. So, here is the conundrum:
When record is updated, the trigger is fired and SQL statement is executed.
I need to check if the field contain word "BAD" or "GOOD" and my SQL statement must be different. And I can't use stored procedures. must be pure SQL
something like this
CASE
WHEN (TO_CHAR(?)=TO_CHAR('GOOD'))
THEN INSERT VALUES INTO GOOD_TABLE
WHEN (TO_CHAR(?)=TO_CHAR('BAD'))
THEN INSERT VALUES INTO BAD_TABLE
END
You can leverage the multi-table inserts functionality using INSERT FIRST / INSERT ALL command, as below:
INSERT FIRST
WHEN (TO_CHAR(?)='GOOD') THEN
INTO GOOD_TABLE
VALUES(values...)
WHEN (TO_CHAR(?)='BAD') THEN
INTO BAD_TABLE
VALUES(values...)
SELECT values, ?
FROM mytable;
Reference :
Multi table Inserts on Oracle Examples blog (Very good examples)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.