Coil PL/SQL parameter value using shell script
HelloI execute PL/SQL procedure using shell script. I want the value of parameter in a coil OUTPUT text file. to_msg is the IN OUT parameter in the script below. Is this possible?
sqlplus test/***@db < < EOFSQL
COIL Status.txt
HEAD off SET
SET SERVEROUTPUT ON
declare
to_msg varchar2 (8000): = 'status ';
EXEC P_Status (to_msg);
SPOOL off
"exit";
EOFSQL
AravindhK wrote:
Thanks for your reply. When I roll the result, sql statements is also copied to the text file. How can I eliminate the sql statements.
What are the results when you do as below
sqlplus-s
Tags: Database
Similar Questions
-
How to write the CLOB parameter to a file or a XML using shell script?
I run an oracle stored procedure using shell script. How can I get the OUT of the procedure (CLOB) parameter and write it to a file or a XML in UNIX environment using shell script?
Edit/Delete MessageSQL> var c clob SQL> SQL> begin 2 select 3 DBMS_XMLGEN.getXML( 4 'select rownum, object_type, object_name from user_objects where rownum <= 5' 5 ) into :c 6 from dual; 7 end; 8 / PL/SQL procedure successfully completed. SQL> SQL> set long 999999 SQL> set heading off SQL> set pages 0 SQL> set feedback off SQL> set termout off SQL> set trimspool on // following in the script is not echo'ed to screen set echo off spool /tmp/x.xml select :c from dual; spool off SQL> SQL> --// file size SQL> !ls -l /tmp/x.xml -rw-rw-r-- 1 billy billy 583 2011-12-22 13:35 /tmp/x.xml SQL> --// file content SQL> !cat /tmp/x.xml
1 TABLE BONUS 2 PROCEDURE CLOSEREFCURSOR 3 TABLE DEPT 4 TABLE EMP 5 TABLE EMPTAB -
Hi people
I have this code in my shell script, but I get the below error please check
Please help me on thissqlplus -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
Newbie says:
Mr President, I gave my oracle home.How to check if she properly o?
No, you said that you believe that oracle_home should be. But you have NOT proven that it was properly defined in the session that threw the error and the error itself is almost certain evidence that it was NOT set correctly. And your assertion that the referenced file exists (again, your assertion, not proof) gives more weight to the evidence that ORACLE_HOME is not set correctly.
Run the following commands, and then copy and paste the whole session (complete order, full power) to your next assignment
env |grep ORA|sort echo $PATH sqlplus -s scott@xyz/tiger @1.sql > 1.log
-
Database remote stop using shell script
Hi all
I need to close a remote database through shell script. I won't know SYS password and so cannot connect directly.
I need to SSH to the remote database will define ORACLE_SID and then stop the database.
Note Please I want to achieve this without calling any other SQL or shell script I have ssh.
Pointers or help is much appreciated.
Kind regards
Nagendra ChillaleHi Nagendra,
following works for me...
SSH otherhost ".» \$home/.bash_profile
export ORACLE_SID = MYSID
echo \"shutdown abort\ | sqlplus------' / as sysdba\.
"SSH otherhost ".» \$home/.bash_profile
export ORACLE_SID = MYSID
sqlplus------' / as sysdba\.<>
startup
EXPRESSIONS OF FOLKLORE
"HTH Mathias
Published by: mzarick on August 13, 2009 11:27
-
Managed server starts do not using shell script
Hi all
I have configure weblogic server and 3 servers managed in it. I wrote a script to start the server. I am able to start the database/earpiece and weblogic admin server. But I'm not able to start managed server.script is as below. UCM_server1 does not start. When I click on 4, it's just showing
From UCM_server1
nohup: redirect stdout stderr
.
and so on
I just also field path and all the numnber port
Please suggest how to debug and fix this.
« 2 »)
Claire
#
lsnr_num ='ps - ef | grep tnslsnr | grep - v grep | AWK ' END {print NR} "
If [$lsnr_num - gt 0]
then echo "Database already running listener."
else echo 'starting Infrastructure Database listener... »
Starting from $ORACLE_HOME/bin/lsnrctl
FI
db_num ='ps - ef | grep pmon | grep - v grep | AWK ' END {print NR} "
If [$db_num - gt 0]
the echo then "database running."
else echo ' from Oracle Database... »
$ORACLE_HOME/bin/sqlplus "/ as sysdba" < < EOF
#connect eu1/sys as sysdba
startup
EXPRESSIONS OF FOLKLORE
#
Sleep 10
echo "Database Services started successfully."
#
FI
;;
#---------------------------------------------------------------------------------------------
« 3 »)
ECHO "from WLS_Admin..."
admin_num ='netstat - nl | grep '$ADMIN_PORT ' | grep - v grep | AWK ' {print NR} end "
If [$admin_num - gt 0]
then echo "WebLogic Admin Server running."
else echo "."
CD $DOMAIN_HOME/bin
echo "start WebLogic Admin Server... »
nohup./startWebLogic.sh > weblogic.out &
sleep 5;
admin_run ='grep-i 'Server started in OPERATION' weblogic.out | grep v - grep | AWK ' {print NR} end "
While [$admin_run - eq 0]
do
sleep 5;
admin_run ='grep-i 'Server started in OPERATION' weblogic.out | grep v - grep | AWK ' {print NR} end "
fact
FI
;;
#---------------------------------------------------------------------------------------------
« 4 »)
ucm_num ='netstat - nl | grep '$UCM_PORT ' | grep - v grep | AWK ' {print NR} end "
If [$ucm_num - gt 0]
then echo "UCM_server1 already running."
else echo "."
CD $DOMAIN_HOME/bin
ECHO "from UCM_server1... »
nohup./startUCMDebugMemory1GB.sh UCM_server1 > ucm.out &
sleep 5;
ucm_run ='grep-i 'Server started in OPERATION' ucm.out | grep v - grep | AWK ' {print NR} end "
While [$ucm_run - eq 0]
do
sleep 5;
ucm_run ='grep-i 'Server started in OPERATION' ucm.out | grep v - grep | AWK ' {print NR} end "
fact
FI
;;
best way to debug is to find the location of the log. Go to the location of the specified managed server and check out ucm_server.log. Check what error u get
-
pl/sql to java shell script
This issue crosses many boundaries, but it begins with PL/SQL, and I hope that there is sufficient expertise here in order to cover the basics.
System: Oracle 11.2.0.1.0 on Oracle 5, 64 - bit Linux
I have a PL/SQL, java appeal procedure, which in turn calls a shell script. I put a few diagnostic output in the shell script, the redirection of stdout to a file in / tmp. running the script from the command line works perfectly. When it is called by procedures, no output.
Here is the 'chain of traceability', somehow...
In the PL/SQL:
where the variable v_command = /opt/u01/app/oracle/admin/control/sqlldr3_test.scriptHost_Command (p_command => v_command||v_control_file||v_orasid);
So this is 'Host_command', the whole procedure procedure:
And the shell script /opt/u01/app/oracle/admin/control/sqlldr3_test.script:CREATE OR REPLACE PROCEDURE "DW"."HOST_COMMAND" (p_command IN VARCHAR2) AS LANGUAGE JAVA NAME 'Host.executeCommand (java.lang.String)';
but in the end, there is no /tmp/edstest.* file#!/bin/ksh export trcfle=/tmp/edstest.$$ export ORACLE_SID=$2 export ORACLE_HOME=/u01/app/oracle/product/11.2.0/dwdev export PATH=$PATH:/u01/app/oracle/product/11.2.0/dwdev/bin export ORACLE_BASE=/u01/app/oracle export SQLLDR_CONTROLFILE=$1 # echo input parms are $* >> $trcfle echo environment is: >> $trcfle env|grep -i ORACLE|grep -v grep|sort >> $trcfle # exit
open to all ideas.oracle$ ls -ltr /tmp/eds* ls: /tmp/eds*: No such file or directory oracle$
I cut things down to their bases, but with the exception of the line of the high level process, the code above is finished... is that my test cut original scripts to exactly what is show. Requriement of business is to take existing scripts and remove some of the stuff that is hard coded, allowing procedures move from dev to qa to prod without hardcoded values unique to each environment.
I'm very comfortable with PL/SQL and more with shell scripts, but the java link is a black hole for me.When the proc of Java runs the external command, a child process of Unix/Linux is created for it. This process inherits the environment settings of the parent process - that would be a dedicated server process, a work process or shared in the pool of the MTS server process.
These processes have parameters of environment of bare bones and something fundamental that + $PATH + should not be approved as being valid and usable.
If the Java code should fully qualify the path to the executable file to run.
Java code should do 2 things - stdout (and stderr if possible) back to the appellant to PL/SQL as vacrhar2 of the parameters out. And return the exit code of the child process.
They help a lot in troubleshooting why an outgoing external call failed.
We use these external calls widely enough (through a number of interfaces, treatments to distance running and pulling on the release of data by the latter in the database). All driven from PL/SQL using the proc of Java to make an outgoing call. If the basics are working-, but there seems to be a constant learning and troubleshooting curve to follow to get this working in a robust way.
-
export to shell script variable
Hi all
When I tried to export values of variables using shell script. Its exported values dies shell dies.
How to store these values in the current shelloracle:/app/oracle # cat a.sh export ABC=hi oracle:/app/oracle # ./a.sh oracle:/app/oracle # echo $ABC ksh: ABC: parameter not set
Problem I sthat, I can't use above method I provide parametrs to shell. I want to make the interactive script.oracle:/app/oracle # cat a.sh export ABC=hi oracle:/app/oracle # . a.sh oracle:/app/oracle # echo $ABC hi
Please suggest.select z in `ls` do echo $z break; done 1) 1.txt 2) a.sh 3) admin #? 3 admin
Let me know if the issue is not clear.
Thank you and best regards,
AjayHow is it a question of Oracle? Have you tried to check the Unix Forum instead?
Nicolas.
-
I'm on Mac OS X 10.11.2 and have problems with AppleScript and shell scripting.
The following script is a cutting of a larger project:
Tell application "Finder".
the value the_MePath (path for me)
the value the_MeCont (the_MePath container) as string
tell the end
the value of the_MeCont (text 1 thru-2) the_MeContShell
-normally isn't here!
the value the_MePara (the_MeCont & "STH - C Para WAV_48k_24.txt")
the value the_Parameters (opening for access file the_MePara with permission to write)
write ("WAV\r24\r48000\r48k\r") the_Parameters
Close access the_Parameters
-normally isn't here!
-destined to be there!
-the value the_MePara (shell script 'find' & city form the_MeContShell POSIX path & "-iname" "Para STH - C *'")
the value the_Parameters (opening for access file the_MePara)
the value the_ParaList (read the the_MePara file)
Close access the_Parameters
paragraph 1 of the value userFormat the_ParaList
paragraph 2 of the the_ParaList the value userBitDepth
paragraph 3 of the the_ParaList the value userSampleRate
paragraph 4 of the the_ParaList the value shortSampleRate
The lines between the "-normally isn't there!"-lines fills a file in the directory of the AppleScript with the data.
So now the file is there.
If I remove these lines and enable the line below "-intended to be here! ', the shell should find this file.
What I get, then, is a mistake:
"Fehler beim Zugriff auf das Netzwerk." error number - 5000 file "/ users/shared/_AppleScript development/_Archiv Sniplets/STH-C Para WAV_48k_24.txt" to "class fsrf".
to "open for access file the_MePara.
Any ideas, anyone?
Kind regards...
... Maik
Hello
Remove the end of file before the_MePara.
the_MePara contains a posix path type path--> "/ users/shared/_AppleScript development/_Archiv Sniplets/STH-C Para WAV_48k_24.txt.
You can use the file on the path of type HFS --> ' StartupDiskName:Users: shared: _AppleScript development: _Archiv Sniplets:STH - C Para WAV_48k_24.txt.
Information:
The script didn't need to open and close the access when the script to read-only.
Use this line only--> the value the_ParaList to read the_MePara
-
Get PLSQL stored procedure in unix shell script
Hi Experts,
I have a PLsql procedure with the specification below-
PROCEDURE SEND_INV_VIA_EMAIL (p_pdf_file_name IN VARCHAR2, p_submitted_frm IN VARCHAR2);
I can pass two parameters of SHELL script and it works fine-
# By calling the PLSQL procedure
sqlplus-s $APPS_USER < < EOSQL
SET SERVEROUTPUT SIZE 1000000
whenever sqlerror exit 1;
run MOB_XMLPUB_ARCHIVE_ARINV_PCK.send_inv_via_email ("basename $DATA_FILE", "ARCHIVE");
"exit";
EOSQL
But now I want to have an output in the plsql procedure parameter-
PROCEDURE SEND_INV_VIA_EMAIL (p_pdf_file_name IN VARCHAR2, p_submitted_frm IN VARCHAR2, p_return_status IN OUT VARCHAR2);
based on this I want to determine the concurrent request completion status since the shell script is called via the simultaneous program.
How will pass parameter out of the shell and how do I use this parameter in the SHELL script to determine completion status?
Thank you very much.
Vikrant
Something like this:
# By calling the PLSQL procedure
sqlplus-s $APPS_USER<>
SET SERVEROUTPUT SIZE 1000000
whenever sqlerror exit 1;
declare
rstatus varchar2 (100) - or however long, it must be
Start
MOB_XMLPUB_ARCHIVE_ARINV_PCK.send_inv_via_email ("basename $DATA_FILE", 'ARCHIVE', rstatus);
dbms_output.put_line (' status = ' | rstatus);
end;
/
"exit";
EOSQL
grep 'Return status =' somefile -
Query does not not in shell scripts
Hi Experts,
I created a query to check the temp tablespace use in production servers and I wanted to run the query using shell scripts, but when I run the query in the script I get no error or output I am unale to correct where exactly, I make the mistake
This is the query
SELECT A.tablespace_name 'space', D.gb_total, ROUND (SUM (A.used_blocks * D.block_size) / 1024 / 1024/1024,2) "gb_used", ROUND (D.gb_total - SUM (A.used_blocks * D.block_size) / 1024 / 1024/1024,2) 'gb_free' v$ \sort_segment A, (SELECT B.name, C.block_size, ROUND(SUM (C.bytes) / 1024 / 1024/1024,2) 'gb_total' v$ \tablespace B, v$ \tempfile C WHERE B.ts #= C.ts # GROUP BY B.name, C.block_size) D WHERE A.tablespace_name = D.name GROUP by A.tablespace_name D.gb_total
You can help in this.
Thank you...
Basic Linux/Unix shell script format
#! / bin/sh
oracle set environment #.
Export ORACLE_HOME =...
export of SID =... or TWO_TASK = export
.. etc.
# launch sqlplus
sqlplus-s/nolog<>
Connect scott/tiger
together... environment of sqlplus
-execution of script sql (or sql query)
@script.sql
output
EXPRESSIONS OF FOLKLORE
#end script
Character $ is interpreted by the shell as environment variables, you must escape the $ character is as well as it not assimilated to the variable approx.
For example, v$ instance should be written as v$ instance.
-
Get the progress and result of a shell script
Hello
I would use a shell script to convert MP3 / audio FLAC files MP3 files with a bitrate of 192kbs and do other things in Automator or AppleScript script.
So I installed lame and flac with brew, run an Automator process with a selected file and perform an action of AppleScrip:
on run {input, parameters} if input is not {} then repeat with theFile in input set posix_file to POSIX path of theFile if input is not {} then tell application "Terminal" set thescript to "/usr/local/bin/lame -b 192 \"" & posix_file & "\" " do script thescript end tell end if end repeat end if return input end run
The Terminal window is there because you tell the Terminal to run your script - try using shell script.
-
Hi all
I have oracle DB in Amazon EC2. This DB will go down and I have to make every day.
I want to write a shell script that checks the State of the DB and do.
The things I do is
Log in as root
Su - oracle
sqlplus
user name:
PWD:
If DB is down, it shows error.
So I'll do it again
Log in as root
. / stopPageview
Su - oracle
sqlplus
user name: sys as sysdba
PWD:
the judgment
startup
output
output
. / startPageview
How automatically using shell script?
Published by: 969707 on January 9, 2013 04:36#! / bin/bash
#
# /etc/init.d/oracledb
#
# Startup script execution for the Oracle Listener and instance level
# It relies on information on/etc/oratab# These are the paths for our basic installation
export ORACLE_BASE = / opt/oracle
export ORACLE_HOME=/opt/oracle/product/11.1.0/db_1
Export ORACLE_OWNR = oracle
export PATH = $PATH: $ORACLE_HOME/binIf [! f $ORACLE_HOME/bin/dbstart - o! d $ORACLE_HOME]
then
echo "Oracle startup: cannot start.
Output 1
FIcase '$1' in
implementation)
# Start a listener and oracle instance
echo - n "starting from Oracle:
known $ORACLE_OWNR - c "start ORACLE_HOME/bin/lsnrctl $".
known $ORACLE_OWNR-c "$ORACLE_HOME/bin/dbstart $ORACLE_HOME.
touch/var/lock/oracle
echo 'OK '.
;;
stop)
# Stop listener and oracle instance
echo - n "" shutdown Oracle: "."
"judgment of $ORACLE_HOME/bin/lsnrctl" known $ORACLE_OWNR - c
known $ORACLE_OWNR-c "$ORACLE_HOME/bin/dbshut $ORACLE_HOME.
RM-f/var/lock/oracle
echo 'OK '.
;;
reload | restart)
$0 stop
starting at $ 0
;;
*)
echo "use:" basename $0' start | stop | restart | reload. "
Output 1
ESACExit 0
also use link below to create start & stop the database...
http://www.Oracle-base.com/articles/Linux/automating-database-startup-and-shutdown-on-Linux.php
http://www.exzilla.NET/docs/instance/StartupNshutdownWithshell.php*****************************************
Best regards
Shishir Tekade.
My Blog: http://shishirtekade.blogspot.com -
Shell Scripts installation / migration of an object
Hi all
We are on Oracle Applications R12 and we settle down with it. Our database servers and the app are under Linux. To migrate objects from one instance to another, or to install objects, we use two different approaches. One is to move objects manually using installation instructions (MD120) and the other using Shell scripts. We must now choose any of these two approaches. But we are not able to decide. Grateful if you can help me answer questions more. This will greatly help us to complete the process. I'm for the Shell Script. But if I'm good arguments / reasons, I am not against.
1. who will be responsible for moving objects or migration? What DBA? If not, who? We DBAs perform this task.
2. our DBAs have argument if they move using script, there will be a question of great control over what moves in database / application server. (Our DBA is no previous case management experience Oracle Applications. There used to be an Oracle DBA for Peoplesoft)
3. If we have a few side by side comparison or a link to that will be perfect.
4. If someone has a case study and / or best practices document from the industry on this issue, please share it with me. My email is [email protected].
Earlier, I worked only in consultation of the companies where only the Shell script was the standard and best practices. It is my first company to the end user.
Appreciate the help and thank you in advance.
CAHHello
If you are willing to spend money, you could go with "Oracle Change Management Pack Application" as it can be used to migrate the changes / installation from one instance to another.
Application Management Pack and Application Change Management Pack 3.1 now available
http://blogs.Oracle.com/stevenChan/2010/01/amp_acmp_31_ebs.htmlThank you
Hussein -
Exports (from shell script) without password given explicitly in the script
Hi all
I have Oracle 10g 2 on SLES 10 64-bit. I would like to export the database using shell scripts data pump. Is there a method to hide the password in the script file.
Currently to be done by the command:
expdp system/password@database...
If any user who see the script will know the Passover.
Concerning
GroxyHello
Have you thought about the feature ' Secure external password store "which was added in 10 gr 2? It uses the Oracle Wallet to store a database_alias with the name of user and password credentials in an encrypted format. You can then enter your order expdp like this:
expdp / @database_alias...
Take a look at the security of 10gr 2 Guide. There is a chapter on how to put in place.
John
-
Call Shell Script from within PL/SQL - using DBMS_PIPE
Hi all
I'm trying to run a shell script inside my PL/SQL using DBMS_PIPE block (not sure if this is the right way or not)
Pl Sql script
==========
Set serveroutput size 100000
declare
cursor c1 is select * from mag_images
where nom_image like '% comp2.
v_path varchar2 (100): = ' / home/maguzzi/DOCUMENTS_DIR / ";
v_result number: = 0;
v_in_filename varchar2 (100): = v_path | ' test_file.jpg';
v_out_filename varchar2 (100): = v_path | ' test_file_out.jpg';
v_script varchar2 (100): = "tst_convert.sh";
v_command varchar2 (200): = 'sh'. v_path | v_script | » '|| v_in_filename | » '|| v_out_filename;
Start
A1 to c1 loop
dbms_output.put_line ('v_command: ' | v_command);
write_to_file ('test_file.jpg', 'DOCUMENTS_DIR', a1. Content);
dbms_output.put_line (' file write result: ' | v_result);
v_result: = exec_host_command (v_command);
dbms_output.put_line (' resize result :'|| file v_result);
end loop;
end;
Result DBMS_OUTPUT
====================
v_command: /home/maguzzi/DOCUMENTS_DIR/tst_convert.sh test_file.jpg test_file_out.jpg
Result of the entry of the file: 0
Result of resizing the file: 0
PL/SQL procedure successfully completed.
Function exec_host_command
=======================
FUNCTION to CREATE or REPLACE exec_host_command (lc_cmd IN VARCHAR2)
RETURN INTEGER IS
ln_status NUMBER;
lc_errormsg VARCHAR2 (80);
lc_pipe_name VARCHAR2 (30);
BEGIN
lc_pipe_name: = 'Maguzzi_PIPE ';
DBMS_PIPE. PACK_MESSAGE (lc_cmd);
ln_status: = dbms_pipe.send_message (lc_pipe_name);
RETURN ln_status;
END;
/
The Image of the BLOB is written to the correct location on the server "test_file.jpg", and although the exec_host_command function returns a value of 0, the shell script (tst_convert.sh) is not executed (i.e. no output file is created - outfile.txt and the image is not copied/converted to a new file name "" test_file_out.jpg" )
Shell script
========
tst_convert.sh
echo 'Here' > outfile.txt
Echo $1 > > outfile.txt
Echo $2 > > outfile.txt
resizing to convert $1 - $200 2
Could this be problems with permissions on files?
test_file1.jpg has permission - rw-rw-r-
test_convert.sh a permission rwxrwxrwx
When I run the script manually and pass in 2 parameters ($1 = infilename and $2 = outfilename), it works...
I'd appreciate if someone can point out my mistake or suggest another method that works.
Thanks in advance
How long does it take to create the converted file? Remember that the external Scheduler is running asynchronously, so it is possible that the converted file does not exist yet when the PL/SQL block subsequently tries to open it.
Try to add some delay seconds to the routine to ensure that the external task is completed:
begin dbms_scheduler.create_job( job_name => 'MAG_IMAGE_CONVERT2' , job_type => 'EXECUTABLE' , job_action => '/home/oracle/DOCUMENTS_DIR/tst_convert2.sh' );-- '/home/oracle/DOCUMENTS_DIR/tst_convert.sh'); dbms_scheduler.enable('MAG_IMAGE_CONVERT2'); dbms_lock.sleep(3); end;
This probably isn't really a viable solution in the long term if it turns out that this is really the problem.
Maybe you are looking for
-
I bought a clip video on iTunes and downloaded to my iPad Mini-4. I couldn't watch it. What should I do to see the video?
-
Context of sequence of LabVIEW user interface access
I'm trying to find a way convey the context of the sequence into LabVIEW Advanced User Interface. I need to check the values of some globals to the station before opening a movie file. I was looking for a way to send a UImessage to frontendcallbacks.
-
Is this a real attention/alert Windows security?
I got a "Windows Security Alert" less than an hour ago and the need to know whether it is legitimate, before I click REMOVE ALL to 91 spyware, adware & virus it shows. Can anyone help? (I took a screenshot & the window is still open)
-
Pavilion TS 15 Sleekbook: keyboard HP Pavilion Touchsmart 15 Sleekbook does not work correctly
Hello Recently, the keyboard on my laptop has stopped working. I tried to reset the laptop and do a hard reset, but nothing seems to work. I have to use the keyboard to type on the touch screen. When I turn on the laptop, I can type the password with
-
A Wi - fi connection is always on, even if not activated?
I have a question about wi - fi on Z5C. Most of the time, I have a disabled wi - fi connection. In 2 days, wi - fi is activated maybe 4 hours, no more. But this figure shows, that a wi - fi connection is always on? Time counter also shows a WiFi runn