Subject | Re: complex select |
---|---|
Author | Marco Menardi <mmenaz@lycosmail.com> |
Post date | 2003-02-16T16:01:06Z |
You CAN use SP in a select. Be sure that you have a SUSPEND on each
row that is returned by the SP, or if only one is returned, at the end
of the SP.
One trick I learned is use JOIN with ON (1=1) when you don't have
comparison fields usefull for the join.
You will have selects like this:
...
CLIENTI.NOME,
GET_CONTO_CORRENTE_UNICO.OUT_CONTO_CORRENTE_ID,
...
FROM WK_SELEZIONI
LEFT JOIN GET_CONTO_CORRENTE_UNICO(WK_SELEZIONI.CONDOMINIO_ID, 'DEF')
ON (1=1)
...
where GET_CONTO_CORRENTE_UNICO is a SP, and
WK_SELEZIONI.CONDOMINIO_ID, 'DEF' are input parameters of the SP.
OUT_CONTO_CORRENTE_ID is a returning value of the SP.
Consider also the use fo FOR SELECT ... in a SP, that gives you the
possibility of elaborate each line of your main select, and decide the
returning rows values.
regards
Marco Menardi
--- In ib-support@yahoogroups.com, "duilio_fos <irel_llc@l...>"
<irel_llc@l...> wrote:
row that is returned by the SP, or if only one is returned, at the end
of the SP.
One trick I learned is use JOIN with ON (1=1) when you don't have
comparison fields usefull for the join.
You will have selects like this:
...
CLIENTI.NOME,
GET_CONTO_CORRENTE_UNICO.OUT_CONTO_CORRENTE_ID,
...
FROM WK_SELEZIONI
LEFT JOIN GET_CONTO_CORRENTE_UNICO(WK_SELEZIONI.CONDOMINIO_ID, 'DEF')
ON (1=1)
...
where GET_CONTO_CORRENTE_UNICO is a SP, and
WK_SELEZIONI.CONDOMINIO_ID, 'DEF' are input parameters of the SP.
OUT_CONTO_CORRENTE_ID is a returning value of the SP.
Consider also the use fo FOR SELECT ... in a SP, that gives you the
possibility of elaborate each line of your main select, and decide the
returning rows values.
regards
Marco Menardi
--- In ib-support@yahoogroups.com, "duilio_fos <irel_llc@l...>"
<irel_llc@l...> wrote:
> I have a SP that contains a complex SELECT.
>
> (The SELECT is enclosed at the end of the message, but there is no
> use in trying to understand the logics behind it: mine is a general
> question).
>
> God knows how long it took me to have the source code compiled into
> FB, not to tell how long it took me to test the code!
>
> Usually you don't write complex programs: you divide complex programs
> in short, manageable chunks that you can be tested separately.
>
> Then you build the program as a main procedure that calls several
> different procedures and you get a short, clear program.
>
> Going back to my SELECT, some parts of the code could well be written
> as different SPs, but I cannot use SPs in a SELECT, can I ?
>