Is it possible to retrieve the name of the database table(s)

Posted by Rom Elwell on 18-Feb-2014 11:44

Setup (running OE 10.2b):

DEFINE BUFFER EMPemployee FOR employee.
DEFINE BUFFER EMPdepartment FOR department.

DEFINE QUERY qryEmployee FOR EMPemployee, EMPdepartment.

DEFINE DBTable AS CHAR.

...

DBTable = QUERY qryEmployee:HANDLE:GET-BUFFER-HANDLE (1):<WHAT GOES HERE>

QUESTION:


What I am ultimately trying to retrieve is the name of the DB tables ('Employee', 'Department') referenced by the buffers in the query object.  For example, if I use QUERY qryEmployee:HANDLE:GET-BUFFER-HANDLE (1):NAME, the output value is 'EMPemployee'.  I am not concerned with the name of the associated buffer, rather the name of the underlying DB table.

Thanks in advance for any advice you care to share.

Posted by Peter Judge on 18-Feb-2014 12:40

AH, that's easy. Take a look at buffer-handle:TABLE-HANDLE or buffer-handle:TABLE for a name (the Buffer Object Handle in the Help).

But in your example you have the db table buffer handle already.

All Replies

Posted by Thomas Mercer-Hursh on 18-Feb-2014 12:10

Handle to the DB table makes no sense.  Is it the name of the DB table that you want?

Posted by Rom Elwell on 18-Feb-2014 12:11

Yes.

Posted by Håvard Danielsen on 18-Feb-2014 12:22

>hdlDBTable = QUERY qryEmployee:HANDLE:GET-BUFFER-HANDLE (1):<WHAT GOES HERE>.

Nothing goes here...

--------------------

DEFINE var hdlDBTable AS HANDLE.

hdlDBTable = QUERY qryEmployee:HANDLE:GET-BUFFER-HANDLE (1).

---------

Or

----

hdlDBTable = QUERY qryEmployee:HANDLE:GET-BUFFER-HANDLE ("EMPemployee").

-----

Posted by Rom Elwell on 18-Feb-2014 12:25

Thank you for the reply hdaniels.  As Dr. Mercer-Hursh astutely pointed out in his previous post, I am not looking for a handle to the buffer defined by the query object, rather, I am attempting to discern the name of the db table that this buffer references.

Posted by Peter Judge on 18-Feb-2014 12:28

EMPemployee and EMPdepartment are both buffers on the DB table. As are employee and department (ie you never talk to a database table without going through a buffer).

So Get-buffer-handle(n) gets you what you're asking for.

If you want another buffer on the database table that has a different name, use

DEF VAR hNamedEmpBuffer as handle.

create buffer hNamedEmpBuffer  for table Employee buffer-name 'AnotherEmployee'.

The buffer-name modifier is vital here.

-- peter

Posted by Thomas Mercer-Hursh on 18-Feb-2014 12:34

I think the point is that he would like to query the handle of EMPemployee and find out that it is a buffer for employee.

Posted by Rom Elwell on 18-Feb-2014 12:39

Thomas is correct.  I apologize for the confusion I have caused.  I have updated the original question in light of my ignorance.

Posted by Peter Judge on 18-Feb-2014 12:40

AH, that's easy. Take a look at buffer-handle:TABLE-HANDLE or buffer-handle:TABLE for a name (the Buffer Object Handle in the Help).

But in your example you have the db table buffer handle already.

Posted by Rom Elwell on 18-Feb-2014 12:43

Thank you to everyone that replied.  Peter has provided the answer I was looking for to this question.  I appreciate the mentoring, gentlemen.

This thread is closed