03-16-2014
Quote:
Originally Posted by
Ditto
Understood, however, the only issue I was trying point out was that because of that bit-wise fun, depending on the error code sent back, it *could* come back as 0, despite throwing an error.
Yes that is correct since error codes with all zeros in their LS byte would be interpreted as success because $? evaluates to zero...
Quote:
Originally Posted by
Ditto
(ie if Oracle throws ORA-00256, even with the WHENEVER logic there, it'll pass error code 256 back to unix, get mashed to 0, and say "oh hey, everything's fine"
So unfortunately, it's hard to rely on that. Just have to be careful.
ORA-00256 is
0x100 with its least significant byte being zero meaning that $? is zero and for all scenarios where the lsb is zero...perhaps the only workaround is to have a hard-coded value i.e.
whenever sqlerror exit 1 and redirect all stdout/stderr to a logfile and after the sqlplus sessions ends...peek inside to see the exact error that caused the abend or wait until the shell is fixed so that no bits are truncated...
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
I'm having a question about for loops. (bash)
I have the following for example:
for file in `ls *.txt`
do
read file ...
done
Now when there is a file present there is no problem, now when there is no file present I get the following output in my standard mail box : "No such... (4 Replies)
Discussion started by: lumdev
4 Replies
2. Shell Programming and Scripting
Hello,
I need some help from the experts on PL/SQL and Shell scripting. I need a shell script that runs a PL/SQL procedure and gets the values returned from the PL/SQL procedure into the shell variables. The PL/SQL procedure returns multiple values.
I was able to assign a single return value... (1 Reply)
Discussion started by: Veera_Raghav
1 Replies
3. Shell Programming and Scripting
Hi all
Im trying to call a PL SQl block from a ksh file like this :
sqlplus -s $DB_USERID/$DB_PASSWD@$DB_NAME<<eof
whenever SQLERROR exit 1
var varError VARCHAR2(200);
exec ODAS_BATCH_JOBS_RETRIEVE.retrieve_user_info(:varError);
eof
If there is a error then varError will return a... (1 Reply)
Discussion started by: Sam123
1 Replies
4. Shell Programming and Scripting
Hi Everyone,
How to use catch, try and final in bash script?
what is (SQLException e) and (IOException e), who to conver this 2 function to bash script?
Thank you (8 Replies)
Discussion started by: ryanW
8 Replies
5. Shell Programming and Scripting
I tried searching the forum for similar posts but its closed now.
Would appreciate any help on this.
I am trying to capture return value from a select query into a variable.
DB is Oracle
I am able to spool it to a file but I donot intend to use it.
Here is my script that does not work ;)
I... (27 Replies)
Discussion started by: monie2717
27 Replies
6. Programming
I have some unstable mistake in my program and out-of-idea how to catch it.
I am looking for advice with a way to work it out!
I have in a pretty complicated program (but one source file) set of int-counters - 15, if exactly.
Lately, on final printout I have inpossible value (I am... (3 Replies)
Discussion started by: alex_5161
3 Replies
7. Shell Programming and Scripting
We have script running to SFTP some file to the remote server. The problem is the SFTP transfer returns an exit code of 0 even if there is permission error during file transfer, connection refuse (like when sftp server is down), thus, returning the status of the script as success.
I was thinking... (3 Replies)
Discussion started by: The One
3 Replies
8. Shell Programming and Scripting
I need help in the following script. I want to grep the sql errors insert into the error table and exit the shell script if there is any error, otherwise keep running the scripts.
Here is my script
#!/bin/csh -f
source .orapass
set user = $USER
set pass = $PASS
cd /opt/data/scripts
echo... (2 Replies)
Discussion started by: allinshell99
2 Replies
9. Shell Programming and Scripting
Hi Experts,
Problem summary :
I am facing the below problem on huge files when the disk is getting full on the half way through the execution.
If the disk was already full , the commands fail & everything is fine.
Sample Code :
head_rec_data_file=`head -1 sample_file.txt`
cat... (9 Replies)
Discussion started by: Pruthviraj_shiv
9 Replies
10. Shell Programming and Scripting
Hello,
I have a main.sql file which runs around 5-6 .sql files and each .sql file is spooling it in separate text file.
In my shell script I am appending main.sql to one of my log file but I am not able to get detailed error if anything fails from those 5-6 .sql files. Those errors are... (1 Reply)
Discussion started by: sp92
1 Replies
LEARN ABOUT PHP
oci_password_change
OCI_PASSWORD_CHANGE(3) OCI_PASSWORD_CHANGE(3)
oci_password_change - Changes password of Oracle's user
SYNOPSIS
bool oci_password_change (resource $connection, string $username, string $old_password, string $new_password)
DESCRIPTION
resource oci_password_change (string $dbname, string $username, string $old_password, string $new_password)
Changes password for user with $username.
The oci_password_change(3) function is most useful for PHP command-line scripts, or when non-persistent connections are used throughout
the PHP application.
PARAMETERS
o $connection
- An Oracle connection identifier, returned by oci_connect(3) or oci_pconnect(3).
o $username
- The Oracle user name.
o $old_password
- The old password.
o $new_password
- The new password to be set.
o $dbname
- The database name.
RETURN VALUES
Returns TRUE on success or FALSE on failure.
EXAMPLES
Example #1
oci_password_change(3) example changing the password of an already connected user
<?php
$dbase = 'localhost/orcl';
$user = 'cj';
$current_pw = 'welcome';
$new_pw = 'geelong';
$c = oci_pconnect($user, $current_pw, $dbase);
oci_password_change($c, $user, $current_pw, $new_pw);
echo "New password is : " . $new_pw . "
";
?>
Example #2
oci_password_change(3) example of connecting and changing the password in one step
<?php
$dbase = 'localhost/orcl';
$user = 'cj';
$current_pw = 'welcome';
$new_pw = 'geelong';
$c = oci_pconnect($user, $current_pw, $dbase);
if (!$c) {
$m = oci_error();
if ($m['code'] == 28001) { // "ORA-28001: the password has expired"
// Login and reset password at the same time
$c = oci_password_change($dbase, $user, $current_pw, $new_pw);
if ($c) {
echo "New password is : " . $new_pw . "
";
}
}
}
if (!$c) { // The original error wasn't 28001, or the password change failed
$m = oci_error();
trigger_error('Could not connect to database: '. $m['message'], E_USER_ERROR);
}
// Use the connection $c
?>
NOTES
Note
Changing the password either with this function or directly in Oracle should be done carefully. This is because PHP applications
may continue to successfully reuse persistent connections by authenticating with the old password. The best practice is to restart
all web servers whenever the user password is changed.
Note
If upgrading the Oracle client libraries or the database from a release prior to 11.2.0.3 to version 11.2.0.3 or higher, oci_pass-
word_change(3) may give the error "ORA-1017: invalid username/password" unless both client and server versions are upgraded at the
same time.
Note
The second oci_password_change(3) syntax is available since OCI8 version 1.1.
Note
In PHP versions before 5.0.0 you must use ocipasswordchange(3) instead. This name still can be used, it was left as alias of
oci_password_change(3) for downwards compatability. This, however, is deprecated and not recommended.
PHP Documentation Group OCI_PASSWORD_CHANGE(3)