Jorge Vega Sánchez
Jorge Vega Sánchez

Reputation: 7590

PL/SQL Execute inmediate Update query giving SQLCODE -932

I'm finishing a PL/SQL block but the final update statement is giving me a headache.

The following EXECUTE INMEDIATE thows me an SQLCODE -932 and program breaks.

EXECUTE IMMEDIATE 'UPDATE RS2QTCIN cin SET cin.date_end = '|| dateINSERT ||' WHERE cin.id = '|| REG1.c1id;

The query is just simple, dateINSERT is a variable defined in the declaration block and the value at the end(REG1.c1id), is a result of a cursor also defined.

The update query seems correct and the variables are concatenated with the query string.

Upvotes: 0

Views: 94

Answers (1)

user330315
user330315

Reputation:

Don't concatenate parameters into the SQL string, use placeholders instead:

EXECUTE IMMEDIATE 'UPDATE RS2QTCIN cin SET cin.date_end = :1 WHERE cin.id = :2'
  USING dateINSERT, REG1.c1id;

But as there are no dynamic identifiers in your SQL, you don't need dynamic SQL to begin with:

UPDATE RS2QTCIN cin 
    SET cin.date_end = dateINSERT 
WHERE cin.id = REG1.c1id;

Upvotes: 1

Related Questions