Sponsored Content
Top Forums Shell Programming and Scripting Scirpt to fetch the variable from sqlplus Post 302950735 by arun888 on Tuesday 28th of July 2015 10:47:53 AM
Old 07-28-2015
Hi Ravi/All,

I have written a oracle procedure where i am not able to send email from oracle due to priviliges issue. any idea how to call it from unix shell side

Output Required :

If job is success/failure need to trigger an email from unix.

Please help me out how to call the below oracle function from unix & send the email from unix

Code:
cursor rec 
IS
SELECT * FROM location_id_queue where location like '%DETAILS.LLL%';
V_value_COUNT       NUMBER;
V_proc_name       VARCHAR2(50);
V_valuexxx          NUMBER;
V_valuexxx2         NUMBER;
V_valuexxx3                           NUMBER;
v_location_id       VARCHAR2(50);
v_sales            NUMBER;
BEGIN 
for i in rec
loop
select substr(i.location,12,4)  INTO v_location_id from dual;
select substr(i.location,17,4) INTO v_sales from dual;                
v_proc_name := 'JOBS';
DBMS_OUTPUT.PUT_LINE ('Program name '||V_proc_name);
DBMS_OUTPUT.PUT_LINE ('outletid is '||v_location_id);
DBMS_OUTPUT.PUT_LINE ('sales is '||v_sales);
DBMS_OUTPUT.PUT_LINE ('Now Getting the count from the table for the outlet '||v_location_id);
SELECT COUNT(*) INTO V_value_COUNT FROM COUNT WHERE location_id = v_location_id AND   sales= v_sales;
                IF V_value_COUNT > 0 THEN
                DELETE FROM COUNT WHERE location_id = v_location_id AND sales= v_sales;
                ELSE
                DBMS_OUTPUT.PUT_LINE ('No Data found from the table TOTAL_Count '||v_location_id);
                END IF;
                IF v_location_id IN ('chen','bang') THEN
                select GET_COUNTS.GET_bang_chen_COUNT(v_location_id,v_sales) INTO V_valuexxx from dual;
  DBMS_OUTPUT.PUT_LINE ('chen/bang functions'|| V_valuexxx);
    ELSIF   v_location_id IN ('sale','tric','padi','madu','PUDU') THEN
   select GET_COUNTS.GET_OTHER_OUTLET_COUNT(v_location_id,v_sales) INTO V_valuexxx from dual;
  DBMS_OUTPUT.PUT_LINE ('sale/tric/padi/madu/PUDU function '|| V_valuexxx);
                ELSIF v_location_id IN ('TIRU') THEN
select GET_COUNTS.GET_TIRU_COUNT(v_location_id,v_sales) INTO V_valuexxx from dual;
DBMS_OUTPUT.PUT_LINE ('TIRU function'|| V_valuexxx);
                END IF; 
                IF V_valuexxx = 0 THEN
  select GET_COUNTS.GET_CRT_COUNT(v_location_id,v_sales) INTO V_valuexxx2 from dual;
select GET_COUNTS.GET_PANEL_COUNT(v_location_id,v_sales) INTO V_valuexxx3 from dual;
   END IF;
                 BEGIN
                IF  V_valuexxx = 0 and  V_valuexxx2 = 0 and  V_valuexxx3 = 0 THEN
DBMS_OUTPUT.PUT_LINE ('Job Sucess'||v_location_id);
ELSE       
DBMS_OUTPUT.PUT_LINE ('Job Failed'|| v_location_id);
END IF; 
                EXCEPTION
            WHEN OTHERS THEN
                                                DBMS_OUTPUT.PUT_LINE ('Program errors while sending email due to:'||SQLERRM);   
                 END;
                  END LOOP;
                EXCEPTION
            WHEN OTHERS THEN
                DBMS_OUTPUT.PUT_LINE ('Program errors due to:'||SQLERRM);
                
END;


Last edited by arun888; 07-28-2015 at 12:48 PM..
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Using a variable in sqlplus

Hello, I'm trying to write a script that will loop a sql statement through an external list. Basically, the script enters a loop and runs the sql statement for each entry in the list file. Currently, the script will stop at a cursor where I can then manually enter the SQL statment. This is... (11 Replies)
Discussion started by: MadHatter
11 Replies

2. Shell Programming and Scripting

Unix code to fetch the first field till space in a variable

Hi, I want to get the value of the first field till space in a variable. e.g x=323 /test/personel/logs/File1 I want to get the first field till space i.e 323 in another variable ,lets say y. echo $x|cut -d' ' -f1 gives 323 but when I'm trying y=`echo $x|cut -d' ' -f1 its giving... (3 Replies)
Discussion started by: autosys_nm
3 Replies

3. Shell Programming and Scripting

How to fetch variable value in if block and to compare it with certain string

Hi, I am trying to execute this command if ; then but getting error .Some problem with reteriving the value of $exception_info. Please help.Its urgent. thanks (4 Replies)
Discussion started by: khushboo
4 Replies

4. Shell Programming and Scripting

Passing the unix variable to sqlplus

Hi, I am writing a script which creates an external table using a shell script. My requirement is like this. Usage: . ./r.ksh <table_name> - this should create an external table. e.g . ./r.ksh abc - this should create an external table as abc_external. How do i achieve this? Please... (5 Replies)
Discussion started by: Anaramkris
5 Replies

5. UNIX for Dummies Questions & Answers

fetch Variable value

Hi Guys, I have written a script that declares all the variables and its values in a conf file. Now i use a variable whose value i need to change it in one of the sub-file that is used in the script. In the startup file i want to print or check its value. The value get changed and printed... (5 Replies)
Discussion started by: Swapna173
5 Replies

6. Shell Programming and Scripting

Fetch the different data by searching with a same variable from a file in AIX server

Hi, I am trying to fetch the different values in an xml file by searching with the same variable in AIX Server. <name>SharedResources/Shared/JNDI/Username</name> <value>admin</value> <name>SharedResources/Shared/JNDI/Username</name> ... (1 Reply)
Discussion started by: tejastrikez
1 Replies

7. Shell Programming and Scripting

awk with variable from sqlplus

Hi, I'm a it stuck on the below code where a variable is pulled from sqlplus and used in awk. It runs with no errors but still pulls back all records in the input file. It should pull the max reference from sql plus and then only print those records where the reference value in column 1 is... (4 Replies)
Discussion started by: jonathanb30
4 Replies

8. UNIX for Advanced & Expert Users

[Solved] Unable to fetch the UNIX variable information

I am having a file called variable_info.ksh in that file I am having following global variable information like… EMAIL_PATH=/var/mail TMP_PATH=/home/tmp And we are having another temporary parameter file abcd.txt, in that file we are having the following information like… EMAIL|EMAI_PATH I... (4 Replies)
Discussion started by: mesahammad
4 Replies

9. Shell Programming and Scripting

Fetch field to variable

Input.txt NOTE1|VALUE1|HMM|UPSTR| NOTE2||HMP|UPSTR| NOTE3|VALUE3|HML|UPSTR| NOTE4||HMD|UPSTR| NOTE5|VALUE5|HMS|UPSTR| NOTE6|VALUE6|HSD|UPSTR| NOTE7||HSS|UPSTR| NOTE8|VALUE8|HEE|UPSTR| NOTE9|VALUE9|HER|DOWNSTR| NOTE50|VALUE1|HEE|DOWNSTR| I am trying to read field 1, 2 and 3 from the... (4 Replies)
Discussion started by: Joselouis
4 Replies

10. UNIX for Beginners Questions & Answers

Sqlplus variable UNIX

hi guys i have a sqlplus : sqlplus -s username/password << EOF @mysql.sql EOF in mysql.sql there is a count of a table, i want to write in a variabile unix. how can i do? Thanks a lot Regards Francesco. (3 Replies)
Discussion started by: Francesco_IT
3 Replies
END(7)							  PostgreSQL 9.2.7 Documentation						    END(7)

NAME
END - commit the current transaction SYNOPSIS
END [ WORK | TRANSACTION ] DESCRIPTION
END commits the current transaction. All changes made by the transaction become visible to others and are guaranteed to be durable if a crash occurs. This command is a PostgreSQL extension that is equivalent to COMMIT(7). PARAMETERS
WORK, TRANSACTION Optional key words. They have no effect. NOTES
Use ROLLBACK(7) to abort a transaction. Issuing END when not inside a transaction does no harm, but it will provoke a warning message. EXAMPLES
To commit the current transaction and make all changes permanent: END; COMPATIBILITY
END is a PostgreSQL extension that provides functionality equivalent to COMMIT(7), which is specified in the SQL standard. SEE ALSO
BEGIN(7), COMMIT(7), ROLLBACK(7) PostgreSQL 9.2.7 2014-02-17 END(7)
All times are GMT -4. The time now is 02:08 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy