| View previous topic :: View next topic |
| Author |
Message |
Decker87 OOo Enthusiast

Joined: 21 May 2007 Posts: 163
|
Posted: Mon Jun 11, 2007 11:35 am Post subject: Can you execute insert into statements? |
|
|
| Is it possible to execute SQL statements other than SELECT? |
|
| Back to top |
|
 |
Mark B Super User


Joined: 16 Feb 2007 Posts: 852 Location: Lincolnshire, UK
|
|
| Back to top |
|
 |
Decker87 OOo Enthusiast

Joined: 21 May 2007 Posts: 163
|
Posted: Mon Jun 11, 2007 12:09 pm Post subject: |
|
|
Hmm, I read that chapter and I have to say that I really like your style. You clearly say what commands are, and how to use them. I find random code snippets are useful but very hard to learn from.
That aside, at first I had a problem with my values trying to violate index rules. But, I fixed that. However, I get an error saying that 'No ResultSet was produced'. The command executes properly and adds the data; however, it still expects a result set no matter what.
Is there a way to cure this? |
|
| Back to top |
|
 |
squenson Super User


Joined: 09 Mar 2007 Posts: 690 Location: Nis, Serbia
|
Posted: Mon Jun 11, 2007 12:27 pm Post subject: |
|
|
Decker87,
Could you be a little bit more specific and show us the few lines of codes that you use to execute your query, it will help us to help you. _________________ Help us to help you: Add [Solved] to the title of the thread if you agree with the answer
>>> Do you know the new OOo support forum http://user.services.openoffice.org/en/forum/index.php? <<< |
|
| Back to top |
|
 |
Decker87 OOo Enthusiast

Joined: 21 May 2007 Posts: 163
|
Posted: Mon Jun 11, 2007 12:37 pm Post subject: |
|
|
| Code: | Sub insert_into_country (oEv)
Dim oRS, oStatement, oForm as object
oForm=oEv.Source.Model.Parent
oStatement=oForm.ActiveConnection.CreateStatement
oStatement.executeQuery("INSERT INTO VEH_COUNTRY VALUES(31,30,30)")
End Sub |
This is called from a button on a form which is already connected to the database. As said, the query executes just fine, but OOo expects a result set, but SELECT is the only command which returns one. |
|
| Back to top |
|
 |
squenson Super User


Joined: 09 Mar 2007 Posts: 690 Location: Nis, Serbia
|
Posted: Mon Jun 11, 2007 9:21 pm Post subject: |
|
|
Decker87,
It may not be the solution, but I normally use ExecuteQuery as a function, which means it returns a result. So my statement normally is: | Code: | | Result = SQLStatement.executeQuery (SQLQuery) |
_________________ Help us to help you: Add [Solved] to the title of the thread if you agree with the answer
>>> Do you know the new OOo support forum http://user.services.openoffice.org/en/forum/index.php? <<< |
|
| Back to top |
|
 |
Decker87 OOo Enthusiast

Joined: 21 May 2007 Posts: 163
|
Posted: Tue Jun 12, 2007 4:01 am Post subject: |
|
|
| Yes, executeQuery IS a function, that is the problem. It always executes the query, then attempts to return a result. However, not all statements return a result. I wonder if it's possible to modify the executeQuery function, do you know which library it is in? |
|
| Back to top |
|
 |
|