The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Execute oracle query determined at runtime from a unix script infyanurag Shell Programming and Scripting 4 02-01-2008 07:54 AM
Script executing sql query kingluke Shell Programming and Scripting 2 01-23-2008 01:57 PM
executing a SQL query in shell script lijju.mathew Shell Programming and Scripting 1 05-17-2007 11:29 AM
Executing Sql Query Using Shell Script ragha81 Shell Programming and Scripting 14 07-31-2006 02:15 PM
Executing a SQL query from a shell script 98_1LE UNIX for Dummies Questions & Answers 3 03-23-2002 03:29 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 03-21-2008
ravi gongati ravi gongati is offline
Registered User
  
 

Join Date: Mar 2008
Posts: 15
Question Need Unix script for executing oracle query

Hi All,
This is Ravi. I am new in Unix platform. I need unix script for executing oracle query.
Requirement:-
1. We had 2 tables 1 is source table 2 is target table.

Example:- Ravi1(Source Table) 100000 records
Ravi2(Target Table) 50000 records
Fallouts 50000
I was successfully got this result in in sqlplus.

But now i want to run this script in unix mechine. While executing this script in unix the fallouts should automatically it will store in fallouts table(Major issue for me).

So i don't know how to execute this query so i would appreciate if any one send that unix AWK script to me.
  #2 (permalink)  
Old 03-21-2008
thana thana is offline
Registered User
  
 

Join Date: Jan 2008
Posts: 55
Code:

#!/bin/bash
sqlplus -s /nolog << EOF

CONNECT $DB_USER/$DB_PASSWORD

Your sql query here
................
.............

end;
/
EOF
  #3 (permalink)  
Old 03-21-2008
ravi gongati ravi gongati is offline
Registered User
  
 

Join Date: Mar 2008
Posts: 15
Question Thanks thana

I will explain my total requirement:-
We are developed script in PL/SQL. In the PL/SQL script i was got the fallout report(no. of rows records not extracted well).

Now client he was asking us like we want to execute the script in unix mechine. He was asking like while executing the PL/SQL script in unix the fallouts should be automatically store in Fallout table.Is it possible.

give me your mail id i will send my PL/SQL that will easy for both to understand.



Quote:
Originally Posted by thana View Post
Code:

#!/bin/bash
sqlplus -s /nolog << EOF

CONNECT $DB_USER/$DB_PASSWORD

Your sql query here
................
.............

end;
/
EOF
  #4 (permalink)  
Old 03-21-2008
ravi gongati ravi gongati is offline
Registered User
  
 

Join Date: Mar 2008
Posts: 15
Exclamation Need Unix script for executing oracle query

DECLARE CURSOR np IS
SELECT * FROM np_classes;

total_rows_np NUMBER;

CURSOR idb IS
SELECT * FROM dl_class;

total_rows_idb NUMBER;

expFallouts NUMBER;

BEGIN
FOR x IN np LOOP
total_rows_np := np% ROWCOUNT ;
END LOOP;

FOR y IN idb LOOP
total_rows_idb := idb% ROWCOUNT;
END LOOP;

IF total_rows_np > 0 AND total_rows_idb >0 THEN

expFallouts := total_rows_np - total_rows_idb;
dbms_Output.new_line;
dbms_output.put_line('DL_ CLASS');
dbms_Output.new_line;
dbms_output.put_line('total rows np :' ||To_Char(total_rows_np ));
dbms_output.put_line('total rows idb :' ||To_Char(total_rows_idb));
dbms_output.put_line('Expected Fallouts :' ||To_Char(expFallouts));
Dbms_Output.new_line;
ELSE
Dbms_Output.new_line;
dbms_output.put_line('DB Empty');
END IF;
END;


This is a Snippet code so please give idea how i want to execute this query in unix mechine.


Quote:
Originally Posted by thana View Post
Code:

#!/bin/bash
sqlplus -s /nolog << EOF

CONNECT $DB_USER/$DB_PASSWORD

Your sql query here
................
.............

end;
/
EOF
  #5 (permalink)  
Old 03-21-2008
hanu_oracle hanu_oracle is offline
Registered User
  
 

Join Date: Mar 2008
Location: MUMBAI, INDIA
Posts: 41
Execute SQL Query from Unix.

Hi Ravi,

You can execute any SQL Statement from HERE..

##############################################

sqlplus -l USERNAME/PASSWORD@DB_SCHEMA <<EOF
insert into ODS_T_CFS_DUMP(FILE_NAME, REGION_ID, SDP_ID, SEQUENCE_ID, TOTAL_RECORDS) values ('$file','$region_id','$sdp_id','$sequence_id', '$cos_records');

Select 1 from dual;
select "Hello Ravi" from dual;
EXIT
EOF

###############################################
  #6 (permalink)  
Old 03-21-2008
ravi gongati ravi gongati is offline
Registered User
  
 

Join Date: Mar 2008
Posts: 15
Question Thanks hanu

I will explain my total requirement:-
We are developed script in PL/SQL. In the PL/SQL script i was got the fallout report(no. of rows records not extracted well).

Now client he was asking us like we want to execute the script in unix mechine. He was asking like while executing the PL/SQL script in unix the fallouts should be automatically store in Fallout table.Is it possible.

give me your mail id i will send my PL/SQL that will easy for both to understand.


Quote:
Originally Posted by hanu_oracle View Post
Hi Ravi,

You can execute any SQL Statement from HERE..

##############################################

sqlplus -l USERNAME/PASSWORD@DB_SCHEMA <<EOF
insert into ODS_T_CFS_DUMP(FILE_NAME, REGION_ID, SDP_ID, SEQUENCE_ID, TOTAL_RECORDS) values ('$file','$region_id','$sdp_id','$sequence_id', '$cos_records');

Select 1 from dual;
select "Hello Ravi" from dual;
EXIT
EOF

###############################################
  #7 (permalink)  
Old 03-21-2008
ravi gongati ravi gongati is offline
Registered User
  
 

Join Date: Mar 2008
Posts: 15
Exclamation Need Unix script for executing oracle query

DECLARE CURSOR np IS
SELECT * FROM np_classes;

total_rows_np NUMBER;

CURSOR idb IS
SELECT * FROM dl_class;

total_rows_idb NUMBER;

expFallouts NUMBER;

BEGIN
FOR x IN np LOOP
total_rows_np := np% ROWCOUNT ;
END LOOP;

FOR y IN idb LOOP
total_rows_idb := idb% ROWCOUNT;
END LOOP;

IF total_rows_np > 0 AND total_rows_idb >0 THEN

expFallouts := total_rows_np - total_rows_idb;
dbms_Output.new_line;
dbms_output.put_line('DL_ CLASS');
dbms_Output.new_line;
dbms_output.put_line('total rows np :' ||To_Char(total_rows_np ));
dbms_output.put_line('total rows idb :' ||To_Char(total_rows_idb));
dbms_output.put_line('Expected Fallouts :' ||To_Char(expFallouts));
Dbms_Output.new_line;
ELSE
Dbms_Output.new_line;
dbms_output.put_line('DB Empty');
END IF;
END;


Please check this query and tell me how i want to execute this code in unix mechine.

Quote:
Originally Posted by hanu_oracle View Post
Hi Ravi,

You can execute any SQL Statement from HERE..

##############################################

sqlplus -l USERNAME/PASSWORD@DB_SCHEMA <<EOF
insert into ODS_T_CFS_DUMP(FILE_NAME, REGION_ID, SDP_ID, SEQUENCE_ID, TOTAL_RECORDS) values ('$file','$region_id','$sdp_id','$sequence_id', '$cos_records');

Select 1 from dual;
select "Hello Ravi" from dual;
EXIT
EOF

###############################################
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 05:28 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0