vBulletin Search Engine Optimization
| |||||||
| Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| ||||
| Hi, is it possible to store a query in mysql table and evaluate/ execute it from there? I have few big queries & i would like to store them in a table and execute them from there. how easy it is? i would also need some place hold to pass args. Thanks, Sasi |
| |||
| sasi wrote: > Hi, > is it possible to store a query in mysql table and evaluate/ > execute it from there? > I have few big queries & i would like to store them in a table and > execute them from there. > how easy it is? i would also need some place hold to pass args. > > Thanks, > Sasi > You can store it like any other string then fetch the string and execute it in your favorite language. Or you could create a view with the query and just select from the view. Alternatively you could create a stored procedure and pass parameters to it. -- ================== Remove the "x" from my email address Jerry Stuckle JDS Computer Training Corp. jstucklex@attglobal.net ================== |
| |||
| thanks for the reply. i am not using DBI. I am using mysql command line to query data. i have a table with 2 cols. {name, query} select query from qrytbl where name = "myqry1" return the query stored in table, but i dont know how to evaluate it. any help? thanks, --Sasi |
| |||
| On Mon, 13 Aug 2007 17:50:57 +0200, sasi <sasidublin@gmail.com> wrote: > thanks for the reply. > > i am not using DBI. I am using mysql command line to query data. > i have a table with 2 cols. {name, query} > > select query from qrytbl where name = "myqry1" > > return the query stored in table, but i dont know how to evaluate it. Copy/paste? I'd go for the View if possible. -- Rik Wasmus |
| |||
| sasi wrote: > thanks for the reply. > > i am not using DBI. I am using mysql command line to query data. > i have a table with 2 cols. {name, query} > > select query from qrytbl where name = "myqry1" > > return the query stored in table, but i dont know how to evaluate it. > > any help? > thanks, > --Sasi > > As Rik indicated - copy/paste. The query will just return the data, not execute it. View or stored procedure, depending on your needs. -- ================== Remove the "x" from my email address Jerry Stuckle JDS Computer Training Corp. jstucklex@attglobal.net ================== |
| |||
| i cannot use views as it doesn't provide any placehold to subtitute args passed from commandline. copy/paste will work, not a good idea when many people use. i am looking for some way simillar to, call query1 <arg1> <arg2> or eval query1 <arg1> <arg2> can i return a query values from procedures? say for example, if i want to return the output of this query (select c1,c2 from t1 where c1 = "str1") from a procedure, how to do it? pseudo code or any idea welcome thanks Sasi |
| ||||
| sasi wrote: > i cannot use views as it doesn't provide any placehold to subtitute > args passed from commandline. > copy/paste will work, not a good idea when many people use. > > i am looking for some way simillar to, > call query1 <arg1> <arg2> > or > eval query1 <arg1> <arg2> > > can i return a query values from procedures? > > say for example, if i want to return the output of this query (select > c1,c2 from t1 where c1 = "str1") from a procedure, how to do it? > > pseudo code or any idea welcome > > thanks > Sasi > > > > > No, you can't evaluate a query like you want. You can, however, pass 'c1' to a SP and have it perform the select for you. But if you're talking multiple tables joined together (a typical example), you could still use a view - just join the tables in your view and pass your WHERE clause to the view. Maybe if you post a real query you're trying to do it would help. -- ================== Remove the "x" from my email address Jerry Stuckle JDS Computer Training Corp. jstucklex@attglobal.net ================== |