Oracle OCI programming returning null value into define variable [message #638663] |
Wed, 17 June 2015 04:26 |
clancypc
Messages: 36 Registered: December 2006
|
Member |
|
|
Hi,
I have a query that returns a value into a define variable, but if there is no value in the database for that field it inserts null. On Solaris this works fine, but I have migrated my code to Red Hat and it is behaving differently. The code is:
if ( RtrnValue == OCI_NO_DATA )
{
return (FALSE);
}
else if ( RtrnValue == OCI_SUCCESS )
{
switch (Migrated)
{
case 'Y':
/* This cli is marked as migrated, so convert it as normal */
strcpy( CliRec->AccountNumber, Account );
return (TRUE);
case 'N':
/* I dont think that this will happen, but it potentially could
** If it does then update the cli, set the migrated field to yes */
default:
/* The value should come through as null if the migrated field is not set
** hopefully this will catch null values */
strcpy( CliRec->AccountNumber, Account );
return (FALSE);
}
}
else if ( Migrated == NULL )
{
strcpy( CliRec->AccountNumber, Account );
return (FALSE);
}
else
{
check_err( OraErrorHandlePtr, RtrnValue);
return (FALSE);
}
What predominently happens is the code falls through to the:
else if Migrated == NULL
statement and executes that statement and returns FALSE, however on Red Hat it does not recognise that Migrated == NULL and falls through to the check_err statement which then prints out the message:
ERROR - ORA-01405: fetched column value is NULL
So the value is NULL but as far as Red Hat is considered it isnt. Any ideas anybody?
Thanks
Peter
|
|
|
|
|