| View previous topic :: View next topic |
| Author |
Message |
pfandler General User

Joined: 09 Jan 2006 Posts: 7
|
Posted: Thu May 17, 2007 12:32 am Post subject: SOLVED Calling stored procedures from Base |
|
|
Hello,
I want to call a MySQL stored procedure from OObasic (OO version 2.2).
When I call the function prepareCall(<sql statement>) then I get the following exception:
BASIC runtime error.
An exception occured
Type: com.sun.star.sdbc.SQLException
Message: XConnection::prepareCall: feature not implemented..
How can I call a stored procedure if the call is NOT IMPLEMENTED????
Last edited by pfandler on Sun May 20, 2007 9:54 pm; edited 1 time in total |
|
| Back to top |
|
 |
DrewJensen Super User


Joined: 06 Jul 2005 Posts: 2616 Location: Cumberland, MD
|
|
| Back to top |
|
 |
pfandler General User

Joined: 09 Jan 2006 Posts: 7
|
Posted: Sat May 19, 2007 12:33 am Post subject: |
|
|
| Thanks Drew, I will try with the newer version of ODBC. Now I use version 3 |
|
| Back to top |
|
 |
pfandler General User

Joined: 09 Jan 2006 Posts: 7
|
Posted: Sun May 20, 2007 9:53 pm Post subject: SOLUTION |
|
|
MySQL ODBC Connector V5 beta supports calling stored procedures.
It works this way:
| Code: |
dbpath="file:///C:/path/to/openoffice_database.odb"
DatabaseContext = createUnoService("com.sun.star.sdb.DatabaseContext")
oDataSource = DatabaseContext.getByName(dbpath)
if not oDataSource.isPasswordRequired then
oConnection = oDataSource.getConnection("username","password")
MsgBox "The database was opened: " & dbpath
else
MsgBox "Please log in to the database"
oHandler = createUnoService("com.sun.star.sdb.InteractionHandler")
oConnection = oDataSource.connectWithCompletion(oHandler)
end if
q1 = "call stored_procedure(" & paramstring & ");"
oConnection_m = oDataSource.getConnection("username","password")
oStatement_m = oConnection_m.CreateStatement
oResultSet_m = oStatement_m.executeQuery(q1)
|
The openoffice ODB file is created using a predefined MySQL ODBC v5 datasource. |
|
| Back to top |
|
 |
|