How To Output Dynamic Temp Tables

Posted by Krishna Kumar on 22-Jul-2016 07:59

Hi,

I just created a dynamic temp table for testing purpose and tried to output the same in JSON FORMAT. However  I'm getting the temp table  as blank. Can anybody provide me some inputs on the same?  

PROCEDURE

procedure dynamictemp :
DEFINE OUTPUT PARAMETER  TABLE-HANDLE   hTable .

CREATE TEMP-TABLE hTable.
hTable:ADD-NEW-FIELD("kk","logical").
hTable:TEMP-TABLE-PREPARE("ttkfacilities").
hTable:BUFFER-CREATE().
hTable:BUFFER-FIELD ("kk"):BUFFER-VALUE = TRUE.

end. 

TEMP TABLE coming blank in JSON Format

},

   "Table": {

     "ttkfacilities": []

   }

 

Thanks,

KRISHNA KUMAR

All Replies

Posted by Brian K. Maher on 22-Jul-2016 08:02

hTable:BUFFER-RELEASE().
 
When using dynamic database objects it is encumbent on YOU to handle to flushing of records.

Posted by Krishna Kumar on 22-Jul-2016 08:07

I tried adding the same. However it doesn't work. Still it's showing blank

Posted by Brian K. Maher on 22-Jul-2016 08:09

Consider posting your full code.

Posted by Krishna Kumar on 22-Jul-2016 08:12

Below is the same -

procedure dynamictemp :

DEFINE OUTPUT PARAMETER  TABLE-HANDLE   hTable .

CREATE TEMP-TABLE hTable.

hTable:ADD-NEW-FIELD("kk","logical").

hTable:TEMP-TABLE-PREPARE("ttkfacilities").

hTable:BUFFER-CREATE().

hTable:BUFFER-FIELD ("kk"):BUFFER-VALUE = TRUE.

hTable:BUFFER-RELEASE().#sthash.0PBCTlsQ.dpuf

end procedure.  

Posted by Brian K. Maher on 22-Jul-2016 08:15

That is not the completel code.  Where is the WRITE-JSON call?

When you have code that does not work as expected it is very important that you paste the complete code if you want answers that solve the problem.  The folks here are good but I don't think any of them are psychic. <smile>

Posted by Brian K. Maher on 22-Jul-2016 08:19

By the way, does the following statement throw an error?

hTable:BUFFER-CREATE().

???

Posted by Brian K. Maher on 22-Jul-2016 08:23

... or does the RUN statement which calls this internal procedure have a NO-ERROR on it?  If so, remove it for debugging purposes.

Posted by Brian K. Maher on 22-Jul-2016 08:31

Here is a variation of your code that works.  I expect your real issue is that the RUN statement has a NO-ERROR phrase on it there by suppressing the 4052 error you are getting.

define variable hTable as handle.
define variable hBuffer as handle.

CREATE TEMP-TABLE hTable.

hTable:ADD-NEW-FIELD("kk","logical").

hTable:TEMP-TABLE-PREPARE("ttkfacilities").

hBuffer = hTable:default-buffer-handle.

hBuffer:BUFFER-CREATE().

hBuffer:BUFFER-FIELD ("kk"):BUFFER-VALUE = TRUE.

hBuffer:BUFFER-RELEASE().

def var x as longchar.

hTable:write-json("longchar",x).

message string(x) view-as alert-box.

This thread is closed