![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Rules & FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here. |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Regarding Shell Scripting | anilkarikkandar | UNIX for Dummies Questions & Answers | 3 | 11-19-2006 08:26 PM |
| HELP PLS!! Shell Scripting!! | Mary_xxx | Shell Programming and Scripting | 9 | 09-16-2006 03:52 AM |
| difference between AIX shell scripting and Unix shell scripting. | haroonec | Shell Programming and Scripting | 2 | 04-12-2006 05:12 AM |
| something else on shell scripting | master_6ez | Shell Programming and Scripting | 1 | 11-21-2004 07:42 PM |
|
|
LinkBack | Thread Tools | Display Modes |
|
|||
|
Help on SED AWK in shell scripting
Hi,
I have a script abc.sql which contains a word 'timestamp'. I have another script xyz.txt genrated everyweek, which has a new timestamp value every week. How do I replace the word 'timestamp' in script abc.sql with the value mentioned in the script xyz.txt, so that I can run the script abc.sql with the a new timestamp value every week. |
| Forum Sponsor | ||
|
|
|
|||
|
The thing is that the value changes every week. So if I write a script with that sed command I ineed to include a variable in the command and to do that I need to include the " character. If I do that then I cannot execute the command so right now in a diff script I echo the sed command with the variable and pass it to a new script which actually runs the sed command. This is the only way I can do it now. I wanted an easier way.
and more over the abc.sql script cannot have any variables because I dont execute that as s shell script. |
|
|||
|
Database engines typically have command processors like Oracle's sqlplus.
sqlplus allows for arguments to be passed so that copies of SQL scripts don't have to be created every time a value changes. Code:
sqlplus un/pw @abc.sql 20060309 Code:
INSERT INTO sometable (columna, columnb, datecolumn)
VALUES (value1, value2, TO_DATE('&1', 'YYYYMMDD'));
COMMIT;
If you have an SQL script and if you are creating a copy of it with a new value as you indicate then it follows that you are attempting to execute the SQL through some utility. The utility that executes the SQL should allow you to pass parameters. Oracle sqlplus, Sybase's/Microsoft's isql, et. al. all allow for this capability. I don't use MySQL or DB2 but I would be surprised if they don't allow for parameters. Last edited by tmarikle; 03-09-2006 at 10:46 AM. |
|||
| Google UNIX.COM |