PLSQL error - ORA-00984: column not allowed here

后端 未结 2 884
-上瘾入骨i
-上瘾入骨i 2021-01-28 23:04

I have written a PL-SQL block

DECLARE
    SchemaName  VARCHAR2(50) :=\'REQ_SUNIL_5750\';
    userpassword VARCHAR2(50) :=\'XYZ\';  
    stmt VARCHAR2(5000);
BEG         


        
相关标签:
2条回答
  • 2021-01-28 23:28

    You have to quote your string values properly:

    stmt :='INSERT INTO ' || SchemaName || 
      '.USER_CREDS VALUES ('''|| SchemaName ||''', '''|| userpassword ||''' )';
    
    0 讨论(0)
  • 2021-01-28 23:35

    Frank's answer is great, I would add one point though.

    From the perspective of performance and reuseability, your execute immediate statement should use bind variables and the insert syntax should specify the columns that correspond to the values being entered.

    0 讨论(0)
提交回复
热议问题