comparing the null values in the unix

hi all,

iam new to this forum.i have to submit the script EOD.so please help me.

my requirement is to compare two null values..iam trying to compare two null values :One null value output of the storedprocedure and another iam giving spaces in script.

it is giving the error
DTLTRD_VALD_ACCT_CW_FILE.sh: line 215: [: =: unary operator expected

Thanx in Advance.
Chandu.

Hi,

Not sure why you are trying to compare null values. :confused:

I would suggest, you create a function & make it return "0" if success.
Then you can check for "ZERO" instead of any other value.

Hope this helps :slight_smile:

its a client requirement.already all the stored procedures are created iam using those stored procedures.the return value is used some where else in the script if it retuns not a null value

Would like to see the script & place where error is coming...

Thanks

Hi,

I assume that its a oracle stored procedure, can you clarify the following points?

How can a stored procedure return any value? u mean to say tat ur using an OUT parameter and u wanna check whether it contains null value?

Is it possible to post ur script and specify ur requirement?

This was the procedure declaration in unix script

Lkp_Trd_Acct()
{
#connecting to oracle database and inserting a row into btch_ctrl and getting the sequence value and
#storing it into the variable VALUE
VALUE=`sqlplus -silent $DbUserName/$DbPassword@$DbSchema <<END >$PathOfTempLstFile/TrdAcctSqlLog
set serveroutput on
set pagesize 0
set feedback off
set verify off
set heading off
set echo off
variable Acct_id varchar2;
variable curr_cfdc_parm_typ_cd number;
variable curr_org_id number;
exec dtstg.lkp_trd_acct_prc('$1','$2',$3,$4,$5,$6,:Acct_id,:curr_cfdc_parm_typ_cd,:curr_org_id);
print :Acct_id;
exit;
END`

This was the call of storedproc

Lkp_Trd_Acct $NewAcctNbr_Lk $TrNbr_Lkp $Cty_Geo_Ref_Id_Us $BatchID 0 $CD_VAL_ID_PRCS_STEP_LOD_TRD_ACCT

it will stored this value in log
AcctID=`cut -f1 $PathOfTempLstFile/TrdAcctSqlLog

iam storing the return value into the variable AcctID.

then i am comparing that value with the null

if [ AcctID = " "]--- iam getting the error in this line
then
exit 0
else
........
fi

(1) Check the value of "Acct_id" in procedure: dtstg.lkp_trd_acct_prc.
This is stored in your log $PathOfTempLstFile/TrdAcctSqlLog

exec dtstg.lkp_trd_acct_prc('$1','$2',$3,$4,$5,$6,:Acct_id,:curr_cfdc_parm_typ_cd,:curr_org_id);
print :Acct_id;

(2) Echo value of $AcctID after the below statement

AcctID=`cut -f1 $PathOfTempLstFile/TrdAcctSqlLog`

echo $AcctID

(3) Need to change the below.. you need to use $AcctID & based on
point(1) you need to change the condition

if [ AcctID = " "]--- iam getting the error in this line

Hope this helps :slight_smile:

change the if condition to

if [ -n "$AcctID" ]..

hope this helps

i placed $ in script i forgot to place here :slight_smile: wat the -n stands for

tests whether the variable contains something

You can use also :

if [ x"$AcctID" = x ] ...

Depending on the shell used you could use:
[[ -n "${AcctID}" ]]
[[ "x${AcctID}" == 'x' ]]
[[ "${AcctID}" == '' ]]
While the last one you should avoid.