Subject Re: [firebird-support] Custom search string
Author Grant Brown
Hi Helen,

You missed the point of my question entirely :-(

So we'll start at the start OK

/>>>>> /I need to create a custom search string in a stored procedure
subject to
/>>>>> /the fields that the user has selected.

/>>>>> /On a particular form in our application we have 10 user input
devices,
/>>>>> /some are standard edit boxes, some are drop down lists.

Simply explaining the starting point of the query - nothing to do with
Delphi

/>>>>> /I need the "where" clause of the _*stored procedure*_ to cope
with this set
/>>>>> /up subject to what ever the user has selected.

I am trying to find out how to create a dynamic stored procedure that
can will emulate what I describe below, again nothing to do with Delphi.

/>>>>> /If I was creating a normal sql query statement then I could just add
/>>>>> /together the required bits and end up with the final "where" clause.

/>>>>> /eg -
/>>>>> /ABC.SQL.Add('where Detect= :123);
/>>>>> /if X = true then ABC.SQL.Add('and Text1= :T1);
/>>>>> /if C = true then ABC.SQL.Add('and Text2= :T2);
>
/>>>>> /and so on and so on until I get the final "where" clause for
the query.

again trying to explain my desired outcome and again nothing to do with
Delphi.

/>>>>> /My question is how do I set up a stored procedure that could be
created
/>>>>> /at runtime ?

Now to my question.

/>>>>> You don't create stored procedures at runtime.

/I am aware of this hence my question./
/
/>>>>> /Is this do able or can I only do this with "querys" and then
send the
/>>>>> /whole query to the DB server.

/>>>>> /It really seems that you don't know about parameters in dynamic
/>>>>> / SQL. Please signal "yes" or "no" to this. :-)

Yes - I do understand them, but my question was / and is about how to I
write stored procedure that emulates what I tried to explain above.

/>>>>> / e.g. (for Delphians):

/>>>>> / Statement (which can be persistent and should be, if possible
for this type
/>>>>> / of application, since you can prepare it once and keep it
prepared for a
/>>>>> / series of "hits" on the search)::::

/>>>>> / select blah from aTable
/>>>>> / where Detect = :Detect
/>>>>> / and Text1 = :Text1
/>>>>> / and Text2 like :Text2

/>>>>> / ....in BeforeOpen:

/>>>>> / with abc do
/>>>>> / begin
/>>>>> / ParamByName('Detect') := YourControl.Text;
/>>>>> / ParamByName('Text1') := AnotherControl.Text;
/>>>>> / ParamByName('Text2) := YetAnother.Text + '%';
/>>>>> / end;

Dont know where that bit cam from as it does not reflect my question.

Helen, I think that I asked a reasonably decent Fire Bird question upon
which even you reflect upon in your book (pg 592 - 2nd para)

Quite frankly - I dont understand how you could frame your response in
such a manner given that my entire question was and is related to stored
procedures.

--
Regards,
Grant Brown

Product Development Manager
Phone : 02 4229 1185
Mobile : 0412 926 995
Email : grant@...
Web : www.sitedoc.com.au

SiteDoc - Easy to Use - Powerful Results