My actual issue is to fetch and pass a dynamic value in query.(Please excuse for the lengthy post)
For my requirement, I need to run 3 queries to approve a request in backend -
- INSERT INTO a tableA – insert the intitation data/record to the tableA
- SELECT FROM the tableA – select the latest inserted record from the tableA and fetch the value of Field1 (the value of Field1 changes with every run of 1st query)
- INSERT INTO tableB– pass the value of Field1 fetched from previous select query and use it to insert approval data
The issue here lies between the 2nd and 3rd query. I have explained in detail the steps I have followed so far -
Inside an Excel loop -
ii)execute DBquery (2nd query - SELECT FROM tableA)
iii)get data (fetch value of Field1)
at this stage, I have split the 3rd query in two parts like below -
part1 = INSERT INTO tableB VALUES ("
part2 = ",‘xxxx’, ‘xxxx’, ‘xxxx’)
iv) Assign 3rd query = part1 + “Field1” + part2
v) Write 3rd query to excel
Till here everything is going as expected. Now I have to convert the contents of this excel i.e., 3rd query to .sql and execute it. But the ‘convert’ option in file operations doesn’t support .sql file type, hence i’m not able to proceed further.
Is there a way I can convert this to .sql? or is there an alternative to this entire process of passing dynamic values altogether? Please advice.