Home » SQL & PL/SQL » SQL & PL/SQL » Dynamically pass table name in PLSQL (Oracle client 18.0)
Dynamically pass table name in PLSQL [message #685468] |
Sat, 22 January 2022 07:35  |
 |
345678
Messages: 3 Registered: January 2022
|
Junior Member |
|
|
Hi,
I am passing table name to oracle stored procedure and wants to execute it dynamically . Below is snippet of my stored procedure.
When i execute this ,i'm getting "ORA-00984: column not allowed here" error . Could you please help me in solving this issue.
execute immediate 'INSERT INTO ' ||P_TableName|| '(T$IDNO,T$TEDT,T$CONO,T$TTYP,T$TSER,T$FYER,T$FPRD,T$RPRD,T$VYER,T$VPER,T$ITYP,T$ISER,T$IDOC,T$STAT,T$BTNO,T$BREF,T$USER,T$TRST,T$TRD T,T$MAIM,T$REFCNTD,T$REFCNTU) VALUES (p_IdentificationNumber,p_TransactionDate,p_BatchCompany,p_TTransactionType,p_TransactionSeries,p_FiscalYear,p_FiscalPeriod,p_Reporti ngPeriod,p_TaxYear,p_TaxPeriod,p_IImportJournalType,p_ImportJournalSeries,p_ImportJournalDocument,p_ImportJournalStatus,p_BatchNumber ,p_BBatchReference,p_UUser,p_TransferStatus,p_TransferDate,p_ManualImport,p_REFCNTD,p_REFCNTU)';
COMMIT;
|
|
|
|
|
|
|
Re: Dynamically pass table name in PLSQL [message #685485 is a reply to message #685483] |
Mon, 24 January 2022 00:44   |
flyboy
Messages: 1901 Registered: November 2006
|
Senior Member |
|
|
You may benefit from writing down the constructed string (e.g. using DBMS_OUTPUT) before executing it.
In this case, you would see something like this (as I do not know exact name of your table):
DELETE FROM TableName1WHERE T$IDNO= :p_IdentificationNumber
Can you spot the missing space before WHERE? Analogically, the space is explicitly stated in the constructed MSG a few rows after.
|
|
|
Re: Dynamically pass table name in PLSQL [message #685487 is a reply to message #685485] |
Mon, 24 January 2022 03:16  |
 |
345678
Messages: 3 Registered: January 2022
|
Junior Member |
|
|
Thank you , I have added space before where condition , It worked fine
execute immediate 'DELETE FROM ' || P_TableName1 || ' WHERE T$IDNO= :p_IdentificationNumber'
using p_IdentificationNumber;
execute immediate 'DELETE FROM ' || P_TableName2 || ' WHERE T$IDNO= :p_IdentificationNumber'
using p_IdentificationNumber;
|
|
|
Goto Forum:
Current Time: Thu Mar 30 22:24:00 CDT 2023
|