Hi all.
I have a program that is called from an appserver routine. It fetches data from multiple tables (specified by user) and returned data as xml to a .net program. I have recently received an error that number of active temp-tables have reached a limit 32762. Am i not deleting objects correct.
For each of my tables i have a own procedure that creates a dynamic temp-table (like), fills the temp-table and then returns the buffer. This buffer is then added to the dataset and on the end, the dataset is written as xml as output (longchar).
I have attached a example of what i do. Am i doing something wrong here ?? Is it enough to delete the dataset ?
I have a program that is called from an appserver routine. It fetches data from multiple tables (specified by user) and returned data as xml to a .net program. I have recently received an error that number of active temp-tables have reached a limit 32762. Am i not deleting objects correct.
For each of my tables i have a own procedure that creates a dynamic temp-table (like), fills the temp-table and then returns the buffer. This buffer is then added to the dataset and on the end, the dataset is written as xml as output (longchar).
I have attached a example of what i do. Am i doing something wrong here ?? Is it enough to delete the dataset ?
Code:
function GetExternalTable returns handle(input iph as handle):
/* Create temp-table */
def var hTable as handle no-undo.
create temp-table hTable.
/* Add all fields one by one since i have to check extents, datatypes etc etc . */
def var i as int no-undo.
def var j as int no-undo.
def var f as char no-undo.
do i = 1 to iph:NUM-FIELDS:
hTable:ADD-NEW-FIELD(iph:buffer-field(i):name,
(if iph:buffer-field(i):DATA-TYPE = "Date" then "DateTime" else iph:buffer-field(i):DATA-TYPE), /* date->datetime */
0,'',iph:buffer-field(i):DEFAULT-VALUE,iph:buffer-field(i):LABEL,iph:buffer-field(i):COLUMN-LABEL).
end.
hTable:TEMP-TABLE-PREPARE(iph:name).
return hTable:Default-buffer-handle.
end function.
def var hDataSet as handle no-undo.
def var hBuffer as handle no-undo.
//Create a dataset
create dataset hDataSet.
//Create one dynamic table
assign hBuffer = GetExternalTable(input buffer ActivityComment:handle). //Table called ActivityComment
/* Fill temp-table */
for each ActivityComment no-lock
where ActivityComment.ActivityNumber = 123456:
hBuffer:BUFFER-CREATE().
hBuffer:buffer-copy(buffer ActivityComment:HANDLE,?,?).
end.
//Add to dataset:
if valid-handle(hBuffer) then
hDataSet:Add-buffer(hBuffer).
//Create second dynamic table
assign hBuffer = GetExternalTable(input buffer Customer:handle). //Table called customer
/* Fill temp-table */
for each customer no-lock
where customer.c-custno1 = 987654:
hBuffer:BUFFER-CREATE().
hBuffer:buffer-copy(buffer customer:HANDLE,?,?).
end.
//Add to dataset:
if valid-handle(hBuffer) then
hDataSet:Add-buffer(hBuffer).
//Dataset now contains 2 buffers. Output this to my .NET program using appserver
def var cResultXml as longchar no-undo.
hDataSet:write-xml("Longchar",cResultXml,true,"ISO8859-1",?,true,true).
//Clean up ?? This is my problem. Is this good enough ???
delete object hDataSet.