PL/SQL tag suggests you use Oracle, while question says
How to run this as a single script automatically?
From my point of view, you'll have to put some effort in it as I'm not sure you can do it as is without any programming.
You didn't post Excel file contents so I'll presume that it looks like
VOLTAGE SPID
------- ----
11000 25
11000 32
22000 120
13200 24
etc.
One option is to create UPDATE
statements directly in Excel by writing a formula which contains fixed text (update your_table set voltage =
, where
clause) concatenated with cells' values that represent voltage
value and spid
. You can then save such a file as a .sql
file and run it. Alternatively, as you're mentioning nohup
, create a procedure which is basically just the same as that .sql
file - you 'd just enclose bunch of update
statements into begin-end
block. Then schedule that stored procedure to run whenever you want (could be right now, if you want) using dbms_scheduler
package.
Another option is to load Excel file contents into database. How? Save it as a CSV file and load it using SQL*Loader; or, create simple Apex application whose Wizard will help you in that task; or, use CSV file as external table. Once you have data in the database table, create a stored procedure which will loop through table's contents, dynamically create update
statement and execute immediate
it. As in previous option, you'd schedule that procedure.
Why "stored procedure" and "scheduling"? Because of nohup. Stored procedure runs in the database (i.e. on a database server, which is what you want), while database job lets you run it even though you aren't connected to the database (personally).