Hello,
how can i use Stored Procedures in Qt4?
I like to save information in a MySQL table. The return of this should be the unique ID from the new row.
Or is there a way to do this without Stored Procedures?
Thanks a lot!
Martin
Hello,
how can i use Stored Procedures in Qt4?
I like to save information in a MySQL table. The return of this should be the unique ID from the new row.
Or is there a way to do this without Stored Procedures?
Thanks a lot!
Martin
Everything depends on the database you use.Originally Posted by pinktroll
http://doc.trolltech.com/4.1/sql-dri...cedure-support
I don't use MySQL, but in PostgreSQL you can do it like this:Originally Posted by pinktroll
SQL Code:
INSERT ...; SELECT currval( 'sequence_name' );To copy to clipboard, switch view to plain text mode
Maybe MySQL has a similar method, for example using @variables?
Anyway creating stored procedures for common queries might reduce the number of mistakes and increase performance.
pinktroll (27th August 2006)
uuuh.. i am blind!![]()
I tried with INOUT parameters also without them..
but i always used query.bindValue().. and thats not working, right?
So thank you very much!
p.s. MySQL has a similar method to PostgreSQL currval(), its called mysql_insert_id().
bindValue() is for setting and boundValue() for reading, but MySQL is a special case --- see the link above.Originally Posted by pinktroll
Thats waht i notized.. in some cases MySQL is really different..bindValue() is for setting and boundValue() for reading, but MySQL is a special case --- see the link above.
So it means using stored procedures with MySQL will stick my application to that database?
Stored procedures handling usually differs between databases, but you could try to create a workaround. For example by writing a function that invokes stored procedure --- this way you will have only one place where you will have to handle the differences.Originally Posted by pinktroll
That would be a solution. Til now i don`t need the functionality to switch database system i`m still learning Qt and C++. But i will keep it in mind, maybe i find a easy way of handling with it.
Could be a nice feature to impress my boss![]()
Thanks for your great help!
Bookmarks