I am trying to run something similar to this within a stored procedure in Oracle.
pWhereCLAUSE is generic which I set depending on the table I am working on. The following code runs just if I have the proper defined where clause, but If I try to use this variable, I keep getting errors. I have tried to use ||, single quotes, but nothing has worked. I am not an expert at stored procedures. But any help would be appreciated. I am just trying to figure how I can keep this generic and have this code work with pWhereCLAUSE working
INSERT INTO ABC
SELECT *
FROM ABCD
pWhereCLAUSE to_char(dateOne, 'DD-MON-YYYY') and ROWNUM <= variable1;
commit;
I have also tried:
BEGIN
sql_stmt := 'INSERT INTO TABLS_AB SELECT * FROM TABLE_C' || pWhereClause || to_char(offsetDate, 'DD-MON-YYYY');
END;
EXECUTE IMMEDIATE sql_stmt;
The procedure compiles just fine, and this never executes. Please assist.
execute immediateup above theEND;line. It's a PL/SQL command, not a SQL command.