Link to home
Start Free TrialLog in
Avatar of vadicherla
vadicherla

asked on

Shell Script

Hi

I have a delete.dat and insert.dat files.  I want to run Shell script to update records in database

when i passwd three argument for deletion with Shell script as


./shellscript.sh delete tom delete.dat

it has to Create a sql file as below

delete from tabl1 where name = 'tom' and id = 1;
delete from tabl1 where name = 'tom' and id = 2;
delete from tabl1 where name = 'tom' and id = 3;
delete from tabl1 where name = 'tom' and id = 4;

delete.dat file will following data
1
2
3
4

when i passwd three argument for insert to same Shell script as

./shellscript.sh insert tom insert.dat

it has to Create a sql file as below

insert into tab1 values(id_sequence.nextval,'tom'1);
insert into tab1 values(id_sequence.nextval,'tom'2);
insert into tab1 values(id_sequence.nextval,'tom'3);
insert into tab1 values(id_sequence.nextval,'tom'3);

insert.dat file will following data
1
2
3
4

SQL file
Avatar of vadicherla
vadicherla

ASKER

Hi

I have a delete.dat and insert.dat files.  I want to run Shell script to update records in database

when i passwd three argument for deletion with Shell script as


./shellscript.sh delete tom delete.dat

it has to Create a sql file as below

delete from tabl1 where name = 'tom' and id = 1;
delete from tabl1 where name = 'tom' and id = 2;
delete from tabl1 where name = 'tom' and id = 3;
delete from tabl1 where name = 'tom' and id = 4;

delete.dat file will following data
1
2
3
4

when i passwd three argument for insert to same Shell script as

./shellscript.sh insert tom insert.dat

it has to Create a sql file as below

insert into tab1 values(id_sequence.nextval,'tom'1);
insert into tab1 values(id_sequence.nextval,'tom'2);
insert into tab1 values(id_sequence.nextval,'tom'3);
insert into tab1 values(id_sequence.nextval,'tom'3);

insert.dat file will following data
1
2
3
4

SQL file is based on arugument we pass(delete or insert)
.(After Creating the sql file it has to connect to database and execute the delete or insert sql script file.
ASKER CERTIFIED SOLUTION
Avatar of woolmilkporc
woolmilkporc
Flag of Germany image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
As I mentioned it also connects to database and execute the SQL script and also spool the all database execution
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial