Skip to Main Content

SQL & PL/SQL

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!

How to assign a column value to variable in PL-SQL-Procedure?

pstein-JavaNetFeb 19 2009 — edited Feb 19 2009
I want to retrieve a value from a table and assign it to a variable inside a PL-SQL procedure.
This variable should later be used in WHERE clauses or comparison statements.
It should look like similar to:

myvar NUMBER;
myvar := SELECT myid FROM mytab WHERE ....:
if myvar > 23 THEN .... END-IF;

The code above does however not work. How do I otherwise assign
a column value to a procedure variable?

How do I catch the error that the SELECT statement returns MORE than one value?

Peter
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Mar 19 2009
Added on Feb 19 2009
5 comments
652 views