OpenOffice.org Forum at OOoForum.orgThe OpenOffice.org Forum
 
 [Home]   [FAQ]   [Search]   [Memberlist]   [Usergroups]   [Register
 [Profile]   [Log in to check your private messages]   [Log in

Can you execute insert into statements?

 
Post new topic   Reply to topic    OOoForum.org Forum Index -> OpenOffice.org Macros and API
View previous topic :: View next topic  
Author Message
Decker87
OOo Enthusiast
OOo Enthusiast


Joined: 21 May 2007
Posts: 163

PostPosted: Mon Jun 11, 2007 11:35 am    Post subject: Can you execute insert into statements? Reply with quote

Is it possible to execute SQL statements other than SELECT?
Back to top
View user's profile Send private message
Mark B
Super User
Super User


Joined: 16 Feb 2007
Posts: 852
Location: Lincolnshire, UK

PostPosted: Mon Jun 11, 2007 11:42 am    Post subject: Reply with quote

Hi

I don't know if you've seen my downloadable chapter on using databases with macros at http://www.packtpub.com/openoffice-ooobasic-calc-automation/book - that will show you how to implement select, update and insert statements through OOo basic.

Mark
_________________
Mark B's Articles
Back to top
View user's profile Send private message Send e-mail Visit poster's website MSN Messenger
Decker87
OOo Enthusiast
OOo Enthusiast


Joined: 21 May 2007
Posts: 163

PostPosted: Mon Jun 11, 2007 12:09 pm    Post subject: Reply with quote

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
View user's profile Send private message
squenson
Super User
Super User


Joined: 09 Mar 2007
Posts: 690
Location: Nis, Serbia

PostPosted: Mon Jun 11, 2007 12:27 pm    Post subject: Reply with quote

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
View user's profile Send private message
Decker87
OOo Enthusiast
OOo Enthusiast


Joined: 21 May 2007
Posts: 163

PostPosted: Mon Jun 11, 2007 12:37 pm    Post subject: Reply with quote

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
View user's profile Send private message
squenson
Super User
Super User


Joined: 09 Mar 2007
Posts: 690
Location: Nis, Serbia

PostPosted: Mon Jun 11, 2007 9:21 pm    Post subject: Reply with quote

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
View user's profile Send private message
Decker87
OOo Enthusiast
OOo Enthusiast


Joined: 21 May 2007
Posts: 163

PostPosted: Tue Jun 12, 2007 4:01 am    Post subject: Reply with quote

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
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    OOoForum.org Forum Index -> OpenOffice.org Macros and API All times are GMT - 8 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group