Search code examples
oracle-databasereferencedynamic-sqlbind-variables

parameter reference using dynamic SQL


Below statement use a mixture of bind variable, constant and Oracle keyword for insertion. ABC REVIEW and N are actual values to be inserted.

l_sql :='INSERT INTO EMP
         (BUSINESS_DATE,GROUP_NAME, DELETED,UPDATE_DATE) VALUES
          (:BIZ_DATE,ABC REVIEW,N,SYSDATE)';

Is this the correct way for parameter reference using dynamic SQL? Doesn't it require additional parenthesis?


Solution

  • Just esacpe the quote sign around actual string values:

      l_sql :='INSERT INTO EMP
         (BUSINESS_DATE,GROUP_NAME, DELETED,UPDATE_DATE) VALUES
          (:BIZ_DATE,''ABC REVIEW'',''N'',SYSDATE)';