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!

Regarding decode function

672483Nov 26 2008 — edited Nov 26 2008
Hi all,

i want to know abt decode function in oracle-sql
i..e passing the parameters in decode using decode using ":" bind parameter

select JOB, decode(:j,'CLERK','MANAGER','ANALYST','EXEC',JOB) FROM EMP;
i declared the j variable in sql environment
VARIABLE J VARCHAR2(20);
i exec the query
and passed as the clerk as input parameter
but iam getting the o/p as
JOB DECODE(:J
--------- ---------
MANAGER MANAGER
MANAGER MANAGER
MANAGER MANAGER
SALESMAN SALESMAN
SALESMAN SALESMAN
SALESMAN SALESMAN
CLERK CLERK
SALESMAN SALESMAN
ANALYST ANALYST
CLERK CLERK
ANALYST ANALYST

JOB DECODE(:J
--------- ---------
CLERK CLERK

12 rows selected.

SQL> PRINT J;

J
--------------------------------------------------------------------------------

im not getting o/p
so please hlelp me only : should be used not &
this is my first thread.
execuse me if any mistakes

tons of thanks in advance to all
This post has been answered by EnjoyToHelp on Nov 26 2008
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Dec 24 2008
Added on Nov 26 2008
16 comments
768 views