Home > Net >  Parse Sql: analyze the select statement from the update statement
Parse Sql: analyze the select statement from the update statement

Time:09-23

There is now a task, there is a batch of orders, update, insert, delete the batch operation,
There is also a requirement, when performing operations need to record the history of updating data,

For example:
 update tab1 set col='*', col2='* * *' where id in (select tid from tab2 the where the enable='Y 
')

my process is like this:
1. first resolved to get:
 select * from tab1 where id in (select tid from tab2 the where the enable='Y') 


2. execute the select to save historical data to other places,

3. to perform the update command

The problem is,
how do I parse out the select statement?
Statement is not too complex, are all clauses statements,
So close, can provide a good way?

CodePudding user response:

Is not resolve the where clause?
In the example but you have the insert, insert instruction is no where clause, when are you going to do with?

CodePudding user response:

reference 1st floor xuzuning response:
is not resolve the where clause?
In the example but you have the insert, insert instruction is no where clause, when are you going to do with?


Insert don't need to parse,
And I want to make the update, delete types of SQL parsing out look at the update,


And analyze the where clause from the update, also is not so easy, or want to consider the diversity of the statement

CodePudding user response:

Brother you implement this feature

CodePudding user response:

refer to the original poster yuna @ liu reply:
there is now a task, there are a batch of orders, update, insert, delete the batch operation,
There is a requirement, when performing operations need to record the history of updating data,

This requirement, if the update is, in fact, adding a new data, view of time is to see the latest one, history is a previous article, isn't this supposed to be a bit better?

CodePudding user response:

Roll, only to find that is grave post several years ago,

CodePudding user response:

Write transactions, update delete, new backup to the backup table first
  •  Tags:  
  • C #
  • Related