SQL in Unix


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers SQL in Unix
# 1  
Old 03-13-2009
SQL in Unix

Hi,

I would like to access SQL plus from my unix, and learn to run some SQL scripts in Unix.

How do i begin. Is there any known website that offers a quick tutorial or tips?

Thanks,
unxhopeful
# 2  
Old 03-13-2009
SQLplus is oracle product and you will find it $ORACLE_HOME/bin
(Usually ~oracle/product/<vesrion>/bin)
# 3  
Old 03-17-2009
var=`sqlplus -s <<EOF
<statement>
>>EOF`
# 4  
Old 03-17-2009
Bug

on your sql prompt type

sqlplus (then enter)

u will b asked for username ans Passwd to connect to the database on that server from which ur logging into

Happy Scripting !!!
# 5  
Old 03-17-2009
sqlplus in unix

refer below code


Quote:
export SQL_QUERY="Select count(1) from SOME_TABLE where cur_pgm_name like 'DISPATCHER' and nxt_pgm_name like 'PM9USGLOADER' and file_status =
'AF' AND DATA_GROUP LIKE '%ASHISH%';"

export LOADER_AF_FILES_COUNT_NUM=`sqlplus -s user_name/password@db_instance << EOF
set echo off feed off heading off pagesize 0 trimspool on linesize 500
whenever sqlerror exit sql.sqlcode;
${SQL_QUERY}

EXIT;
EOF`

if [ $? -ne 0 ]
then
echo "Failed to execute query: ${SQL_QUERY}">> $LOG_FILE 2>&1
exit -10 ;
fi
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How can i run sql queries from UNIX shell script and retrieve data into text docs of UNIX?

Please share the doc asap as very urgently required. (1 Reply)
Discussion started by: 24ajay
1 Replies

2. Shell Programming and Scripting

Formatting sql in UNIX

hi folks am running the shell script below #!/bin/bash sqlplus 'scott@orcl/tiger'<<ENDSQL >> outputlogfile.csv SET PAGES 0 SET HEAD ON SET ECHO OFF SET FEEDBACK OFF SET LINESIZE 100 SET PAGESIZE 100 SET SERVEROUTPUT ON --# Fire the query on database select * from employee; ... (2 Replies)
Discussion started by: coolboy98699
2 Replies

3. Shell Programming and Scripting

Unix and SQL server

Hi All, I am accessing Unix through putty (i.e. unix is installed on other server and i am accessing it remotely through putty). I am having SQL Server 2008 installed on my computer. Now i want to access sql server via. unix. Could some one please help me in this!!! Thanks (2 Replies)
Discussion started by: preetpalkapoor
2 Replies

4. Programming

Doing a SQL rollup in unix

If anyone is familiar with Oracle, there is a way to trace a file. Then there is is a script called tkprof that will generate a report that includes a rollup of some values. The problem with this script is that it only does the rollup properly if the query is finished. So I need something quick and... (2 Replies)
Discussion started by: guessingo
2 Replies

5. Shell Programming and Scripting

How to use sql data file in unix csv file as input to an sql query from shell

Hi , I used the below script to get the sql data into csv file using unix scripting. I m getting the output into an output file but the output file is not displayed in a separe columns . #!/bin/ksh export FILE_PATH=/maav/home/xyz/abc/ rm $FILE_PATH/sample.csv sqlplus -s... (2 Replies)
Discussion started by: Nareshp
2 Replies

6. UNIX for Dummies Questions & Answers

Execute PL/SQL function from Unix script (.sql file)

Hi guys, I am new on here, I have a function in oracle that returns a specific value: create or replace PACKAGE BODY "CTC_ASDGET_SCHED" AS FUNCTION FN_ASDSCHEDULE_GET RETURN VARCHAR2 AS BEGIN DECLARE ASDSchedule varchar2(6); ASDComplete... (1 Reply)
Discussion started by: reptile
1 Replies

7. Shell Programming and Scripting

unix variables from sql / pl/sql

How do I dynamically assign the below output to unix shell variables so I can build a menu in a shell script? Example: var1 = 1 var2= SYSTEM var3 = 2 var4= UNDOTBS1 and so on, then in the shell script I can use the variables to build a menu. set serveroutput on declare... (2 Replies)
Discussion started by: djehres
2 Replies

8. Shell Programming and Scripting

sql through unix.

when we are spooling query o/p to certain txt file,in that file how we can get headers in the query.(through unix shell scripting). for exmple q1="slect * from XXXXXX;"; sqlplus XXX/XXXX@XXXXX spool XXXX.txt $q1 spool off in the text file i want the headers of the query..... ... (1 Reply)
Discussion started by: bhagya.puccha
1 Replies

9. Shell Programming and Scripting

Using SQL in Unix

Please tell me how i can use SQL in my unix scripts. Please give examples. I just want to start writing some scripts for my use. Looking for ur cooperation. thanks (2 Replies)
Discussion started by: Mohit623
2 Replies

10. Shell Programming and Scripting

SQL Commands in Unix

Hi gurus, Being a newbie not sure whether iam asking the right question? can we use oracle commands in unix for ex: to read a count on a table. if so, what needs to be configured and etc.. any kind of help is appreciated. Thanks sish (6 Replies)
Discussion started by: sish78
6 Replies
Login or Register to Ask a Question