Skip to Main Content

APEX

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

procedure to check if a value exists in a column

2750208Sep 22 2014 — edited Sep 22 2014

Hello Experts,

version : 10.1.0.5

I am a novice in pl/sql programming. i am trying to create a procedure which checks if a value exists in a column and if it does not it inserts .Below is the procedure and the errors,

SQL> CREATE OR REPLACE PACKAGE BODY manr.audit_pkg IS

  2  PROCEDURE audit_proc(p_sessionid number,p_username VARCHAR2,p_date date) IS

  3  BEGIN

  4  if p_sessionid not in(select sessionid from manr.audit_history)

  5  then

  6  INSERT INTO manr.audit_history VALUES (p_sessionid,p_username, p_date);

  7  Commit;

  8  end if;

  9  END;

10  END audit_pkg;

11  /

Warning: Package Body created with compilation errors.

SQL> show error

Errors for PACKAGE BODY MANR.AUDIT_PKG:

LINE/COL ERROR

-------- -----------------------------------------------------------------

4/1      PL/SQL: Statement ignored

4/22     PLS-00405: subquery not allowed in this context

Could you please tell me where i am going wrong.Thanks for your help.

Rocky

This post has been answered by Ziut on Sep 22 2014
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Oct 20 2014
Added on Sep 22 2014
2 comments
2,935 views