Subject | Stored Procedure for searching DB |
---|---|
Author | killerion |
Post date | 2006-11-13T21:07:08Z |
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
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