Using Windows Batch Scripting, I'm working to pull certain strings from an error log so I can build a SQL Statement.
So far, I've gotten what I need into a file on one continuous line. It should be that way each time I pull in an error. I'm interested in pulling out only the UPDATE statements and certain elements related to each one.
The line may contain one or several INSERT, UPDATE or DELETE statements peppered throughout so it's very tough to decide what to search for.
As I pull in the strings I want for each UPDATE statement, I'll build the SQL and call a stored procedure to do what I need to do. Then return to the Batch Script to get the next UPDATE statement (if there is one).
I've already managed to get a Count of the number of UPDATE statements so I can use that for a loop.
The line below is an example of what I've managed to place in a file (all one continuous line).
} SQL Exception (state )(using SQL: "[UPDATE owner.tableName SET i_unwanted_column1=yyyy,i_unwanted_column2=yyy,i_unwanted_column3=yyyyy,d_unwanted_column4=to_timestamp('1900-01-01 00:00:00','yyyy-mm-dd hh24:mi:ss.ff3') WHERE i_pkey_column = yyyyy , UPDATE owner.tableName SET i_unwanted_column1=xxxx,i_unwanted_column2=xxxx,i_unwanted_column3=xxxxx,d_unwanted_column4=to_timestamp('2018-10-29 00:00:00','yyyy-mm-dd hh24:mi:ss.ff3') WHERE i_pkey_column = xxxxxx ]"):
I need to extract the "owner", "tableName" (found after the UPDATE), the primary key column name and it's value (located after the WHERE) for each UPDATE statement.
I've been looking at many websites but none have helped me put together something that I can get to work.
I'm a novice at Windows Batch scripting and only now exploring Powershell. In fact, it's with powershell that I've been able to extract the line I need from the error log into a file all on one line and count the number of UPDATE statements. :)