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

How to return a single value from a table?

 
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: Thu May 31, 2007 7:21 am    Post subject: How to return a single value from a table? Reply with quote

Hello. I have a table in OOo Base which has two columns, veh_make and veh_make_id. It looks something like this:
veh_make: Dodge, Mitsubishi, Honda, Toyota, Chevrolet
veh_make_id: 0, 1, 2, 3, 4

I want to set a variable equal to veh_make_id when given veh_make.
In other words, my macro can figure out that veh_make is "Toyota", but from this info I want to set another variable equal to 4. How can this be done?

In other words, I want to return the result of
Code:
SELECT ""veh_make_id"", ""veh_make_id"" FROM ""veh_make"" WHERE veh_make = 'Mitsubishi'
Back to top
View user's profile Send private message
TerryE
Super User
Super User


Joined: 16 Jul 2006
Posts: 550
Location: UK

PostPosted: Thu Jun 07, 2007 5:27 pm    Post subject: Reply with quote

There are quite a few examples on this. Rather than me giving you specific ones, why not try searching for "SQL AND select" from this forum and from the Code Snippets forum and look at te examples discussed?
_________________
Terry
WinXPSP3, OOo 2.4.1, Ubunto 8.04 for development
Also try the Official OOo Community Forum where I mainly post now.
Back to top
View user's profile Send private message Visit poster's website
Decker87
OOo Enthusiast
OOo Enthusiast


Joined: 21 May 2007
Posts: 163

PostPosted: Fri Jun 08, 2007 5:15 am    Post subject: Reply with quote

I do not think it can be done with a select statement. These statements return result sets, not individual strings or numbers.
Back to top
View user's profile Send private message
Decker87
OOo Enthusiast
OOo Enthusiast


Joined: 21 May 2007
Posts: 163

PostPosted: Fri Jun 08, 2007 7:53 am    Post subject: Reply with quote

A little update. The key seems to be the getString and getInt methods. But, how in the world are these used? I have a resultset stored in a variable, but I don't know how to return a value from this set using those methods.
Back to top
View user's profile Send private message
TerryE
Super User
Super User


Joined: 16 Jul 2006
Posts: 550
Location: UK

PostPosted: Fri Jun 08, 2007 2:47 pm    Post subject: Reply with quote

D, I am not sure exactly what you are talking about here. When we talk about Base, we are really talking about two things. The first is a database platform implemented in Java and called HSQL that is bundled in OOo, but in fact is separately available from http://hsqldb.org/. This site also includes a lot of documentation, specifications, FAQs, etc. that are light in the OOo bundle. If you run windows then you will also have the Jet Engine installed. This is the low end database platform that is bundled with al MS OSs and is used by Access and many system utilities. There are also many other mor powerful databases that are freely downloadable, such as MySQL. OOo supports any database that provides an JDBC connector, and section 12 of the SDK describes how to use the UNO API to access and use these. OK the examples are in C++ and Java, but they map back into Basic quite easily.

The second thing s a GUI and builder package that sites over the database and provides a user environment to build applications much in the same way that Access does over the Jet Engine. To me a major difference between Base and Access is that whilst VBA is fully integrated into Access, the UNO API and macro languages sit uncomfortably alongside Base. The getXXXX methods are part of the UNO API.

The stickies at the head of this forum explain how to biuld applications using Base and related tips and techniques in developing a database application. The really isn't any painfree quick start here other than reading these stickies and the resources they point to. Sorry.
_________________
Terry
WinXPSP3, OOo 2.4.1, Ubunto 8.04 for development
Also try the Official OOo Community Forum where I mainly post now.
Back to top
View user's profile Send private message Visit poster's website
Decker87
OOo Enthusiast
OOo Enthusiast


Joined: 21 May 2007
Posts: 163

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

Terry, I am not new to databases. I am just asking how to use the getString() and getInt() methods because there is no documentation on it.

What I am saying is, I have a result set which looks like this:

This is what a select statement returns, a result set. It does not return a string, integer, etc.

What I am asking, is how do I return the string "ENGLISH" from that result set?
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