On Wednesday, March 16, 2005 09:30, sguazt sguazt wrote: > Hi folks! > > (I hope this is the right list ... if not please tell me where I can > submit this post) > > I would like to create a MySQL UDF (i.e. User Defined Function) that > embeds a query; for instance, suppose the UDF is named foobar: > > mysql> SELECT foobar(); > > When foobar function receives the control from the MySQL, it attempts > to create a query. To do so it has to connect to DB (since it seems > there's no way to access to current DB connection from a UDF function > -- at least I did'nt find it any way). So the flow of execution is: > SELECT foobar() > 1 --> Call foobar > 2 -----> init MySQL > 3 -----> connect to MySQL > 4 -----> create/execute query > 5 -----> get query result > 6 -----> close MySQL connection > 7 -----> return result
[...snip...] > const char* query = "SELECT COUNT(*) FROM tblfoobar"; Can you explain exactly what you are using this for? What benefit does this provide over just executing the query? You can either execute SELECT foobar() or SELECT COUNT(*) FROM tblfoobar, and you don't have to do anything to make the latter work. Creating the UDF just seems like a lot of extra work. Maybe this is my ignorance, but I don't see much use for executing a query within a UDF esspecially if you are using 4.1 with subqueries. -- Tom Crimmins Interface Specialist Pottawattamie County, Iowa -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]