Subject Re: [firebird-support] 'IN' problem
Author Ann W. Harrison
Nick Upson wrote:
> I'm trying to use a list of ids to exclude in a select called from C.

If you were doing this in a stored procedure, you'd use execute
statement. Version 2 has an execute block which has similar
characteristics. But basically, you can't replace an in list
with a single string parameter and expect the system to parse
the string into a list of the actual items you want evaluated.

Regards,


Ann



> To try and make it easier to explain this SP shows the same problem. I
> provide a list of id's in a varchar, but 1 & 2 both ignore the IN,
> only the 3rd gives the answer I'm looking for.
>
> How can I get the same answer?
>
> CREATE OR ALTER PROCEDURE AA_TEST (str Varchar(40))
> returns (rcount2 Integer,
> rcount1 Integer,
> rcount3 Integer)
> AS
>
> begin
>
> str = '1, 2, 3';
>
> SELECT count(*) FROM TBLTXAPPMSGQ WHERE BASEIDENT NOT IN ( '1, 2, 3' )
> into :rcount1;
>
> SELECT count(*) FROM TBLTXAPPMSGQ WHERE BASEIDENT NOT IN ( :str ) into :rcount2;
>
> SELECT count(*) FROM TBLTXAPPMSGQ WHERE BASEIDENT NOT IN ( 1, 2, 3 )
> into :rcount3;
> end
>
>
> ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
>
> Visit http://www.firebirdsql.org and click the Resources item
> on the main (top) menu. Try Knowledgebase and FAQ links !
>
> Also search the knowledgebases at http://www.ibphoenix.com
>
> ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
>
> Yahoo! Groups Links
>
>
>
>