Re: Is Table Number Valid Cannot Validate New Temporary Table

2017-10-11 Thread Mark Scardigno via 4D_Tech
Miyako,

One of the problems is that 'Get Last Table Number’ doesn’t acknowledge the new 
temporary table at all, but the Util_GetTableNum function does.

For example, after I create the temporary table, Util_GetTableNum returns table 
number 51. But then when 'Is Table Number Valid’ fails in my code, I log using 
the following method and 'Last Table Number' gives me 48.

See output below (I trimmed it for obvious reasons). It reports the temporary 
table as a missing table (And I’m not sure why I have 5 missing since I’m using 
CREATE TABLE IF NOT EXISTS each time).

Also, this only happens when compiled, client/server.

ARRAY TEXT(asTables;Get last table number)
If (Get last table number>0)
For ($vlTables;Size of array(asTables);1;-1)
If (Is table number valid($vlTables))
SEND PACKET(MyLogDoc;Char(13)+String($vlTables;"00 ")+Table name($vlTables))
Else 
SEND PACKET(MyLogDoc;Char(13)+String($vlTables)+" *Deleted*")
End if 
End for 
End if 

ARRAY TEXT($arrMissingTables;0)
GET MISSING TABLE NAMES($arrMissingTables)
$SizeArray:=Size of array($arrMissingTables)
If ($SizeArray#0)
For ($i;1;$SizeArray)
If (Find in array(asTables;$arrMissingTables{$i})=-1)
SEND PACKET(MyLogDoc;Char(13)+$arrMissingTables{$i}+" *Missing*")
End if 
End for 
End if 

//**Output*//
48 Table48
…
…
02 Table2
01 Table1
TempTable_4dt *Missing*
TempTable_4dt *Missing*
TempTable_4dt *Missing*
TempTable_4dt *Missing*
TempTable_4dt *Missing*

Regards,
Mark

> On Oct 10, 2017, at 12:12 PM, Keisuke Miyako via 4D_Tech 
> <4d_tech@lists.4d.com > wrote:
> 
> why not simply use Get last table number?
> 
> and you don't really need to use SQL to get a table pointer from name, just 
> do something like...
> 
> C_POINTER($p)
> $name:="Table_1"
> $formula:=""
> PROCESS 4D TAGS($formula;$formula;->$p)

**
4D Internet Users Group (4D iNUG)
FAQ:  http://lists.4d.com/faqnug.html
Archive:  http://lists.4d.com/archives.html
Options: http://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
**

Is Table Number Valid Cannot Validate New Temporary Table

2017-10-10 Thread Mark Scardigno via 4D_Tech
Hello,

I’m trying to use a temporary table in 4D but after creating the table 
successfully, "Is Table Number Valid" always returns, “Indice out of range” 
when I try to use the new table number. If the client logs out and then back in 
again, the table number is valid. Please see code below. Is there a workaround 
for this? 4D v15 R4

Regards,
Mark

$tmp_table_name:="TempTable_4dt"
$fields:="Code Int32, Title VARCHAR(80), Name VARCHAR(80)"

 // Create the temporary table
vSQL:="CREATE TABLE IF NOT EXISTS "+$tmp_table_name+" ("+$fields+")"

Begin SQL
EXECUTE IMMEDIATE :vSQL;
End SQL


If (OK=1)
FLUSH BUFFERS
 // Get the new temp table's number and a pointer to it for later
$tmp_table_num:=Util_GetTableNum ($tmp_table_name)

 // Check if we got a good table number.
If (Is table number valid($tmp_table_num))

 // * ERROR 

 // Indice out of range error when trying to get the table number. The table 
gets created but
 // the client can't see it. If the client logs out and back in again, then the 
table will be valid.

End if 
End if 

 // 
 // Util_GetTableNum

If (Count parameters=1)
C_LONGINT($0;vNum_I)
C_TEXT($1;$table_name)

vNum_I:=0

$table_name:=$1

Begin SQL
SELECT TABLE_ID 
FROM _USER_TABLES 
WHERE TABLE_NAME = :$table_name 
INTO :vNum_I
End SQL

$0:=vNum_I
End if 


**
4D Internet Users Group (4D iNUG)
FAQ:  http://lists.4d.com/faqnug.html
Archive:  http://lists.4d.com/archives.html
Options: http://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
**