Mike Yearwood
Toronto, Ontario, Canada
General information
Category:
Coding, syntax & commands
Hi all
There is a SQLParser class in the downloads, but that only works for Selects. What I am wanting to do is parse an insert command and get the PK column names (already have that) and then extract the values of the pk columns from the insert so that I can execute a test to see if the primary key will be violated by the insert.
The system I inherited is doing sqlexec without any checking. I am trying to encapsulate a set of abilities into a new ??sqlexec, such as checking if the connection is valid, wait for it if it's busy, etc. There may be a primary key or other constraint on the table so that this could fail:
insert into table (field1, field2, field3) values ("a",1,{^2021/03/30})
Assuming field1 is the primary key I want to generate a sql command
select field1 from table where field1 = "a"
I can then execute that before the insert. Or I could combine the 2 commands into a single SQL:
insert into table (field1, field2, field3) values ("a",1,{^2021/03/30}) where not exists (select field1 from table where field1 = "a")
There may already be a where clause, so if I had a collection of pieces it would be easy to decide where to add a new one.
Thanks
Next
Reply
View the map of this thread
View the map of this thread starting from this message only
View all messages of this thread
View all messages of this thread starting from this message only