Base: Getting DB value into macro variable

Hi guys

How can I retrieve a value from the database into a variable in a macro. (basic)

I have a on_change event macro where I want to do the following:
SQL → variable
formfieldA = formfieldB * variable

The second bit I can do. But I can’t figure out how to get the select to return the value into the variable. In Oracle PL/SQL you use:
Select employeename INTO empvar from emplyoees where emp_id=1;
but it seems that you dont have this type of structure with base. (I’m using the ‘standard’ Hsomehting database that comes with base)

I suggest you to have a look at the Access2Base library (included in LO 4.2).
It is documented here.

Hi JPL. Thanks for the link. Are you saying that what I’m trying to do is not avialable by default or that this Access2Base is another way of doing it?

Ok, I think I found the standard way of doing this. I’m using LiberOffice 4.1.6.2 which was the default that I could download. When LibreOffice 4.2 is the default, I can start readin up on access2base.

So for the current LibreOffice, the bit of info that I was missing is the workings of the executeQuery function.

Here’s an example of how this works easily

dim Connection,SQL as object
dim myVar
 Connection=oForm.ActiveConnection 
 SQL=Connection.createStatement()
 result=SQL.executeQuery("select 'x' from PARTIES") 
 result.next
 myVar = result.getstring(1)

I didn’t know you can assign the executeQuery to a result variable. I thought you just call it to execute updates.
E.g:

SQL.executeQuery("update parties set name='ME' where party_id=1")