SQL Alias's in Shell Script
Hello all,
We are running Oracle 10G on Unix and I am fairly new to Unix. I know how to assign a SQL select statements values to an alias in a SQL environment such as TOAD, such as for example;
Select LogID ID, LogType Type, LogDate Date from audit_logs
where LogDate = sysdate;
That will give the determined values the labels of ID, Type, and Date respectively. But how do I assign the multiple SQL select values to shell script variables in UNIX? I have found how to do it for a single value but not a multiple value.
Thanks in advance
Regards
Alano
Thanks for reply.
What we want to do is ensure a relevant file was deleted by a database package\procedure that is part of a third party application. My aim will be to interrogate the relevant table, extract the three relevant fields and join them together into one line\string that will be appended to a lof file
Thanks again in advance
Regards
Alano
Similar Messages
-
Error Handling with sql *plus from a shell script
When I execute sql plus in a shell script with the wrong username/pass pair, the shell script hangs without terminating. What is the proper way to execute sql plus in a shell script that will catch a login failure and make sure the script doesn't hang?
Example:
We execute the following in our shell script:
sqlplus ${ORACLE_INST} @./sql/ftp_ledger_put.sql
Now if somebody comes along and alters the login then the script would hang. Is there a way to have the script exit gracefully?Not the most elegant solution but.......
sqlplus <<EOD 2>&1 >some_log_file
user/pwd
@somescript
exit
EOD
Because sqlplus allows for 3 tries at log in if user/pwd is not valid it will try to use subsequent lines. Each will fail.
You have to look in some_log_file to determine success/failure
Ken -
Catch a value from a pl*sql function in a shell script
Hi all,
I have a shell script that simply calls the following pl*sql function.
echo "execute scott.my_pkg.test('FDLmaster');\n exit;" >./pippo.sql
sqlplus scott/tiger @/fidcap_ftp/FDL/SCRIPTS/pippo.sql
What I have to do to catch the value returned from the function test?
Thanks in advance
best regards
MarioSQL> create or replace function do_something return varchar2 is
2 begin
3 return ('Something');
4* end;
SQL> /
Function created.
SQL> select do_something from dual;
DO_SOMETHING
Something
SQL> save pippo
Created file pippo.sql
SQL> exit
Disconnected from Oracle Database 10g Enterprise Edition Release 10.1.0.3.0 - Production
With the Partitioning, OLAP and Data Mining options
[linuxas tmp test10]$ echo exit >>pippo.sql
[linuxas tmp test10]$ VAR=`sqlplus -s scott/tiger @pippo`
[linuxas tmp test10]$ echo $VAR | cut -f3 -d" "
Something
[linuxas tmp test10]$ -
Procedure call from SQL*Plus in Korn Shell Script
I am trying to excute a procedure from sqlplus, truncate_audit_table. I doesn't execute. If I do it manually
it executes. I have tried multiple ways, as below. This is inside a Korn Shell scripts that creates the procedure
and counts the aud$ table. All that works, but does not truncate the aud$ table. It does not do it, no error, just
passes it by. Does anybody know why?
${ORACLE_HOME}/bin/sqlplus -s / << EOF | tee -a ${LOG}
set feedback on
@/backup/oracle/orcl/audit/truncate_audit_table.sql
select count(*) from sys.aud$;
exec truncate_audit_table;
exit
EOF
${ORACLE_HOME}/bin/sqlplus -s / << EOF | tee -a ${LOG}
set feedback on
@/backup/oracle/orcl/audit/truncate_audit_table.sql
select count(*) from sys.aud$;
begin
truncate_audit_table;
end;
exit
EOF
This is the procedure that is being called:
create or replace procedure truncate_audit_table
as
begin
execute immediate 'truncate table sys.aud$';
end;
/aud$ is owned by sys. You can see it does the count with or without the "\".
It creates the procedure under SYS , but does not execute it.
Truncate aud$ table...
Procedure created.
COUNT(*)
422
1 row selected.
===============================================================
audit_maintenance.ksh Completed: Thu Oct 26 14:03:17 GMT 2006
=============================================================== -
Sql Loader by using shell script, not able to insert data
Hi,
I am trying to dump the data by using shell script.(in shell script i am having sqlldr command)(its a host excutable method cocurrent program)
When i am loading the data, by placing my files(.ctl,.prog,.csv,symbolink file for .prog) in $Custom_top/bin, it is loading exactly. 17000 records inserted.
But if i am loading the data by placing my files in $custom_top/custom_folders. unable to insert total data. only 43 records inserting.
Please any one can help me.
Thanks in advance.
Rama.Srini, Thanks a lot for ur reply,
Oracle Apps version R12,
Microsoft windows XP profissional
Version 2002 service Pack 3
My Control file Script is:
load data
infile '$XADP_TOP/data/CPIU/in/XXOKS_Price_Increase.csv'
append
into table XXOKS_CONTRACT_PRICE_INCR_DTLS
fields terminated BY ',' optionally enclosed by '"'
TRAILING NULLCOLS
(EXCLUSION_FLAG,
LEGACY_NUMBER,
CUSTOMER_NUMBER,
CUSTOMER_NAME,
REQUEST_ID,
CONTRACT_NUMBER,
CONTRACT_START_DATE,
CONTRACT_END,
REQUEST_LINE_ID,
LINE_START_DATE,
LINE_END_DATE,
ITEM_NUMBER,
ITEM_DESCRIPTION,
UNIT_PRICE,
QTY,
NEW_UNIT_PRICE,
LINE_AMOUNT,
NEW_LINE_AMOUNT,
PRICE_INCREASED_DATE,
PERCENTAGE_INCREASED,
ORIGINAL_CONTRACT_AMOUNT,
NEW_CONTRACT_AMOUNT,
PRICE_INCREASE_AMOUNT)
My .prog File is: Please fidn that i created symbolink file also for my .prog.
if [ -z $XADP_TOP ];then
echo "XADP_TOP environment variable is not set!"
exit 1
fi
cd $XADP_TOP/data/CPIU/in
DATE=`date +%y%m%d:%H%M`
i_program_name="$0"
i_ora_pwd="$1"
i_user_id="$2"
i_user_name="$3"
i_request_id="$4"
i_ftp_host_name="$5"
i_ftp_user_name="$6"
i_ftp_user_password="$7"
ftp_prog() {
# FTP Function to reuse the FTP Commands
if [ $# -ne 6 ];then
echo "Usage : ftp_prog <Hostname> <User name> <Password> <Remote Directory> <command> <filename>"
exit 2
fi
l_ftp_host_name="$1"
l_ftp_user_name="$2"
l_ftp_user_password="$3"
l_ftpdir="$4"
l_ftp_command="$5"
l_ftp_filename="$6"
ftp -v -n ${l_ftp_host_name} <<EOF
user ${l_ftp_user_name} ${l_ftp_user_password}
ascii
cd ${l_ftpdir}
${l_ftp_command} ${l_ftp_filename}
quit
EOF
#exit $?
# setting the ftp directory
#ftpdir="/`echo ${TWO_TASK:-$ORACLE_SID}|tr "[A-Z]" "[a-z]"`/CPIU"
##ftpdir="/FinTEST/quoting/PS/ar"
ftpdir="$XADP_TOP/data/CPIU/in"
# setting the in directory and out directory
indir="$XADP_TOP/data/CPIU/in"
outdir="$XADP_TOP/data/CPIU/out"
ftp_prog ${i_ftp_host_name} ${i_ftp_user_name} ${i_ftp_user_password} ${ftpdir} get XXOKS_Price_Increase.csv
echo $ftpdir
echo "Converting the data file into unix mode"
dos2unix XXOKS_Price_Increase.csv XXOKS_Price_Increase.csv
chmod 777 XXOKS_Price_Increase.csv
cd $XADP_TOP/bin
echo "Trying to excute sqlldr and entering into the into control file"
$ORACLE_HOME/bin/sqlldr userid=$i_ora_pwd control=XXOKS_PRICE_INCR_LOAD log=$XADP_TOP/log/XXOKS_PRICE_INCR_LOAD_${DATE}.log;
exit_status=$?
echo "Checking the status and giving permissions to the data file which in in dir"
if [ $exit_status -eq 0 ]; then
cd $XADP_TOP/data/CPIU/in
chmod 777 XXOKS_Price_Increase.csv
echo "try to move data file into out dir"
# Moving the file to out directory
mv XXOKS_Price_Increase.csv ${outdir}/XXOKS_Price_Increase.csv_${DATE}
#echo "ready to zip file in out dir step6"
# Zipping the file
#gzip -f ${outdir}/XXOKS_Price_Increase.csv_${DATE}
echo "deleting the file which is in dir"
# Deleting the file from in directory
/bin/rm -f ${indir}/XXOKS_Price_Increase.csv
# Deleting from the remote directory
ftp_prog ${i_ftp_host_name} ${i_ftp_user_name} ${i_ftp_user_password} ${ftpdir} delete XXOKS_Price_Increase.csv
echo "sqlloader finished successfully."
else
echo "Error in loader"
##echo "Loader error in Price Increase Detials File ${i_file}"
fi
exit $exit_status
And My Log file Comments are
SQL*Loader: Release 10.1.0.5.0 - Production on Thu Dec 3 01:32:08 2009
Copyright (c) 1982, 2005, Oracle. All rights reserved.
Control File: XXOKS_PRICE_INCR_LOAD.ctl
Data File: /oesapp/applmgr/GIS11/apps/apps_st/appl/xadp/12.0.0/data/CPIU/in/XXOKS_Price_Increase.csv
Bad File: XXOKS_Price_Increase.bad
Discard File: none specified
(Allow all discards)
Number to load: ALL
Number to skip: 0
Errors allowed: 50
Bind array: 64 rows, maximum of 256000 bytes
Continuation: none specified
Path used: Conventional
Table XXOKS_CONTRACT_PRICE_INCR_DTLS, loaded from every logical record.
Insert option in effect for this table: APPEND
TRAILING NULLCOLS option in effect
Column Name Position Len Term Encl Datatype
EXCLUSION_FLAG FIRST * , O(") CHARACTER
LEGACY_NUMBER NEXT * , O(") CHARACTER
CUSTOMER_NUMBER NEXT * , O(") CHARACTER
CUSTOMER_NAME NEXT * , O(") CHARACTER
REQUEST_ID NEXT * , O(") CHARACTER
CONTRACT_NUMBER NEXT * , O(") CHARACTER
CONTRACT_START_DATE NEXT * , O(") CHARACTER
CONTRACT_END NEXT * , O(") CHARACTER
REQUEST_LINE_ID NEXT * , O(") CHARACTER
LINE_START_DATE NEXT * , O(") CHARACTER
LINE_END_DATE NEXT * , O(") CHARACTER
ITEM_NUMBER NEXT * , O(") CHARACTER
ITEM_DESCRIPTION NEXT * , O(") CHARACTER
UNIT_PRICE NEXT * , O(") CHARACTER
QTY NEXT * , O(") CHARACTER
NEW_UNIT_PRICE NEXT * , O(") CHARACTER
LINE_AMOUNT NEXT * , O(") CHARACTER
NEW_LINE_AMOUNT NEXT * , O(") CHARACTER
PRICE_INCREASED_DATE NEXT * , O(") CHARACTER
PERCENTAGE_INCREASED NEXT * , O(") CHARACTER
ORIGINAL_CONTRACT_AMOUNT NEXT * , O(") CHARACTER
NEW_CONTRACT_AMOUNT NEXT * , O(") CHARACTER
PRICE_INCREASE_AMOUNT NEXT * , O(") CHARACTER
value used for ROWS parameter changed from 64 to 43
Table XXOKS_CONTRACT_PRICE_INCR_DTLS:
43 Rows successfully loaded.
0 Rows not loaded due to data errors.
0 Rows not loaded because all WHEN clauses were failed.
0 Rows not loaded because all fields were null.
Space allocated for bind array: 255162 bytes(43 rows)
Read buffer bytes: 1048576
Total logical records skipped: 0
Total logical records read: 43
Total logical records rejected: 0
Total logical records discarded: 0
Run began on Thu Dec 03 01:32:08 2009
Run ended on Thu Dec 03 01:32:08 2009
Elapsed time was: 00:00:00.19
CPU time was: 00:00:00.04
Plz srini help me.
Thanks in advance
Rama.. -
SQL in Connection with shell scripts
Hello everyone,
I have a conceptual question:
If people like to implement their SQL-Scripts attached on a shell script(Ruby, Perl, or even OS-Shell), what are actually the benefits doing this? Can someone please give me a szenario, which is very effectively if we do it with combination with shell-script.
My second question: does oracle sql developer support this shell combination?
Thank you..Wrapping sql script in a shell script provides flexibility. Shell can provide better parameter validation than SQL, better output handling, and better error trapping. Personally I would have the sql script separately for purist modularisation reasons, but you can merge the two.
e.g.
getdate.sql
select sysdate from dual;getdate.sh can look like this
sqlplus user/pwd @getdateor
sqlplus user/pwd <<EOSQL
@getdate
EOSQLor
sqlplus user/pwd <<EOSQL
select sysdate from dual;
exit
EOSQLMy preference would be for either of the first two.
You can use various shell facilities to capture the output of the sql statement for use elsewhere. Variations of the above example can be use to get the current database date and time into the shell environment for use in other queries, or in the shell itself.
You can run SQL Developer from the command line, but the tool of choice for command line is SQL Plus. -
Hi Folks
I have this code in my shell script but am getting the below error please check
sqlplus -s scott@xyz/tiger @1.sql > 1.log
and oracle home is
/oracle/app/oracle/product/11.2.0/dbhome_1
error thrown is
Error 6 initializing SQL*Plus
SP2-0667: Message file sp1<lang>.msb not found
SP2-0750: You may need to set ORACLE_HOME to your Oracle software directory
i have checked i have sp1us.msb please help me on thisnewbie wrote:
Sir i have given my oracle home.
how to check whether it is set properly o not?No, you have stated what you believe ORACLE_HOME should be. But you have NOT proven that it was correctly set in the session that threw the error, and the error itself is almost certain proof that it was NOT set correctly. And your assertion that the referenced file does indeed exist (again, your assertion, not proof) lends more weight to the evidence that ORACLE_HOME is not properly set.
Issue the following commands, then copy and paste the entire session (full command, full output) to your next posting
env |grep ORA|sort
echo $PATH
sqlplus -s scott@xyz/tiger @1.sql > 1.log -
How to Compile the PL/SQL Package/ Procedure using shell script
Hi,
I tried to Compiled the shell script but I am facing some error.
Can any one help me how to compile the PL/SQL shell script without error. Awaiting for your valuable reply.
Thanks,
Arun Prakashuser8726849 wrote:
PL/SQL shell script without errorWhat's a PL/SQL shell script?
Can you please post exactly what you are trying to do (As in the actual code that you are executing and its output)? Also please post it in \ tags (See FAQ). -
Calling pl/sql stored procedure from shell script ( kshell)
hello.,
i have written a stored procedure. i need to call this stored procedure from a unix shell script ( korn shell).
can anyone please help me how can i do it.actually there are 3 stored procedures. so my shell script has to call each stored procedure, execute it then go to next stored procedure execute it.
if by chance inbetween any stored procedure do not execute then the shell script has to tell me that this stored procedure failed to execute.
please help me in this.
thanks
madanSorry Madan,
Following is the complete solutiion:
!# /usr/bin/ksh
sqlplus -s user/pass@server << EOF > a.log
exec proc1;
exec proc2;
exec proc3;EOF
if [ $? -eq 0 ]
then
echo "\n Procedures completed successfully at `date`"
else
echo "!!! FAILED!!!"
echo "Details can be found in a.log File"
fi -
Looping through SQL statements in shell script
Hello members,
I'm working on the Solaris environment and the DB i'm using is Oracle 10g. Skeleton of what I'm attempting;
Write a ksh script to perform the following. I have no idea how to include my sql query within a shell script and loop through the statements. Have therefore given a jist of what I'm attempting, below.
1. Copy file to be processed (one file at a time, from a list of 10 files in the folder ).
for i in *
do
cp $i /home/temp[/CODE]2 . Create a snapshot(n) table : Initialize n = 1 -- -- To create my snapshot table and inserts records in SQL
create table test insert account_no, balance from records_all;3. Checking if the table has been created successfully:
select count(*) from snapshot1 -- query out the number of records in the table -- always fixed, say at 400000
if( select count(*) from snapshot(n) = 400000 )
echo " table creation successful.. proceed to the next step "
else
echo " problem creating table, exiting the script .. " 4. If table creation is successful,
echo " select max(value) from results_all " -- printing the max value to console
5. Process my files using the following jobs:
./runscript.ksh - READ -i $m ( m - initial value 001 )
./runscript.ksh - WRITE -i $m ( m - initial value 001 -- same as READ process_id )
-- increment m by 1
6. Wait for success log
tail -f log($m)* | -egrep "^SUCCESS"7. looping to step1 to :
Copy file 2 to temp folder;
create snapshot(n+1) table
Exit when all the files have been copied for processing.
done -- End of Step 1
Pointers on getting me moving will be very valuable.
thanks,
KrisHi,
Are you inserting the data from file or from some table.
If it is from file, I suggest sql loader would be better, I suppose.
If it is from table, then something like this
for i in *
do
sqlplus username/password@db_name<<EOF
create table test select * account_no, balance from records_all;
EOF
exit
doneAnurag -
Shell script calling SQL Program and passing parameters
Hi guys,
Greetings from Toronto. Is it possible to pass a string or strings as parameters to a sql program from a shell script ?
Shell Script
# Accept system input parameters
p_user_id=$1
p_job_id=$2
sqlplus.exe -s $p_user_id @$RD_PATH/rd_test.sql $p_user_id $p_job_id
SQL Program (rd_test.sql)
-- Accept system input parameters
define p_user_id = &1
define p_job_id = &2
-- Wondering if its possible to pass these 3 parameters from a shell script program.
-- (1) rd_test-$p_job_id-3-1.lis
-- (2) RD_PRINTER(rd_test,3)
-- (3) t_data
select
t_data=''rd_test-'||'''$p_job_id'''||'-1-1.txt''
t_data_dir=''.''
ksh $RD_PATH/another_shell_prog.sh $p_user_id $p_job_id '||a.rd_value||' '
||b.rd_value||' rd_test-$p_job_id-3-1.lis $RD_PRINTER(rd_test,3) '||
'$t_data $t_data_dir'||'
exit_status=$?
check_command'
from rd_job_parameter b, rd_job_parameter a
where a.job_id = &2
and a.jp_module_id = 'RDTEST'
and b.job_id = a.job_id
and b.module_id = a.module_id
/As always, its not something I have to solve this minute. Any help would be appreciated
and I will be thinking of the problem.
Thanks
Raj
Edited by: Raj404261 on Jun 25, 2009 11:40 AM
Edited by: Raj404261 on Jun 25, 2009 5:29 PMHi Sean,
Thanks for the reply. I am not at work yet. I already do have the if condition to call 2 separate sql scripts. I was hoping them to be reduced to one sql script. That's why I was hoping to pass some of those values to the select statement as parameters.
Here is what I was hoping to pass from the shell script based on an IF condition. The good thing about it is that I can hard code these 3 parameters in the shell script in the IF and ELSE conditions. Is it possible to tag these 3 hard coded values in the command line after $p_job_id and then capture these 3 parameters in the SQL program ?
1. rd_test-$p_job_id-3-1.lis or rd_test-$p_job_id-3-1.lis
2. RD_PRINTER(rd_test,3) or RD_PRINTER(rd_test,4)
3. t_data=''rd_test-'||'''$p_job_id'''||'-1-1.txt''
Shell script :
# Accept system input parameters
p_user_id=$1
p_job_id=$2
if [condition]
sqlplus.exe -s $p_user_id @$RD_PATH/rd_test.sql $p_user_id $p_job_id
else
sqlplus.exe -s $p_user_id @$RD_PATH/rd_test.sql $p_user_id $p_job_id
fi
ksh $RD_PATH/another_shell_prog.sh $p_user_id $p_job_id '||a.rd_value||' '
||b.rd_value||' rd_test-$p_job_id-3-1.lis $RD_PRINTER(rd_test,3) '||
'$t_data $t_data_dir'||' -
Passing params from SQL file to Shell Script and then from Shell to SQL Fil
Afternoon guys,
Have a fun question for all you gurus in shell scripting out there. I have a shell script that is calling 2
different SQL programs. My objective is to pass a variable called request_number from one sql program
to the shell script and then from the shell script back to another SQL program. I will explain why I
need this to happen.
Here is what the shell script looks like which calls sql programs student_load_a.sql and
student_load_b.sql. Student_load_a.sql basically creates the control file (.ctl) which is needed for the
SQL*Loader and then student_load_b.sql reads the table that was just loaded and does the main
processing. My main objective here is to be passing the request_number which is being generated
using an Oracle Sequence in student_load_a.sql and using this generated number in my main
processing in student_load_b.sql to select records from the table based on request_number.
Any ideas ?Any help or recommendations is welcome and appreciated.
*1. Shell Script*
# Accept system input parameters
p_user_id=$1
p_job_id=$2
# Create control files for sqlload
sqlplus.exe -s $p_user_id @$STUDENT_PATH/student_load_a.sql $p_job_id
exit_status=$?
# Do sqlloads
sdesqlldr.exe userid=$p_user_id control=student_load-$p_job_id.ctl \
log=student_load-$p_job_id.log \
bad=student_load-$p_job_id.bad
exit_status=$?
# Main processing
# sqlplus.exe -s $p_user_id @$STUDENT_PATH/student_load_b.sql $p_user_id $p_job_id $p_request_number
sqlplus.exe -s $p_user_id @$STUDENT_PATH/student_load_b.sql $p_user_id $p_job_id
exit_status=$?
exit 0*2. student_load_a.sql (Would like to pass back the Sequence Number back to shell script and then use in student_load_b.sql*
-- Accept system input parameters
define p_job_id = &1
spool student_load-$p_job_id.ctl
select
'append into table TMP_STUDENT_LOAD
FIELDS TERMINATED BY '','' optionally enclosed by ''"''
trailing nullcols
(request_number CONSTANT ' || '''' || request_number_seq.nextval || ''',
student_id)'
from dual
spool off;
exit 0;
{code}
*3. student_load_b.sql (This is a big file so I am only adding code that is relevant for the SQL)*
{code}
declare
v_request_number number(6);
v_student_id number(7);
cursor cur_student_load is
select student_id
from TMP_STUDENT_LOAD
where request_number = v_request_number
order by 1;
begin
v_user_id := '&1';
v_job_id := &2;
-- This is the variable I would like to be be passing from shell script to student_load_b.sql
-- v_request_number = '&3';
open cur_student_load;
fetch cur_student_load into v_student_id;
exit when cur_student_load%notfound;
.... more logic of if then else in here
close cur_student_load;
end;
{code}
Edited by: RDonASnowyDay on Jan 29, 2010 4:03 PMHow come you are mixing WinDoze script (*.exe) with Unix?
You are aware that you will be passing the password along with the user id to the second sql script?
I will assume Unix ksh:
# Accept system input parameters
p_user_id=$1
p_job_id=$2
# Create control files for sqlload
p_seqno=`sqlplus -s $p_user_id @$STUDENT_PATH/student_load_a.sql $p_job_id`
exit_status=$?
# Do sqlloads
sqlldr userid=$p_user_id control=student_load-$p_job_id.ctl \
log=student_load-$p_job_id.log \
bad=student_load-$p_job_id.bad
exit_status=$?
# Main processing
# sqlplus -s $p_user_id @$STUDENT_PATH/student_load_b.sql $p_user_id $p_job_id $p_request_number
sqlplus -s $p_user_id @$STUDENT_PATH/student_load_b.sql \
$p_user_id $p_job_id $p_seqno
exit_status=$?
exit 0And the first sql script would look like this:
-- student_load_a.sql
-- Accept system input parameters
set echo off pages 0 feed off lin 80 trims on ver off
def p_job_id = &1
col seqno NEW_VALUE seqno
select request_number_seq.nextval seqno from dual;
set term off
spool student_load-$p_job_id.ctl
select
'append into table TMP_STUDENT_LOAD
FIELDS TERMINATED BY '','' optionally enclosed by ''"''
trailing nullcols
(request_number CONSTANT ''&&seqno'',
student_id)'
from dual
spool off;
exit 0;
{code}
:p -
Calling shell script from sql procedure
Hi gurus
Is it possible
1)to call a shell script from sql procedure
2)that shell script has to return one value
3)and again sql procedure(calling shell script) has to capture the return value.
please help me to write this scriptYou may NOT have EXECUTE privilege/ permissions on the DBMS_PIPE package. Check with your DBA.
Using DBMS_PIPE may not be that simple to implement. Just making a call to DBMS_PIPE procedure will not do anything. It will NOT trigger anything on the UNIX side.
. You will also need to :
1. Write a job (ie CRON) at UNIX side which will keep read the incoming pipe for new messages, Unpack the message and get the command to be executed at the UNIX side -- There will be a lot of work involved here + DBA presence/activity is also required.
As Justin has pointed out, try and use HOST command which is very simple or try and use Java.
Shailender Mehta -
SQL-Scripts into a Shell script
Hi!
After creating the database on a Linux machine, we need to create our Schema in that database.This Schema has many objects(tables, views,
procs, triggers etc.). So executing each individual script would not be sensible. Is it possible to pack all sql scripts into one shell script and run that one?
Thanks for your feedback/examples/links!If it's one-off task, why not put all of them in a SQL file and run it from SQL* Plus rather than using shell to cause sql plus which will in turn have to call the script?
If it's a recurring task and you insist that you want to do it from Unix shell, you can do something like this:
Place all scripts in a single file and put it under $HOME for ex. (save it as run_all_scripts.sql)
Then write a shell script something like this:
#!/bin/ksh
connect_schema=scott/tiger
sqlplus -s $connect_schema <<EOF
@$HOME/run_all_scripts.sql
EOF
Regards
Venkat -
Shell script to run PL/SQL Program
hai,
i have problem in returning values from PL/SQL procedyre back to Shell script which calls the procdure.can anyone please suggest a model shell script to handle this
ThankyouSQL> create or replace function disp_mess
2 return varchar2 is
3 begin
4 return('Hello World');
5 end;
6 /
Function created.
SQL> select disp_mess from dual;
DISP_MESS
Hello World
SQL> exit
Disconnected from Oracle8i Enterprise Edition Release 8.1.7.4.0 - Production
With the Partitioning option
JServer Release 8.1.7.4.0 - Production
$ cat disp_mess.sh
MESS=`sqlplus -s scott/tiger << !
set head off
set pages 0
select disp_mess from dual;
exit
! `
echo $MESS
$ disp_mess.sh
Hello World
$Paul
Maybe you are looking for
-
PC Users: From iPod to iTunes
I have created a huge mess when I attempted to move iTunes onto an external hard drive. It is such a huge mess that I want to delete the current data from iTunes and transfer my music from my iPod to iTunes to retrieve my library. I tried downloading
-
Deleting applications from Hard Drive
I need to delete the OS 9 version of RealPlayer from my Hard Drive before installing the OS X version. The problem is, I can't purge the OS 9 version from my Hard Drive. I can drag it to TRASH, but that only creates a duplicate there. How do I elimin
-
How to use an arpeggiator?
Hello, I made a new track but I would like to use an arpeggiator on this. Someone can help me to find it? How does it work? Thank you for your answers!
-
Jsp files are converted to servlets at the first run as you know...Other requests are threaded from that servlet until a code change made in a jsp file... So why do we write servlets...? We may write a jsp(which is easier) then run it and automatical
-
I put a control on the form and am able to modify CSS informaiton. Dreamweaver creates the CSS code on the same cfm form. I would like to know how I can move all CSS code to my application CSS file. Can I just move all CSS code to my file or does Dre