Page 1 of 1

Something amiss with my use of INSERT INTO??

Posted: Fri May 25, 2018 3:00 am
by marksmithhfx
The following example works...

Code: Select all

      put "INSERT INTO Baby (EventID) values(:1)" into tCmd
      revExecuteSQL gconnectID, tCmd, "tEventID" -- creates a new empty record with mothers EventID
So far so good. But, the next example does not...

Code: Select all

      put "INSERT INTO Baby (EventID, Baby) values(:1,:2)" into tCmd
      revExecuteSQL gconnectID, tCmd, "tEventID, tBaby" -- creates a new empty record with mothers EventID and Baby-A,B,C,etc
Should it?

PS I am aware that placeholders (:1, :2) cannot refer to column names, and in this case they don't. These are just variables with single values assigned to them.

Thanks!!

Re: Something amiss with my use of INSERT INTO??

Posted: Fri May 25, 2018 9:56 am
by Klaus
Hi Mark,

I think you need to put all values into quotes separately. Try this:

Code: Select all

...
put "INSERT INTO Baby (EventID, Baby) values(:1,:2)" into tCmd
## revExecuteSQL gconnectID, tCmd, "tEventID, tBaby" 
revExecuteSQL gconnectID, tCmd, "tEventID", "tBaby" 
...
Otherwise LC will treat this as ONE value, as you have experienced.


Best

Klaus

Re: Something amiss with my use of INSERT INTO??

Posted: Sat May 26, 2018 3:47 am
by marksmithhfx
Klaus, thanks so much. As the following demonstrates, we have success :)
Screen Shot 2018-05-25 at 9.09.44 PM.png

Re: Something amiss with my use of INSERT INTO??

Posted: Sat May 26, 2018 7:18 am
by SparkOut
Or use an array where key 1 has the value for :1 and key 2 has the value for :2 etc

Re: Something amiss with my use of INSERT INTO??

Posted: Sat May 26, 2018 7:57 pm
by marksmithhfx
Thanks Sparkout. Was aware of that option, and I use it a lot, but was puzzled over my two variable solution not working. Wasn't sure if that was a bug or... ?? It turned out to be my #1 bugaboo: SYNTAX. Anyone else hate syntax as much as I do :)

You would think by now computers were smart enough to figure out what you wanted... or you could just have a chat with them. Hey Mark?? LC 12.0 perchance :)