Ask Your Question

Base: Getting DB value into macro variable [closed]

asked 2014-05-15 10:51:01 +0200

CEAuke gravatar image

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)

edit retag flag offensive reopen merge delete

Closed for the following reason the question is answered, right answer was accepted by Alex Kemp
close date 2016-02-22 17:40:51.295842

2 Answers

Sort by » oldest newest most voted

answered 2014-05-15 13:40:16 +0200

JPL gravatar image

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

edit flag offensive delete link more


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?

CEAuke gravatar imageCEAuke ( 2014-05-15 15:26:37 +0200 )edit

answered 2014-05-16 10:13:19 +0200

CEAuke gravatar image

Ok, I think I found the standard way of doing this. I'm using LiberOffice 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
 result=SQL.executeQuery("select 'x' from PARTIES")
 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")
edit flag offensive delete link more

Question Tools

1 follower


Asked: 2014-05-15 10:51:01 +0200

Seen: 3,529 times

Last updated: May 16 '14