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
Tags: Database
Similar Questions
-
How2 validate the chain of connection in unix shell script
I am writing a shell script unix which removes the instance user/passwd/user, form a connection string and pass it to sqlplus. Now, I want to validate if a valid/clean connection string was formed. Basically, I want to do something like below
sqlplus-s $CONN_STR
and disconnect if valid string and always disconnect and return to guest if it's not a string valid.
Is there a clean way, I can check if the return has been after a successful login and how disconnect it in script and check if a string is not valid.Create a file name test.sql containing only the OUTPUT and use-L option to SQL * more (attempts to connect only once, instead of reprompting error.)
D:\>sqlplus -L hr/ko@XE @test.sql SQL*Plus: Release 11.1.0.6.0 - Production on Wed Feb 17 08:48:37 2010 Copyright (c) 1982, 2007, Oracle. All rights reserved. ERROR: ORA-01017: invalid username/password; logon denied SP2-0751: Unable to connect to Oracle. Exiting SQL*Plus D:\>echo %errorlevel% 1 D:\>sqlplus -L hr/hr@XE @test.sql SQL*Plus: Release 11.1.0.6.0 - Production on Wed Feb 17 08:48:49 2010 Copyright (c) 1982, 2007, Oracle. All rights reserved. Connected to: Oracle Database 10g Express Edition Release 10.2.0.1.0 - Production Disconnected from Oracle Database 10g Express Edition Release 10.2.0.1.0 - Production D:\>echo %errorlevel% 0 D:\>sqlplus -L hr/hr@KO @test.sql SQL*Plus: Release 11.1.0.6.0 - Production on Wed Feb 17 08:52:22 2010 Copyright (c) 1982, 2007, Oracle. All rights reserved. ERROR: ORA-12154: TNS:could not resolve the connect identifier specified SP2-0751: Unable to connect to Oracle. Exiting SQL*Plus D:\>echo %errorlevel% 1
-
How to validate SQL syntax in Application Engine Peoplecode
Hello
Can someone help me to find out How to validate SQL in Application Engine Peoplecode. I just need to validate SQL syntax. If the syntax is wrong, it should save the exception in the log file but engine Apllication should not go WITHOUT success. App Engine should continue with other SQL validation to check the correct syntax and to retrieve values.
Here is given is peoplecode, which is that I currently use.
Thanks in advance.
String local CSG_SQL_ID & sqltext;
Local date & effdt;
Local Boolean & sql_flag = True;
& CSG_SQL_ID = CSG_REP_DIS_AET. CSG_SQL_ID. value;
SQLExec ("SELECT DEV. CST PS_CSG_SQL_TMP, CRAD PS_CSG_REP_AUT_DST SQLTEXT WHERE CSE. CSG_SQL_ID = DEV. CSG_SQL_ID AND CST. EFFDT = DEV. EFFDT AND CST. CSG_SQL_ID =: 1 ", CSG_SQL_ID, & sqltext);
Try
& sql_flag = SQLExec (& sqltext);
If & sql_flag = True Then
& sql = CreateSQL (& sqltext);
Local string SqlString = & sql. Value;
Logger (String (ExtractTablesJob (& SqlString)));
Logger (String (ExtractTablesDept (& SqlString)));
End - If;
catch Exception & sqlerror
MessageBox (0, "", 0, 0, "found Exception");
end - try;Ludi,
I apologize: I remembered wrong. The Select Type must be reselect. I opened a ticket with Oracle on this problem. I hope that maybe they will build better error messaging tools, but we'll see. The real result of the ticket, it is that evolution to select Type of reselect solved my problem.
Remember that when you Reselect it, you need to follow wherever you are. Reselect him running the DoSelect SQL statement every time until it returns no rows. So, you will need a flag turned on the table. You're DoSelect should select only the rows where the transformed flag is N. Then, you must update the line you are dealing with to set the flag turned on Y. In this way, you will pass through the processing of each lines.
Also, just to be clear, I don't think that App Designer will ever "validate" your SQL. It allows the database to do that when you run it. It can be frustrating because up to now it is not telling you that you are developing, but the advantage is that App Designer does not limit you. You can place some SQL you want in your program, and it will transmit to the database. Stored procedures, functions, all work because the App Designer do not validate things specific special platform.
If you wish, you can copy your SQL in the SQLExec to a SQL definition:
SELECT THE DEV. SQLTEXT
OF PS_CSG_SQL_TMP CST.
PS_CSG_REP_AUT_DST SLAG
WHERE CSE. CSG_SQL_ID = DEV. CSG_SQL_ID
AND CSE. EFFDT = DEV. EFFDT
AND CSE. CSG_SQL_ID =: 1You could name MY_AE_SQL.
Then, in your App Engine PeopleCode, you can change the SQLExec in:
SQLExec (SQL. MY_AE_SQL, & CSG_SQL_ID, & sqltext);This will place your SQL in a place that teaches better, but I don't think that it will validate it no more. In my opinion, it makes your code more difficult to read. Someone coming along behind you must open several pieces of code to see what your program does.
The more I watch your program, you want probably to validate and protect the SQL code that is in & sqltext, rather than the SQLExec. If you want it to be dynamic, I don't see what you can do.
You could possibly launch an other App Engine as another process. You can use the object API ProcessRequest to plan the program through the process scheduler. You must pass your dynamic SQL code to the other program through a sort of serial control. In this way each SQL would go as a separate instance in process monitor and would go to success or no success individually. I still think it's too complicated.
I hope these thoughts help. It looks like a difficult task.
Stephen
-
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 -
Call the OBIEE Unix Shell Script
Hi all
Is it possible to make a call to a Unix Shell Script with the framework of the Action of OBIEE.
Thanks in advanceI don't think, but we can go for it instead side BI. Try to transfer the same features side shell script so that the script can identify your report using the tail of the log nqquery and execute the rest of your lines in shell script.
This can done and works as expected. If you identify your report instead of this long logical query at all with my suggestion that you can go for a little keyword.
Score pls help if
-
How to get SQL * more to connect to my database of Apex?
How can I get SQL * more to connect to my database of Apex? By using the username and password I use to connect to Apex does not (ORA-01017). What should I do to connect to my db Apex?
Thank you
KimConnection string is "connect username/password@database".
The analysis schema is a database account, that's why you can log on to SQL * more like that.
This allows to get the database name
select instance_name from v$instance;
And if you forgot the password for the PT
alter user PT identified by 'your_new_password';
Scott
-
Re: Unix shell script to notify if an array has reached a number of lines
Looking to write a script to send an alert notification when an Oracle database table object reaches a certain value of line number. If anyone has the logic "If this while" for a script shell unix would be great.
With the logic of control and check on the table when it reaches the total line number can be added to the script and on-demand via cron.
Thank you.
Thus, you must periodically (how often?) a COUNT (*) on the target table? Is this acceptable overhead?
/Korn Bourne shell scripts can compare numbers and check if one is greater than another. See "-gt" UNIX - Shell basic operators
Hemant K Collette
-
How to make SQL * more count the comment and blank line numbers?
Hello
Parameter Value of the parameter Oracle version Enterprise Edition Release 11.2.0.1.0 - 64 bit OPERATING SYSTEM Linux Fedora Core 17 (X86_64) I would like to know, is it possible to force SQL * Plus to provide the number of the current in the source file line whenever there is an error? I often put in the first line of my script SQLBLANKLINES the VALUE ON that I may be able to put several consecutive blank lines in my code (I do that sometimes, when I find that it is appropriate to make my code more readable or a sequence of instructions which I believe make their logic more comprehensible for the reader of the Group)
Now the problem is that SQL * Plus will ignore these empty lines and whenever there is an error, the line number in the error message does not match the actual line number in the source file, but it seems to be the last non-empty line in the file. Consider the following example:
SET SQLBLANKLINES ON;
DECLARE
var PLS_INTEGER := 10;
BEGIN
var := 20
END;
/In the code above on line 9 (also counting blank lines), there is an error (no semicolon at the end of the var: = 20) but when I run the script
SQL * also, here is the error message I get
SQL > @myscript.sql;
END;
*
ERROR on line 8:
ORA-06550: line 8, column 1:
PLS-00103: encountered the symbol "END" when expected in the following way:
* & = - + ; <>/ is mod remains not rem
< an exponent (*) > <>or! = or ~ = > = < = <>and like2 or
like4 likec between | submultiset of type multiset Member
The symbol ';' was replaced by 'END' continue.
SQL >
As you can see the error message indicates that the error was found on line 8, while in the file, it's really on line 9
As long as the number of lines in the script is limited, this may not be a problem and we can quickly find the actual line number in the code that causes the error, but for a code, including hundreds (or even thousands) of lines and with many comments and blank lines, find line number given by SQL * error message more becomes complicated.
So my question: is it possible to make SQ * more properly draw the line numbers, as they appear in the source file?
Thanks in advance,
Kind regards
Dariyoosh
Hi, Dariyoosh,
The line numbers in error messages are always from the beginning of the statement, but not the file. The back-end which checks the errors and generates the error message, has no idea if this statement has appeared in your file, even if the statement was in a file at all, or if it comes from multiple files, each with its own line 1.
You can divide your scripts into parts, so that the long statements, which may lead to error messages, are each in a separate file, so the statement starts on the line 1 of the file.
For example, you can call a script called fubar.sql, which looks like this:
SET SQLBLANKLINES ON; @@fubar_1
Which calls another script, called fubar_1.sql, located on the same directory as fubar.sql, that looks like this
DECLARE var PLS_INTEGER := 10; BEGIN var := 20 END; /
You never call him directly fubar_1.
-
DBMS_SCHEDULER - trying to create and run a UNIX shell script from Oracle
How can I run Script Shell Unix from Oracle using DBMS_SCHEDULER?
After reading many examples online, I finished the 3 steps below.
Create program, create jobs, run task. On my 3rd stage, I get the following error.
How can I make sure that the work was created?
ORA-27475: "APPS. POSPAY_FILE_CHECK_JOB' must be work
(1) create the program
(2) create jobsBEGIN dbms_scheduler.create_program( program_name => 'POSPAY_FILE_CHECK_PROG', program_type => 'EXECUTABLE', program_action => '/home/ldcgroup/ldccbc/POSPAY_USC2_CHECK.sh', number_of_arguments => 0, enabled => TRUE, comments => 'Test Program' ); END;
(3) the job (not calendar, I'll run this a concurrent request of EBS)BEGIN DBMS_SCHEDULER.CREATE_JOB ( job_name => 'POSPAY_CHECK_FILE_JOB', program_name => 'POSPAY_CHECK_FILE_PROG', enabled => TRUE); END; /
BEGIN DBMS_SCHEDULER.run_job ( job_name => 'POSPAY_FILE_CHECK_JOB'); END; /
Of [documentation | http://download.oracle.com/docs/cd/E11882_01/server.112/e10595/scheduse002.htm#i1009668]
The job is created disabled. You must enable it with DBMS_SCHEDULER.ENABLE before the Scheduler will automatically run it. Jobs are set to be automatically dropped by default after they complete. Setting the auto_drop attribute to FALSE causes the job to persist.
-
Connection with SQL * more is not possible
Hello together,
I have a problem with my database and SQL Plus.
I can't connect to my DB via SQL Plus, I get the error message: > > ORA_12546: TNS: detonation verweigert (Permission denied) < <.
I tried it with several users. When I try to log in to enterprise manager or connecting to the DB through SQL Developer works very well with the user > > sys < <, only the SQL more connection does not work.
It works until yesterday that there are some problems with the DB and the processor and RAM were almost 100% occupied each.
We use the Version 11 g Enterprise Edition Release 11.2.0.1.0 64 bit Production on a Windows Server 2008 R2 Enterprise Server.
I am running SQL Plus, Enterprise Manager and SQL Developer directly on the DB server.
When I start SQL Plus he asks me my username > > enter user name: < < and after that my password: > > password: < <.
A connection as seen in many forums or document on the internet like > > scott/tiger@ORCL < < never worked on my system, which is also confused me.
We have no listener.ora file in the folder: ORACLE_HOME/NETWORK/ADMIN only a sqlnet.ora with line > > SQLNET. AUTHENTICATION_SERVICES = (NTS) < < in it.
Status of the listener:
---------------------------------------------------------------------------------------------------------------------------------------------------------
C:\Windows\System32 > lsnrctl status
LSNRCTL for 64-bit Windows: Version 11.2.0.1.0 - Production on 18 February 2014 12:14:32
Copyright (c) 1991, 2010, Oracle. All rights reserved.
Connection to (ADDRESS = (PROTOCOL = tcp)(HOST=) (PORT = 1521))
STATUS of the LISTENER
------------------------
Alias LISTENER
TNSLSNR for Windows 64-bit version: Version 11.2.0.1.0 - Production
Start date February 18, 2014 10:15:54
Uptime 0 days 1 hour 58 minutes 42 seconds
Draw level off
Security ON: OS Local Authentication
SNMP OFF
O:\app\administrator\diag\tnslsnr\QualisysDbNbg\listener\alert\log.XML log listener
Summary of endpoints listening...
(DESCRIPTION = (ADDRESS = (PROTOCOL = tcp)(HOST=QualisysDbNbg) (PORT = 1521)))
Summary of services...
Service "orcl" has 1 instance (s).
Instance "orcl", State LOAN, has 1 operation for this service...
The command completed successfully
C:\Windows\System32 >
---------------------------------------------------------------------------------------------------------------------------------------------------------
I hope someone can help me with this problem.
Thank you you very much in forward for your answerand greetings
Matthias
The sys user must connect as sysdba
have you tried
sqlplus 'sys@ORCL as sysdba'
or
sqlplus 'sys/yoursyspwd@ORCL as sysdba'
the first command should work without password for all users group ORA_DBA.
Scott, the user cannot also exists in your database.
-
Can I connect to SQL * more as SYS after connecting as a user and then run a GRANT?
Oracle 11 g 2
Linux RHEL 6.3
SQL * Plus 11.2.0.2 on Windows 7
------------------------------------------------
I am running a script SQL through SQL * more connected as "DOE, JOHN".
In the SQL script, I need to connect as SYS to make a GRANT EXECUTE on a SYS package (e.g. GRANT EXECUTE ON DBMS_CRYPTO to JOHN;).
But it fails with the following error:
GRANT EXECUTE ON TO JOHN DBMS_CRYPTO
*
ERROR on line 1:
ORA-01917: user or role 'JOHN' does not existBut of course, 'JOHN' are. The rest of the SQL script is running "DOE, JOHN" without any problem.
The code segment of SQL script in question is:
connect sys/password as sysdba
GRANT EXECUTE ON DBMS_CRYPTO TO ROYSECITYDATA; <-fails here
to connect/DOEPlease advise on what my being the issue.
tx103108 wrote:
I connect to a remote database. All dbs distance have the same instance name as they are all images. I see where you're going (I think). Should I try
I'll try to connect sys/password@MYDB
Sounds like a plan... (the instance_name returned with what you expected? or something else?)
-
Hello all;
I know this question has been asked several times but I'm still a little confused. I installed oracle database 10g express edition on my computer for the practice of the school. It works fine if I go to the homepage of database icon... However, there is another icon which evokes SQL * who I am trying to use to run sql on my computer but nothing happens when I type in a simple sql statement. I was just wondering how to make sql * more correctly installed on my pc so that I can use PL/SQL instructions for the code, packages, and triggers as well.You must copy the entry in the tnsnames.ora file for the installation of xe, which is located in
C:\oraclexe\app\oracle\product\11.2.0\server\network\ADMIN
on WindowsXE = (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST =host.xx.xxx.net)(PORT = 1521)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = XE) ) )
and edit the tnsnames.ora file from where you are running more than SQL.
For example, I have a client installed 10g, which has its own file tnsnames.ora but I also 11g XE installed.
This entry must exist in the customer 10g tnsnames.ora file if I want to connect with the version of windows
SQL Plus to Database 11g XE.Moreover, why don't you upgrade to 11g xe?
http://www.Oracle.com/technetwork/database/Express-Edition/downloads/index.htmlThe final version was released earlier this month.
-
SQL * more the 'timing' in SQL Developer command
I installed SQL Developer version 4.1.1.19. In the sql worksheet, how can I use SQL * more order 'timing' in a script to see a time elapsed SQL? The "Timing" on 'set' did not return any info after running SQL, and 'calendar beginning mon_timer' back 'command Timing is obsolete. Help, please.
Thank you
- As you can see, there is no calendar information in the script output log.
- Then I tried on the discussion forum, found it can be enabled in "tool > preference > Database > startup script" and set as startup script:
Set serveroutput on
set timing on
- However, 2 questions are:
- the calendar that he returned is NOT the elapsed time of my stored procedure to run. He simply choose the 2 time points its time, before and not after MS point run. Set timing on is therefore not a solution for me.
- He did not follow the instructions in the startup script. After that I put the calendar in the startup script, stop & restart SQL Developer, same laptop charging, timing still on. The only way to turn off now is to configure it to NOT use
any startup script.
- Then I developed my own coding as a solution:
3. control of the COIL
VAR bv_start_ts VARCHAR2 (30)
VAR bv_end_ts VARCHAR2 (30)
VAR bv_elps_ts VARCHAR2 (30)
DECLARE
v_start_ts VARCHAR2 (30);
BEGIN
SELECT TO_CHAR (SYSTIMESTAMP, 'yyyymmddfxDyhh24miss.ff6') INTO v_start_ts FROM DUAL;
: bv_start_ts: = v_start_ts;
END;
/
IMPRESSION bv_start_ts
EXEC pmsmmi.rpt.rpt_ethncty_race_smry (15);
DECLARE
v_end_ts VARCHAR2 (30);
BEGIN
SELECT TO_CHAR (SYSTIMESTAMP, 'yyyymmddfxDyhh24miss.ff6') INTO v_end_ts FROM DUAL;
: bv_end_ts: = v_end_ts;
END;
/
IMPRESSION bv_end_ts
EXEC: bv_elps_ts: = TO_CHAR (TO_TIMESTAMP (: bv_end_ts, 'yyyymmddfxDyhh24miss.ff6')-TO_TIMESTAMP (: bv_start_ts, 'yyyymmddfxDyhh24miss.ff6'), 'hh:mi:ss.ff6');
IMPRESSION bv_elps_ts
SPOOL OFF
- Then I got what I want, the answer is in the 'PRINT ': bv_elps_ts
SQL > VAR bv_start_ts VARCHAR2 (30)
SQL > VAR bv_end_ts VARCHAR2 (30)
SQL > VAR bv_elps_ts VARCHAR2 (30)
SQL > DECLARE
v_start_ts VARCHAR2 (30);
BEGIN
SELECT TO_CHAR (SYSTIMESTAMP, 'yyyymmddfxDyhh24miss.ff6') INTO v_start_ts FROM DUAL;
: bv_start_ts: = v_start_ts;
END;
/
PL/SQL procedure successfully completed.
Elapsed time: 00:00:00.031
SQL > PRINT bv_start_ts
BV_START_TS
-----------
20150702Thu112617.775545
SQL > EXEC pmsmmi.rpt.rpt_ethncty_race_smry (15)
PL/SQL procedure successfully completed.
SQL > DECLARE
v_end_ts VARCHAR2 (30);
BEGIN
SELECT TO_CHAR (SYSTIMESTAMP, 'yyyymmddfxDyhh24miss.ff6') INTO v_end_ts FROM DUAL;
: bv_end_ts: = v_end_ts;
END;
/
PL/SQL procedure successfully completed.
Elapsed time: 00:00:00.062
SQL > PRINT bv_end_ts
BV_END_TS
---------
20150702Thu112630.805786
SQL > EXEC: bv_elps_ts: = TO_CHAR (TO_TIMESTAMP (: bv_end_ts, 'yyyymmddfxDyhh24miss.ff6')-TO_TIMESTAMP (: bv_start_ts, 'yyyymmddfxDyhh24miss.ff6'), 'hh:mi:ss.ff6')
PL/SQL procedure successfully completed.
SQL > PRINT bv_elps_ts
BV_ELPS_TS
----------
+ 00:00:13.030241000 000000
SQL > SPOOL OFF
-
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.
-
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
Maybe you are looking for
-
Wireless more than Seagate and office
Hello Recently, I bought a Seagate Wireless Plus to use with my Ipad2. I need mainly to be used for a large number of Word and Excel docs I have is that I use when I am away from home. I noticed that whenever I try to open a document using the Seagat
-
The site that I always worked before with cams, and I was just there before the update. After that Firefox is updating the cams would work no more - neither I nor others. It is empty. How to fix this or go back to the old version of Firefox? Thank yo
-
For my Satellite 1130 motherboard drivers
Hello My satellite 1130-Z24 died, with a main board failure. I replaced the Board with one, I got from E - Bay, which is not the same exact model, but I don't know which. The keyboard works except the arrows and the touchpad do not work, even if its
-
Well when I transfer my videio and/or photos from my camera sd card, when the transfer images will open in Windows Live Photo Gallery with pictures showing as a large icon. My photos are stored on my HP-Pavilion(E:).) drive But after that when I clic
-
Hi all Is there anyway that I can balance workloads on both routers. I have an ASA with two attached routers each router has two instances of HSRP runs on each with its own IP address, each router is the main for one of the instances of HSRP. If ther