question

Stan Davis avatar image
1 Like"
Stan Davis asked Jason Lightfoot commented

SQL INSERT INTO Global Table Errors

I'm developing a procedure to populate a global table using the 'INSERT INTO' statement. For testing I have a simple global table with all data assigned as numbers...

1662497628819.png


When I run the following statement in the script console..

Table.query("INSERT INTO RackVolumeTable2 (Rack, Bay, Level, Slot, Volume) VALUES ($1, $2, $3, $4, $5)",  1, 2, 3, 4, 5.11);

I get the following error..

1662497134543.png

When I run the statement in debug mode, I get this error..

1662497224820.png


I've tried just inserting a single value but get same errors. I believe the statement is constructed correctly as any variation will result in parsing errors.

Per documentation, the "INSERT INTO" is supported. What is the issue?? Thanks - Stan

FlexSim 22.2.1
sqlsql queries
1662497134543.png (6.0 KiB)
1662497224820.png (13.6 KiB)
1662497628819.png (9.9 KiB)
5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.

1 Answer

Jason Lightfoot avatar image
0 Likes"
Jason Lightfoot answered Jason Lightfoot commented

Concatenate the values into the SQL string rather than using parameters.

· 2
5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.

Stan Davis avatar image Stan Davis commented ·

Thanks Jason. That worked...

Table.query("INSERT INTO RackVolumeTable2 (Rack, Bay, Level, Slot, Volume) VALUES ( " + 1 + ", " + 2 + ", " + 3 + ", " + 4 + ", " + 5.11 + ")");


1 Like 1 ·
Jason Lightfoot avatar image Jason Lightfoot ♦♦ Stan Davis commented ·
Great! And if you need to insert strings just put apostrophes around the string.
0 Likes 0 ·