Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
SQL Parsing
Message
De
30/03/2021 18:04:20
Mike Yearwood
Toronto, Ontario, Canada
 
 
À
Tous
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Titre:
SQL Parsing
Divers
Thread ID:
01679373
Message ID:
01679373
Vues:
87
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
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform