Subject | Re: Building query strings in stored procedures? |
---|---|
Author | willogibbo |
Post date | 2005-05-20T09:37:43Z |
--- In firebird-support@yahoogroups.com, Tim Gahnström
<tim.gahnstrom@i...> wrote:
Ann suggested. It will give you the flexibility you are looking for
but not any speed increase.
to the SP. This way you don't have to pass in and parse an array annd
you can keep most of the logic in PHP.
I don't quite understand how to make EXECUTE work for me. Perhaps you
could mention some kind of basic example to get me going.
I know this is wrong, but the sort of thing I have tried so far, using
a basic FOR SELECT ... DO loop has been
FOR SELECT assetid FROM tblasset querystring
INTO :outputfield
DO
BEGIN
SUSPEND;
END
in which querystring would be an input variable with something like
'WHERE groupid=162'
This doesn't work and shows that I'm not with it on this!
Thanks again for your input. Will
<tim.gahnstrom@i...> wrote:
> > Check the EXECUTE STATEMENT statement. You can build up abuild the query string inside your SP and use the EXECUTE STATEMENT as
> > SQL statement in a procedure then execute it.
>
> You could pass arrays to a stored procedure (I don't know how) and
Ann suggested. It will give you the flexibility you are looking for
but not any speed increase.
>in advance and this is not possible using the EXECUTE STATEMENT.
> The reason SPs are faster is because they are compiled and optimized
>your query string on the clientside (in php) and pass it as a string
> This is a drawback but it also means that you can just as well build
to the SP. This way you don't have to pass in and parse an array annd
you can keep most of the logic in PHP.
>STATEMENT and only use ordinary IF statements etc in your SP.
> If you really need the speed your option is to skip the EXECUTE
>Thanks Tim and Ann for your thoughts.
> Tim
I don't quite understand how to make EXECUTE work for me. Perhaps you
could mention some kind of basic example to get me going.
I know this is wrong, but the sort of thing I have tried so far, using
a basic FOR SELECT ... DO loop has been
FOR SELECT assetid FROM tblasset querystring
INTO :outputfield
DO
BEGIN
SUSPEND;
END
in which querystring would be an input variable with something like
'WHERE groupid=162'
This doesn't work and shows that I'm not with it on this!
Thanks again for your input. Will