0

I have a oracle trigger and it returns the error

Additional information: ORA-00936: missing expression

In my TOAD it shows me the below line.

EXECUTE IMMEDIATE 'UPDATE TBL_NEWS_TYPE SET FULLNAME='|| newsName ||' WHERE ID = SELECT MAX(ID) FROM TBL_NEWS_TYPE)';

In here newsName is varchar2 variable like newsName VARCHAR2(50) / and ID in INTEGER.

2
  • remove ) after TBL_NEWS_TYPE and you should be through Commented Mar 30, 2016 at 5:31
  • Why are you using execute immediate here? There is no reason for it. And if you do have to for some strange reason, then at least use it with parameters. Concatenating values like that is going to give you trouble in the long run. e,g.: execute immediate 'update tbl_news_type set fullname = :1 where id = (...)' using newsname; Commented Mar 30, 2016 at 6:04

1 Answer 1

2

Try this:

EXECUTE IMMEDIATE 'UPDATE TBL_NEWS_TYPE
                   SET FULLNAME='''|| newsName
                   ||''' WHERE ID = (SELECT MAX(ID) FROM TBL_NEWS_TYPE)'

I think you had two problems here:

1) You were missing '(' at the start of the select

2) I think this won't work without putting quote sign wraping the newsName because its a string.

Sign up to request clarification or add additional context in comments.

3 Comments

Now it shows me this exception ORA-06519: active autonomous transaction detected and rolled back
And thats the whole code? are you sure this is the part that throwing the exception?
ah! got it i used PRAGMA AUTONOMOUS_TRANSACTION; .. now COMMIT missing.. i aded that and working perfectly.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.