CREATE BUFFER h_tablehandle[i] FOR TABLE pc_table problem

Posted by mhtan88 on 03-Sep-2007 21:54

hi all,

can anyone help me on this? regarding

CREATE BUFFER h_tablehandle FOR TABLE pc_table. pc_table are only allow to use temp-table and physical tables. but, if i code the statement as below, it give me error "could not create buffer for table test. (7334)".

DEFINE VARIABLE h_tablehandle AS HANDLE NO-UNDO.

DEFINE BUFFER test_table FOR inv_item.

CREATE BUFFER h_tablehandle FOR TABLE "test_table".

may i know how to do it? I need to do like this because i'm using open-query and the statement are having two different item in the (parent_item and child_item) are need to get the different item description by connecting to one inv_item table.

Thank you.

Regards,

Tan

All Replies

Posted by kevin_saunders on 04-Sep-2007 02:54

In the statements:

DEFINE BUFFER test_table FOR inv_item.

CREATE BUFFER h_tablehandle FOR TABLE "test_table".

You are attempting to create a buffer for a buffer, which is why you are getting the error. An easier method would be just to forget about the dynamic buffer and use the buffer test_table in the query, along with inv_item.

Posted by Tim Kuehn on 04-Sep-2007 08:46

This'll work:

CREATE BUFFER h_tablehandle FOR TABLE BUFFER test-table:TABLE.

Posted by mhtan88 on 04-Sep-2007 19:32

thx Kevin Saunders

Posted by mhtan88 on 04-Sep-2007 19:32

thx Tim Kuehn . i manage to do it ^^

Posted by mhtan88 on 04-Sep-2007 20:13

hi ,

i have one more problem here

DEFINE VARIABLE h_tablehandle AS HANDLE NO-UNDO.

DEFINE VARIABLE gc_query AS CHARACTER NO-UNDO.

DEFINE VARIABLE h2 AS HANDLE NO-UNDO.

DEFINE VARIABLE h3 AS HANDLE NO-UNDO.

DEFINE VARIABLE h1 AS HANDLE NO-UNDO.

DEFINE VARIABLE hquery AS HANDLE NO-UNDO.

DEFINE BUFFER test FOR inv_item.

DEFINE VARIABLE hfield AS HANDLE NO-UNDO.

CREATE BUFFER h1 FOR TABLE "bom_BOM".

CREATE BUFFER h2 FOR TABLE "inv_item".

CREATE BUFFER h3 FOR TABLE BUFFER test:TABLE.

gc_query = "for each bom_bom ,

EACH inv_item where bom_bom.bom_parentitem = inv_item.item_item

,EACH test WHERE bom_childitem = test.item_item

".

CREATE QUERY hquery.

hquery:SET-BUFFERS(h1).

hquery:ADD-BUFFER(h2).

hquery:ADD-BUFFER(h3).

hquery:QUERY-PREPARE(gc_query).

hquery:QUERY-OPEN().

REPEAT:

hquery:GET-NEXT().

IF hquery:QUERY-OFF-END THEN LEAVE.

hfield = h2:BUFFER-FIELD("bom_parentitem").

DISPLAY hfield:BUFFER-VALUE().

END.

error come out

"test must be an unabbreviated name of a buffer known in query. (7327)"

is it meaning that, create query function not supported defined buffer 's buffer:table? I need to do this because i'm going to have on program that something like query program that very dynamic. but due to this limitation, i can't manage to finish my program

Posted by Tim Kuehn on 05-Sep-2007 09:21

The new buffer doesn't have the same name as the DEFINE BUFFER you've made, so give it one:

Do this:

CREATE BUFFER h3

FOR TABLE BUFFER test:TABLE

BUFFER-NAME BUFFER test:NAME

.

However, it's also possible to replace

hquery:ADD-BUFFER(h3).

with

hquery:ADD-BUFFER(BUFFER test:HANDLE).

and get where you're going that way as well.

Posted by Håvard Danielsen on 05-Sep-2007 10:35

The create buffer is the dynamic equivalent of define buffer, so there is no point in both defining and creating the "test" buffer.

Just remove your buffer definition and fix the create statement to use the buffer-name option as follows:

/* DEFINE BUFFER test FOR inv_item. not in use */

DEFINE VARIABLE hfield AS HANDLE NO-UNDO.

CREATE BUFFER h1 FOR TABLE "bom_BOM".

CREATE BUFFER h2 FOR TABLE "inv_item".

CREATE BUFFER h3 FOR TABLE "inv_item" buffer-name "test".

As Tim Kuehn points out, you can alternatively add the static buffer directly to the dynamic query and skip the creation of h3 (and possibly h1 and h2 as well):

define buffer Test for inv_item.

hQuery:add-buffer(buffer test:handle).

Posted by mhtan88 on 05-Sep-2007 20:50

cool, you have gave me what i actually going to ask. many many thanks

Posted by mhtan88 on 05-Sep-2007 20:50

many many thanks to you tim ^^

Posted by Tim Kuehn on 06-Sep-2007 12:43

many many thanks to you tim ^^

This thread is closed