Featured post
mysql - SELECT-ing data from stored procedures -
i have complicated select
query filters on time range, , want time range (start , end dates) specifiable using user-supplied parameters. can use stored procedure this, , return multiple-row result set. problem i'm having how deal result set afterwards. can't like:
select * (call stored_procedure(start_time, end_time))
even though stored procedure select
takes parameters. server-side prepared statement don't work (and they're not persistent either). suggest using temporary tables; reason that's not ideal solution 1) don't want specify table schema , seems have to, , 2) lifetime of temporary table limited invocation of query, doesn't need persist beyond that.
so recap, want persistent prepared statement server-side, return result set mysql can manipulate if subquery. ideas? thanks.
by way, i'm using mysql 5.0. know it's pretty old version, feature doesn't seem exist in more recent version. i'm not sure whether select-ing stored procedure possible in other sql engines; switching not option @ moment, i'd know whether it's possible anyway, in case decide switch in future.
selecting functions possible in other engines. instance, oracle allows write function returns table of user defined type. can define result sets in function, fill them using queries or using combination of selects , code. eventually, result set can returned function, , can continue query on using:
select * table(functiontobecalls(parameters));
the disadvantage, result set not indexed, might slow if function used within complex query.
in mysql nothing possible. there no way use result set procedure directly in select query. can return single values function , can use out
or inout
parameters procedure return values from. entire result sets not possible. filling temporary table within procedure closest get.
- Get link
- X
- Other Apps
Comments
Post a Comment