SQL more s in shell script
Hi peopleI have this code in my shell script, but I get 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 this
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
Tags: Database
Similar Questions
-
SQL more how to stop script after the exception of the DDL
Hello
I have script .sql, which I managed by SQL * more.
Some migration of data and database structure changes were made in the script.
So, I use a lot of distinct calls:
@script_name.sql
@script_name_1.sql
@script_name_2.sql
...
Some of the scripts contains DDL as create table or column.
contains some declare blocks (DML).
Is it possible to stop the script after an exception has occurred?
Thank you, Olga.
Hi, Olga.
You can use the SQL * more order
WHENEVER SQLERROR EXIT
to tell SQL * more to stop the execution of orders and immediately disconnect after any exception SQL is triggered.
I don't know of anyway to stay connected, but to stop script execution, after an error.
-
Coil PL/SQL parameter value using shell script
Hello
I 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";
EOFSQLAravindhK 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
-
Detection of parameter NLS_LANG clientside in SQL * more script
Our company has developed an application that uses an Oracle database as backend. Companies can purchase our application and run it against their own installation of Oracle.
A new version of our application often requires an update to the Oracle database schema.
As well as from new application files, we send our customers an update.sql script, they must run to their database using SQL * more.
This update script can contain international characters such as é for example:
Save us the SQL script file in the windows-1252 encoding the character e is encoded by 0xE9 in the script file.UPDATE SHOPS SET DESCRIPTION = 'Café' WHERE SHOP_ID=1
When the ADMINISTRATOR runs him upgrade script is set NLS_LANG =. WE8MSWIN1252 it works perfectly.
When the ADMINISTRATOR has set the NLS_LANG = US7ASCII the e is replaced by an exclamation mark the upside. Other NLS_LANG settings can also be embarrassing.
To avoid this, we give very clear instructions. However, nobody reads. This raises two questions:
(A) is there a way to prevent this problem, so I do not the parameter NLS_LANG by the DBA to run the upgrade script depend on?
(B) otherwise: is there a way to test the NLS_LANG setting in the script and give up if it's not WE8MSWIN1252?
Info:
Database is 10.2.0.3/10.2.0.4 and sometimes 10.2.0.5, always the database character set WE8MSWIN1252.
Client software: I don't know what are the uses each s/n, but it will be mainly the software client 10g
Client OS: Some DBA will run the script from Windows, others of some varieties of Unix. I can't control that.(A) is there a way to prevent this problem, so I do not the parameter NLS_LANG by the DBA to run the upgrade script depend on?
Yes. Use the UNISTR function to encode strings with Unicode, for example UNSITR('\00e9') exhausts to code 'e '. The set conversion implicit character in the set to the national character of database character set will do. You can use the ASCIISTR function to simplify the creation of arguments to UNISTR based on the input text.
-Sergiusz
-
SQL * more report: hide accept the value in the report
Hi all
I created a SQL for APEX-Application report. The output is stored in an HTML file.
Everything works great but think I want to hide in the HTML report.
I try to describe what is the problem.
I invite the user to put in the demand of the apex application_id:
accept v_application_Id char prompt ' ID application:'
In the HTML file, you receive the following output:
Report tabled the: June 25, 2013, 10:06:04 ALT 8: where application_id = & & v_application_id
Neu 8: where application_id = 680Workspace Workspace APPLICATION_ID Application_name ALIAS OWNER Q0Q0AUFTRAGSVERWALTUNG 680 Q0Q0AUFTRAGSVERWALTUNG F680317 Q0Q0AUFTRAGSVERWALTUNG_ADMIN How to hide the two lines
ALT 8: where application_id = & & v_application_id
Neu 8: where application_id = 680
According to the report?
I searched this forum and toke a glance in the documentation, but I found nothing.
Could someone help me please?
Oracle 11g R2
This is the SQL script I run in SQL * more.
-launch scriptaccept v_application_Id char prompt ' ID application:'
coil C:\a\APEX.html
termout off Set
SET of HTML MARKUP WE REEL WE HEAD ' < TITLE > SQL * more APEX report < /title >--
"< STYLE TYPE =" TEXT/CSS"> <!-BODY {bgcolor: background ffffaa: ffffc6}-> < / STYLE >.
Clear jump
clear the buffer
Claire calculate
clear the column
Disable the sql
Set feedback off
Set serveroutput on
--
-Report header
--
TTITLE left ' ' jump 1
Select TO_CHAR (sysdate, 'dd-Mon-yyyy, hh24:mm:ss') ' report created on:
Double;
--
-Workspace
--
TTITLE left col 15 ' < police = "Arial" size = "+ 2" color = "#0000FF" > workspace < / police > ' jump 1set linesize 300
set pagesize 500
Set serveroutput on
column format a35 workspace
application_id 99999999 column format
column format a35 application_name
column alias format a35
column owner format a35Select
WORKSPACE,
APPLICATION_ID,
APPLICATION NAME,
ALIAS,
OWNER
of apex_applications
where application_id = & & v_application_id;off Ttitle
Select
APPLICATION_GROUP,
APPLICATION_GROUP_ID,
HOME_LINK,
PAGE_TEMPLATE,
ERROR_PAGE_TEMPLATE
of apex_applications
where application_id = & & v_application_id;
Set termout on
moved the markup html off the coast of the "body" entmap wide head reel off pre
Set of feedback on
set linesize 80
set pagesize 50
off Ttitle
Set termout on
Set serveroutput off
spool off
set echo on-End Script
Best regards
Ben
Oracle 11g R2
Hi, Ben.
The SQL * Plus command to stop these messages is
SET VERIFY OFF
Put this command anywhere before the first use of a substitution variable, for example before the order of the COIL.
These 'OLD' and 'NEW' messages will remain deleted until you finish the SQL * most the session or cause a SET VERIFY ON command.
If you use SQL * more often, then, when you have a few minutes, look for the SET command in SQL * more manual,.
System of SETTING Variable summary
and read a little about each option. You probably don't remember everything, but you'll probably remember what kind of things can be controlled by the SET command and get a better idea of where to start to look in the future when you have a different problem.
-
How to validate SQL * MORE connection in Unix shell script
I wrote the following function in unix shell script to validate SQL * MORE connection and throw a user-defined message.
function check_db_conn
{
output | sqlplus-s-L $User/$Password@$SID >/dev/null
If [[$?-no 0]]; then
echo 'credentials incorrect DB.
FI
}
However, I would like to change this feature so that the user has entered a good connection and that there is a problem with TNS listener must display the appropriate message.
Hello
Try adding:
lsnrctl status $listener_name > /dev/null if [[ $? -ne 0 ]]; then echo "Issue with Listener" fi
-
Need an example of loop with sql statement in shell script values
Hello
I have to present a simultaneous program to each line of the table through script shell (only).
The table has all the parameters required to pass to the concurrent program.
I have trouble in a loop with the lines of sql statement results.
Could someone give me an example of a shell script with a loop with the sql statement values.
appreciate your time and your help.
Thank you
Ganesh
Hello
Here is a guide using 3 parameters:
{
sqlplus-s $OA_USR / $OA_PWD<>
SET THE OFF POSITION;
SET FEEDBACK OFF;
SET LINESIZE 300;
SELECT param1, param2, param3
Of your_param_table;
ENDOFSQL
} | while reading line
do
If ['$line'] # line non-NULL
then
set $line
param1 = "$1."
param2 = "$2."
param3 = "$3."
# Pass parameters to a script, sql more
sqlplus-s $apps_usr / $apps_pwd @SUBMIT_CONC_PROG.sql $param1 $param2 $param3
FI
fact
}
In your SQL * more script you run 3 parameters into variables:
declare
VARCHAR2 (10) param1: = ' & &1';
VARCHAR2 (10) param2: = ' & &2';
param3 varchar2 (10): = ' & &3';
.....
-
Why the sql statement was extucted twice in shell script?
I tried to test the rac load balancing using the shell script depending on suse 10 + oracle 10g rac.
After run the shell script, I got the result to follow.oracle@SZDB:~> more load_balance.sh #!/bin/bash for i in {1..20} do echo $i sqlplus -S system/oracle@ORA10G <<EOF select instance_name from v\$instance; / EOF sleep 1 done exit 0
Seem that the sql statement was run twice in each loop. If you help please take a look. Thanks in advance.oracle@SZDB:~> ./load_balance.sh 1 INSTANCE_NAME ---------------- ora10g2 INSTANCE_NAME ---------------- ora10g2 2 INSTANCE_NAME ---------------- ora10g1 INSTANCE_NAME ---------------- ora10g1 3 INSTANCE_NAME ---------------- ora10g1 INSTANCE_NAME ---------------- ora10g1
RobinsonBecause you have one; and one.
-
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.
-
Calling shell script program SQL and passing parameters
Hi guys,.
Greetings from Toronto. Is it possible to move one or more strings as parameters to a sql from shell script program?
Shell script
SQL program (rd_test.sql)# 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
As always, this is not something I have to solve that minute. Any help would be appreciated-- 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 /
and I will think of the problem.
Thank you
REDA
Published by: Raj404261 on June 25, 2009 11:40
Published by: Raj404261 on June 25, 2009 17:29OK, just a few pointers possible if you need to go the way of shell script.
I suggest that you have a separate SQL script for each of your options, which retains the fairly well-defined lines and keeps the maintenance as simple as possible. Therefore, in your shell script, you can have something like:
#!/bin/ksh # Accept system input parameters p_user_id=$1 p_job_id=$2 # Deduce which script you'll call here # using if statements, or even a case: if [[ p_job_id -eq 1 ]] then SQL_SCRIPT=sql_script1.sql else SQL_SCRIPT=sql_script2.sql fi # Or using case case $2 in 1) SQL_SCRIPT=sql_script1.sql; 2) SQL_SCRIPT=sql_script2.sql; 3) SQL_SCRIPT=sql_script3.sql; *) SQL_SCRIPT=sql_script4.sql; esac export ${SQL_SCRIPT} #If you need to query the database at all to deduce which script to cal #Then something like this: SCRIPT_VAR=`sqlplus -s username/password << EOF set heading off set feedback off set verify off SELECT * FROM DUAL; EOF` export {SCRIPT_VAR} SQL_SCRIPT=sql_script${SCRIPT_VAR}.sql # Then just call your script: sqlplus. -s $p_user_id/password @${SQL_SCRIPT}
-
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.
-
will not appear sql statemnt in shell script
Hello
I have a shell script with an unfavourable sql she calls another script where I connect to dabase.
In the journal of the script, I see the sql statement and I wish that that do not show me anything. How I make these?
Thank you
Hello
2650697 wrote:
Hello
I have a shell script with an unfavourable sql she calls another script where I connect to dabase.
In the journal of the script, I see the sql statement and I wish that that do not show me anything. How I make these?
Thank you
Your postal code. It is very difficult to tell what you're doing wrong without knowing what you are doing.
You can have SQL statements directly in your shell script. They must be in a script by themselves, said fubar.sql, and shell script must contain
@fubar
instead of real SQL statements.
-
Using the shell script sql variable
OS: Oracle Linux 5.10
DB Oracle 11.2.0
I have need to query the database and assign the return value to a variable of shell, but it does not work.
create table imr_env (key varchar2(1000), value varchar2(1000) ; insert into imr_env values('TblspcUsagePct','90'); commit;
Here is the shell script:
#!/bin/bash echo "in script" ORACLE_HOME=/u01/app/oracle/product/11.2.0/db_1 ; export ORACLE_HOME ORACLE_SID=IMR1 ; export ORACLE_SID export PATH=$PATH:$ORACLE_HOME/bin pct=`sqlplus -S app/manager <<END set serveroutput on declare output_val number ; BEGIN select value into output_val from imr_env where key = 'TblspcUsagePct' ; dbms_output.put_line('output_val: ' || to_char(output_val)) ; END ; / exit; END` ## another sqlplus connection, use $pct in the where clause echo "var value is $pct"
Here is the result:
SQL> ./test.sh in script var value is output_val: 90
Why isn't the shell variable is populated with the value retrieved from the database?
I need to use $pct in another query that will be storage spaces that are at least 90% full.
I had to change to a korn shell - I couldn't get the "READ" command in shell or bash.
But it is not only "READ" command:
SQL > select * from IMR_ENV;
THE KEY VALUE
------------------------- -----
TblspcWarningLimit 90
TblspcUsagePct 50
SQL > exit
Disconnected from the database to Oracle 11 g Enterprise Edition Release 11.2.0.3.0 - 64 bit Production
With partitioning, OLAP, Data Mining and Real Application Testing options
$ cat test.sh
VAL = $(sqlplus-S test/test)<>
Set feedback off
set the position
Select (value) from imr_env, including the key to_number = "TblspcUsagePct";
Select (value) from imr_env, including the key to_number = "TblspcWarningLimit";
"exit";
EXPRESSIONS OF FOLKLORE
)
set $VAL
Echo $1
Echo $2
$./test.sh
50
90
$ echo $SHELL
/ bin/bash
$
-
Component sql through shell script
How to call a sql through UNIX shell script file?Rahul India wrote:
export ORACLE_HOME=$ORACLE_BASE/product/10g cd $ORACLE_HOME set `sqlplus -s
/ < THIS SCRIPT IS OK?
You will also need to set ORACLE_SID
And I don't know why everyone puts the reference to sqlplus context of a 'set' assessment, nor why they put the reference to Scripture in a redirected input stream. What you need is
sqlplus -s user/password @r_100.sql
And to make sure the environment is set correctly:
export ORACLE_SID=whatever export ORAENV_ASK=NO . oraenv unset ORAENV_ASK=NO sqlplus -s user/password @r_100.sql
-
Call the PL/SQL shell script
Hi all
I've seen several links and options for calling a PL/SQL shell script. I was wondering if there is something like DBMS_SCHEDULER. CREATE_PROGRAM-> executable that calls an external program in 11 GR 2.
Here's what I have to. I have 11 GR 2 database with Dataguard. I have START triggering who begins a DBMS_SERVICE when the role becomes PRIMARY. In the same instance, I would stop the VIP on the former primary database and start the VIP on the new primary database.
Thanks for the advice and assistance.
Jan S.The URL below links to ask Tom. Inside, he talks about creating a Java procedure in your database that allows you to execute commands from the host OS (PL/SQL calls the proc of Java that runs the host command). There are several ways to run the OS commands, but this one is very flexible. I needed to use it for a task that I have who didn't fit one of the other methods very well.
http://asktom.Oracle.com/pls/Apex/f?p=100:11:0:no:P11_QUESTION_ID:3069633370832
Maybe you are looking for
-
Match + Apple iTunes music DRM Free?
Dear Apple community, Music is my life, is more valuable to me then anything else. In the early half of my library was already purchased files WAV, Apple Lossless-converted. The other half was poor quality MP3. I signed up for Apple music and began t
-
Re: Portege R400 - cannot install 3G on Windows 7 driver
Hello I installed Windows 7 Beta on my R400 Windows Vista cannot use on the R400 (way to slow down).Everything works fine except for the 3 G module.I am not able to install the drivers. The latest status info is "copying new files" before the beginni
-
Where can I download HWSetup?
HelloI lost my TOSHIBA CD all the drivers that I find on the web, but where can I find the HWSetup? Please help me.Best regards
-
Hello The last time, I sometimes it all of a sudden my phone freeze. My mouse is not responding that also my laptop keyboard does not respond. When I wait like 2 or 3 minutes, everything works again. But I get no message... so I don't know what is ha