Home » SQL & PL/SQL » SQL & PL/SQL » Passing variable in IN clause with more than one values
Passing variable in IN clause with more than one values [message #236525] Thu, 10 May 2007 02:59 Go to next message
bhoite_amol83
Messages: 110
Registered: June 2005
Location: Pune
Senior Member
Hi,
Please take a look at the following query.

DECLARE 
    A VARCHAR2(1000);
    B NUMBER;
BEGIN
    A :='0024'||','||'0007'||','|| '0008';
    SELECT COUNT(*)
    INTO   B
    FROM   TEMP
    WHERE  ID IN ('A');
    RAISE_APPLICATION_ERROR(-20001,B);
END;


Now the output of the query is 0.
I want the output of the query as 3. Because table has 3 records with the ID '0024','0007','0008'
I am passing the variable value A which has three values. Even i can pass the A variable by using the SUBSTR .But the problem is A varible is has not fixed number of values. They will increase dynamically.
Please tell me how can i pass the variable with different values.

Can anyone help me regarding the query?

Thanks in advance.

[Updated on: Thu, 10 May 2007 03:02]

Report message to a moderator

Re: Passing variable in IN clause with more than one values [message #236538 is a reply to message #236525] Thu, 10 May 2007 03:30 Go to previous messageGo to next message
Michel Cadot
Messages: 64119
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
Have a look at thread varying elements in IN list on AskTom.

Regards
Michel
Re: Passing variable in IN clause with more than one values [message #236540 is a reply to message #236538] Thu, 10 May 2007 03:43 Go to previous message
bhoite_amol83
Messages: 110
Registered: June 2005
Location: Pune
Senior Member
Thanks Michel,
Document which you send helps me.

Thanks once again.
Previous Topic: Write a single query to print calender
Next Topic: Duplicate Row Containing a Long Raw Field.
Goto Forum:
  


Current Time: Tue Dec 06 10:25:50 CST 2016

Total time taken to generate the page: 0.07955 seconds