I have an Excel spreadsheeet with a cell containing a concatenated name and surname (don’t ask why). For example, Cell A2: BLOGGSJOE.
On this cell, I would like to run the following SQL and output it to cell A3, A4 and A5:
SELECT i.id, i.forename, i.surname FROM individual i WHERE UPPER(REPLACE('" & A2 & "', ' ', '')) = UPPER(REPLACE(i.surname|| i.forename, ' ', '')) AND NVL(i.ind_efface, 'N') = 'N'
Any idea how I could perform an Oracle query on each cell and return the result?
I have enabled an Oracle datasource connection in Excel, just not sure what to do now.
Is this a stupid approach, and can you recommend a better more proficient way?
I am aware that I could just write a simple Ruby/PHP/Python/whatever script to loop through the Excel spreadsheet (or .csv file) and then perform the query etc. but I thought there might be a quick way in Excel itself.
if you format your spreadsheet properly you could assign rs to a Variant and then assign the variant to a range instead of looping through it.
Edit
With your current SQL you would need to loop through each cell and query the db, then save the results to A3:A5. Edit 2, Something like that:
Note that I have used different cells that you wanted and the GetRow is 2D not 1D, but is hard for me to write it up with no access to actual spreadsheet/db