Subject RE: [IBO]Parameter values in DeleteSQL
Author Paul Hope
> Paul Hope wrote:
> > Hi Helen
> >
> > I changed one of them to :REC and it worked. However it
> seems to me
> > to be a poor Delphi interface when IBO cant interpret a
> valid Delphi statement.
> >
> > I have just had another parameter problem with a straight
> forward TIB_Cursor
> > with 'and((:WHS='')or(WHS=:WHS))'. When the value of
> Parameter WHS is set
> > to '', IBO chooses to convert that to ' ' (WHS is char(1)),
> this then
> > causes a string truncation error.
> >
> > IMO parameter handling could be improved.
> >
>
> No! That would break lots of applications. (Strange though
> that you get a string truncation error, should be just an
> empty result).

I havent thought through what the changes might be but Im not convinced they
would have to break applications.

>
> I use a similar construct a lot. It caters for a generic
> application and lots of reporting queries. Try to write;
>
> and ((:WHS = ' ') or (WHS = :WHS))
>

Sure I could. Then in Delphi I would have
if eWHS.Text='' then
paramByName('WHS').AsString:=' ' else
paramByName('WHS').AsString:=eWHS.Text;
As opposed to just
paramByName('WHS').AsString:=eWHS.Text;

> If WHS is Char(1) then the parameter
> should be too. Maybe you could redefine WHS to be VARCHAR(1)
> but that is awkward.

I'm beggining to wish I had defined it as VARCHAR(1) ;-)

> Another solution is this;
>
> and ((:WHS = 'F') or (WHS = :WHS_VAL))
>
> which to be honest I use more often. That would force you to
> fill two different parameters with the same value.

I know - this works fine. It just seems another example of IBO making thing
more difficult than they could be.

This is a simple stored procedure

CREATE PROCEDURE TEMPTEST(
WHS CHAR(1))
RETURNS (
DESCRIPTION VARCHAR(15))
AS
begin
for select description from warehouses
where ((''=:WHS)or(ref=:WHS))
into :description do suspend;
end

It works perfectly if you send it an empty string (ie it returns all
warehouses rows). Also this isnt a client interface thing when setting the
paramater value - if you add the line WHS=''; (overriding the input value)
it still works. So if FB is happy to handle an empty char parameter I don't
see why IBO shouldn't be.

Regards
Paul