Skip to main content

I am attempting to convert a system from using DB2 to allow ODBC access so that a customer can have an alternative to DB2.

So far I have discovered that I need to remove 'IN SHARE MODE' from the CONNECT statements. Not sure what, if any effect this may have just yet.

My next problem is that Some items seem to be held in the database as a char(x) character field but they are read into a smaller PIC X(y) where y is less than x. Under DB2 this appears to be acceptable and no error is returned. Under ODBC (linking to the same DB2 database) I am receiving a Sql Error of 1. This is a warning and using Netexpress I have stepped into the code and found the issue.

Unfortunately, the many different programs have the following line following a SQL statement:

IF SQLCODE = 0

     PERFORM success-oper


So, my question is, am I going to have to amend all of the programs (no big deal to be honest as we have utilities to do this) or is there some kind of option to ignore these errors?


Many thanks


Ian

I am attempting to convert a system from using DB2 to allow ODBC access so that a customer can have an alternative to DB2.

So far I have discovered that I need to remove 'IN SHARE MODE' from the CONNECT statements. Not sure what, if any effect this may have just yet.

My next problem is that Some items seem to be held in the database as a char(x) character field but they are read into a smaller PIC X(y) where y is less than x. Under DB2 this appears to be acceptable and no error is returned. Under ODBC (linking to the same DB2 database) I am receiving a Sql Error of 1. This is a warning and using Netexpress I have stepped into the code and found the issue.

Unfortunately, the many different programs have the following line following a SQL statement:

IF SQLCODE = 0

     PERFORM success-oper


So, my question is, am I going to have to amend all of the programs (no big deal to be honest as we have utilities to do this) or is there some kind of option to ignore these errors?


Many thanks


Ian

The SQL code of 1 means that a warning has occurred and that you should check the settings of the SQLWARN flags to see which one has occurred.

The one that you are running into is:

SQLWARN1 "W" indicates that data was truncated on output to a character host variable.

I do not see that a directive is available that would turn off this warning reporting behavior.

Thanks.


I am attempting to convert a system from using DB2 to allow ODBC access so that a customer can have an alternative to DB2.

So far I have discovered that I need to remove 'IN SHARE MODE' from the CONNECT statements. Not sure what, if any effect this may have just yet.

My next problem is that Some items seem to be held in the database as a char(x) character field but they are read into a smaller PIC X(y) where y is less than x. Under DB2 this appears to be acceptable and no error is returned. Under ODBC (linking to the same DB2 database) I am receiving a Sql Error of 1. This is a warning and using Netexpress I have stepped into the code and found the issue.

Unfortunately, the many different programs have the following line following a SQL statement:

IF SQLCODE = 0

     PERFORM success-oper


So, my question is, am I going to have to amend all of the programs (no big deal to be honest as we have utilities to do this) or is there some kind of option to ignore these errors?


Many thanks


Ian

Hi Chris

Thanks for your response.

I know ultimately that the reason is probably sloppiness, but I don't know why this is happening when I compile for ODBC but not when I use DB2?

Regards


I am attempting to convert a system from using DB2 to allow ODBC access so that a customer can have an alternative to DB2.

So far I have discovered that I need to remove 'IN SHARE MODE' from the CONNECT statements. Not sure what, if any effect this may have just yet.

My next problem is that Some items seem to be held in the database as a char(x) character field but they are read into a smaller PIC X(y) where y is less than x. Under DB2 this appears to be acceptable and no error is returned. Under ODBC (linking to the same DB2 database) I am receiving a Sql Error of 1. This is a warning and using Netexpress I have stepped into the code and found the issue.

Unfortunately, the many different programs have the following line following a SQL statement:

IF SQLCODE = 0

     PERFORM success-oper


So, my question is, am I going to have to amend all of the programs (no big deal to be honest as we have utilities to do this) or is there some kind of option to ignore these errors?


Many thanks


Ian

OpenESQL is based on the ANSI SQL Standards and does not include some of the extensions that other proprietary precompilers may offer.

This may cause a difference in behavior that requires source code modification when moving from products such as the DB2 ECM using cobsql or Oracle using Pro*COBOL.

What you have found is one of those extensions in DB2 that behaves differently in OpenESQL.


I am attempting to convert a system from using DB2 to allow ODBC access so that a customer can have an alternative to DB2.

So far I have discovered that I need to remove 'IN SHARE MODE' from the CONNECT statements. Not sure what, if any effect this may have just yet.

My next problem is that Some items seem to be held in the database as a char(x) character field but they are read into a smaller PIC X(y) where y is less than x. Under DB2 this appears to be acceptable and no error is returned. Under ODBC (linking to the same DB2 database) I am receiving a Sql Error of 1. This is a warning and using Netexpress I have stepped into the code and found the issue.

Unfortunately, the many different programs have the following line following a SQL statement:

IF SQLCODE = 0

     PERFORM success-oper


So, my question is, am I going to have to amend all of the programs (no big deal to be honest as we have utilities to do this) or is there some kind of option to ignore these errors?


Many thanks


Ian

Chris

Is it 'behaving different' or is it just a different error number?

Ian


I am attempting to convert a system from using DB2 to allow ODBC access so that a customer can have an alternative to DB2.

So far I have discovered that I need to remove 'IN SHARE MODE' from the CONNECT statements. Not sure what, if any effect this may have just yet.

My next problem is that Some items seem to be held in the database as a char(x) character field but they are read into a smaller PIC X(y) where y is less than x. Under DB2 this appears to be acceptable and no error is returned. Under ODBC (linking to the same DB2 database) I am receiving a Sql Error of 1. This is a warning and using Netexpress I have stepped into the code and found the issue.

Unfortunately, the many different programs have the following line following a SQL statement:

IF SQLCODE = 0

     PERFORM success-oper


So, my question is, am I going to have to amend all of the programs (no big deal to be honest as we have utilities to do this) or is there some kind of option to ignore these errors?


Many thanks


Ian

I just tested this here against DB2 and I find that DB2 will return the same warning flags in the SQLCA for data truncation (SQLWARN0 and SQLWARN1 = W) but sqlcode will = 0 instead of 1 which is returned when OpenESQL is used.

This means that DB2 is also treating the exception as a warning but it sets the sqlcode return value differently.