Subject | Re: RES: RES: [firebird-support] Null and parameters |
---|---|
Author | Christian Danner |
Post date | 2006-01-07T15:46:49Z |
Hi Adam,
on Fri, 06 Jan 2006 11:51:35 -0000, you wrote:
necessarily both.
Within a sp the originally discussed syntax does work, no problematic
client side replacement of the variable.
So why not:
create procedure getcustomers (
pcode integer)
returns (
codigo integer,
nome varchar(100))
as
begin
for select c.codigo, c.nome
from customers c
where (:pcode is null)
or (c.codigo = :pcode)
into :codigo, :nome
do
suspend;
end
Regards
Christian
on Fri, 06 Jan 2006 11:51:35 -0000, you wrote:
>create procedure getcustomersShouldn't either 'execute statement' or a sp be used, but not
>(
>pCode integer
>)
>returns
>(
>Codigo Integer,
>NOME varchar(100)
>)
>as
>declare variable stmt varchar(200)
>begin
>stmt = 'SELECT c.Codigo, c.Nome FROM CUSTOMERS C';
>
>if (:pCode is not null) then
>begin
> stmt = stmt || ' WHERE C.CODIGO = ' || :pcode;
>end
>
>for execute statement stmt
>into :Codigo, :Nome do
>begin
> suspend;
>end
necessarily both.
Within a sp the originally discussed syntax does work, no problematic
client side replacement of the variable.
So why not:
create procedure getcustomers (
pcode integer)
returns (
codigo integer,
nome varchar(100))
as
begin
for select c.codigo, c.nome
from customers c
where (:pcode is null)
or (c.codigo = :pcode)
into :codigo, :nome
do
suspend;
end
Regards
Christian