Subject Re: [firebird-support] Selecting records based on a list of ids (sp parameter)
Author Alexandre Benson Smith
At 10:30 06/04/2004 -0700, you wrote:

>Hi,
>
>Question:
>
>What is the preferred way to pass a variable list of record IDs to a stored
>procedure and then return records that are based on the list?
>
>I have tried the usual suspects: Select IN (:list_of_ids) etc. :-)
>
>Here is some background on the issue and perhaps there is a better design
>solution:
>
>We are trying to port an mssql db to firebird. The overall port is simple but
>for one thing: we have a master/detail level relationship between
>databases and
>tables in those databases (I know it's a bad thing, but there are multiple
>business requirements that mandate this design, or better put it's the
>lesser of
>the evils). Anyhow, since FB can't do cross-database joins, we figured we
>will
>have our client app query the master database for a list of Ids and then pass
>that list to the second database as a string or something similar and
>basically
>get the recordset that way.
>
>So, is there a better way to do this? If not, how can this be done?
>
>Thanks in advance
>
>Raf

Raf,

If this is a Stored Proc the number of ID's is known right ? If so, you
should just bind the Id's get from the master database to each parameter.

If you will query the master database, you could on the client app just
format the string to be passed to the server.

something like

S := 'Select * from MyTable where MyTableId in (' + Id[1];

for I := 2 to IDCount do begin
S := S + ', ' + Id[I];
end

S := S + ')';

Is something like this you are looking for ???

HTH


Alexandre Benson Smith
Development
THOR Software e Comercial Ltda.
Santo Andre - Sao Paulo - Brazil
www.thorsoftware.com.br

----------


---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.631 / Virus Database: 404 - Release Date: 17/03/2004


[Non-text portions of this message have been removed]