Subject | Re: Stored Procedure for searching DB |
---|---|
Author | elkins_villalona |
Post date | 2006-11-13T22:50:14Z |
Using your approach somenthing like this will work
begin
if ( SEARCH_TYPE = 1 ) then
begin
For SELECT A.F1, A.F2, A.F3 FROM my_table A WHERE row1 STARTING
WITH :SEARCH_PARAM
INTO :V1, :V2, V3
DO BEGIN
suspend;
END
end
else
if ( SEARCH_TYPE = 2 ) then
begin
For SELECT B.F1, B.F2, B.F3 FROM my_table B WHERE row2 STARTING
WITH :SEARCH_PARAM
INTO :V1, :V2, V3
DO BEGIN
suspend;
END
end
end
You have to declare v1, v2 and v3 as returns values in your store
procedure.
I hope it help
Elkins
--- In firebird-support@yahoogroups.com, "killerion" <killerion@...>
wrote:
begin
if ( SEARCH_TYPE = 1 ) then
begin
For SELECT A.F1, A.F2, A.F3 FROM my_table A WHERE row1 STARTING
WITH :SEARCH_PARAM
INTO :V1, :V2, V3
DO BEGIN
suspend;
END
end
else
if ( SEARCH_TYPE = 2 ) then
begin
For SELECT B.F1, B.F2, B.F3 FROM my_table B WHERE row2 STARTING
WITH :SEARCH_PARAM
INTO :V1, :V2, V3
DO BEGIN
suspend;
END
end
end
You have to declare v1, v2 and v3 as returns values in your store
procedure.
I hope it help
Elkins
--- In firebird-support@yahoogroups.com, "killerion" <killerion@...>
wrote:
>
> I want to write a stored procedure to search among a several tables
> and diferent types of search paramenters but always one parameter at a
> time the reason I want to do this is to simplify a huge portion of the
> code in my aplication, what I've been thinking of is just sending the
> search paramenter and search type to the stored procedure and through
> a series of ifs decide whicch is the apropiate select query kind of
> like this:
>
> begin
> if ( SEARCH_TYPE = 1 ) then
> SELECT * FROM my_table WHERE row1 STARTING WITH :SEARCH_PARAM
> else if ( SEARCH_TYPE = 2 ) then
> SELECT * FROM my_table WHERE row2 STARTING WITH :SEARCH_PARAM
> else if ( SEARCH_TYPE = 3 ) then
> SELECT * FROM my_table WHERE row2 STARTING WITH :SEARCH_PARAM
> suspend;
> end
>
> now my problem is how do I return multiple rows with this procedure?
> and is this a good idea or can you suggest something better?
>
> Jankowiak
>