Need help in updating the tables inside shell script
I have an input file with contents like :
I need to read each field from the file
pass it to a query:
select count(*) from usage_error where usage_id='$field value';
fetch that count value
and need to update two values in another table with that count value, one increment and one decerement(while decerementing I need to ensure that the field value shoulb not be less than 0)
update intrl_err set int_err_val ='$count' ,int_drp= int_drp-$count
where usage_id='$field value';
What did you try till now? The rephrased version of the same question you had posted yesterday Need to store query output variables and there was no response to it after that.
What did you try till now? The rephrased version of the same question you had posted yesterday Need to store query output variables and there was no response to it after that.
I have tried this one and sorry for not replyin to that..I have another requirement...so this post
Iam frst fetching the values storing them in a file after that I need to update them in another table
I need to add another query lyk :
select count(*) from usg_error where usage_id='$a';
I need to check if this count value is equal to $c value.
If it is equal,no need to update.
If it is not
I need to update usage_id table intrl_err ($c) qty to the count value and has to deceremt the same amount i.e., count from intrl_drp ($b) making sure that its value will not be less than 0 after decrementing it
You should not come out of the sqlplus with those 3 values. You just continue to write the update instructions inside the SQLQuery_$TimeStamp.sql. I do not see much to be done in the shell for this requirement. Its little bit of PL/SQL coding containing some if statements and update instructions in addition to the existing in the SQLQuery_$TimeStamp.sql itself.
You should not come out of the sqlplus with those 3 values. You just continue to write the update instructions inside the SQLQuery_$TimeStamp.sql. I do not see much to be done in the shell for this requirement. Its little bit of PL/SQL coding containing some if statements and update instructions in addition to the existing in the SQLQuery_$TimeStamp.sql itself.
Guru.
It can be done but the .sql file should not contain statemnts other than select queries.This file will be used for another process also.So I cannot append update statements ,pl'sql code to that.
So I'm thinking of wiriting it in nawk loop if it can be done.can you help me in implementing it here .we can use another sql file for update statements and execute it.
Just open a same sql session like you had one for the select statement and so something like this:
This is a kind of something which you would like to have. I hope you can develop it from here. Keep in mind, the variables you passed to sql script, will be contained in the form of bind variables &1, &2...
This User Gave Thanks to guruprasadpr For This Post:
Just open a same sql session like you had one for the select statement and so something like this:
This is a kind of something which you would like to have. I hope you can develop it from here. Keep in mind, the variables you passed to sql script, will be contained in the form of bind variables &1, &2...
I have tried in this way but getting some unexpected results can you please check if the script is fine
It didnt throw any error msgs and also no .sql files created in the directories
What I have:
I have a input.sh (script which basically connect to mysql-db and query's multiple tables to write back the output to output1.out file in a directory)
note: I need to pass an integer (unique_id = anything b/w 1- 1000) next to the script everytime I run the script which generates... (3 Replies)
Heyy,
any help would be grateful....
LOOKING FOR THE WAYS TO SEND AN EMAIL WITH ATTACHMENT & HTML TABLES IN BODY THROUGH SHELL SCRIPT (LINUX)..NOT SURE, IF WE HAVE ANY INBUILT HTML TAG OR UNIX COMMAND TO SEND THE ATTACHMENTS. KINDLY HELP
below is small script posted for our understanding..... (2 Replies)
Hi guys.
I am new to this forum so cheers :)
I have a question.
I have created a shell script that puts all the output into 1 file.
The out put is like this:
-----IP------
Data
Data
Data
-----IP------
Data
Data
Data
How can i arrange this to be like this:
IP | Data |... (3 Replies)
Hi All,
In my script I have used the below code to retrieve the instance name
V_INSTANCE_NAME=`sqlplus -s ${APPS_USR_PSWD} <<+
set pagesize 0 linesize 256 feedback off verify off head off echo off
set serveroutput off
select... (2 Replies)
Hi,
I have two databases with same tables on different servers.I need to check the data content in each table and if something is missing, should print that.
I have a tool which takes the snapshot the table structure,index so on and compares with the other server tables snapshot.
Now i need... (1 Reply)
I am coding shell script.
I need to connect to different databases like DB2, Oracle and Sybase.
I would then need to query tables where it has all the groups, users for that database.
I would also need who has what kind of permissions.
EG: I know for DB2 some TABAUTH table needs to be... (0 Replies)
Hi,
I want to compare two tables fieldwise using shell script. Can anyone help me regarding the same.
The approach which i tried is to first move the two tables in simple txt file where each field is now seperated by space. But i can't retrive each field with "space" as a seperator b'coz there... (1 Reply)
hi gurus,
I am having a file containing a list of tables.i want to find the count of records inside thes tables.
for this i have to connect into database and i have to put the count for all the tables inside another file i used the following loop once all the tablenames are inside the file.
... (1 Reply)
Hi friends,
i am having a variable declared in .profile.i am changing its value in a shell script and then i am connecting to oracle and then from there i am calling a .sql called update.sql
STATUS is the variable declared in the .profile
===============================
if
sqlplus <<END... (3 Replies)