[Gambas-user] Multiple Queries

Rob sourceforge-raindog2 at ...94...
Sat Sep 6 18:52:17 CEST 2003


On Saturday 06 September 2003 01:15, Tahara wrote:
> Do you guys know the algorithm of running multiple queries in
> gambas ? so, if i have queries like this:
> use `mysql`;
> select * from `user`;
> delete from `user`;
> I write them in textarea and when I hit the button, the
> queries will work just fine.. (just like other front-end)..

I would expect that running multiple queries like that would be 
the front end (i.e. your program) to handle, not the interface 
to mysql.  You could do it like this (in the submit button's 
click event):

dim statements as new String[]
dim statement as string
...
statements = split(",", myTextArea.Text)
for each statement in statements
	myConnectionObject.exec(statement)
next

Obviously I haven't error checked that code, but that's my guess.  
I've also seen front ends that use the word "go" instead of a 
semicolon, and of course if you ever have a statement that 
includes a semicolon as part of a string value or something 
you'll need to check for that somehow (which will be easier once 
perl-style regexes are here ;) )

I guess I'd suggest doing a myConnectionObject.Begin before the 
above, and myConnectionObject.Commit after (or a 
myConnectionObject.Rollback in a CATCH clause if you want to 
implement error handling.)

Rob





More information about the User mailing list