Focal Point
[SOLVED] column names in sql passthru upper/lower case

This topic can be found at:
https://forums.informationbuilders.com/eve/forums/a/tpc/f/7971057331/m/5317068096

October 18, 2018, 03:05 AM
Martin vK
[SOLVED] column names in sql passthru upper/lower case
We are migrating from DB2 database to SQL Server, actually to Azure SQL through MSODBC adapter.
An issue we are facing is that our sql passthru behaves differently in column names. Often our sql passthru is written in lower case, like
SQL DB2
select column1 from table1
;
TABLE FILE SQLOUT
PRINT *
ON TABLE HOLD AS HOLD000
END
-RUN

With DB2 passthru we could afterwards give an uppercase TABLE request:
TABLE FILE HOLD000
PRINT COLUMN1
END

Changing it to MSODBC it now gives error
(FOC258) FIELDNAME OR COMPUTATIONAL ELEMENT NOT RECOGNIZED: COLUMN1

If I change it to lowercase column1 it works.
It would be quite a work changing the sql passthru everywhere to uppercase, so I wondered is there somewhere an adapter setting to arrange that it returns upper case column names, or at least as an alias? Or would someone have a different (easy) solution

Martin.

This message has been edited. Last edited by: FP Mod Chuck,


WebFocus 8206M, iWay DataMigrator, Windows, DB2 Windows V10.5, MS SQL Server, Azure SQL, Hyperstage, ReportCaster
October 18, 2018, 09:10 AM
Martin vK
For DB2 the ?FF HOLD000 gives:
FILENAME= HOLD000
COLUMN1 E01 A20

For MSODBC the ?FF HOLD000 gives:
FILENAME= HOLD000
column1 E01 A20

I think I also know the reason. It does not have to do with WebFocus and adapter settings. But DB2 is not case sensitive (at least not our installation) and in SQL Server we do use a case sensitive collation. And especially in migrating our database views, which are mainly defined in lower case create view scripts, SQL server has created column names in lower cases, whereas DB2 had made them uppercase column names.

Nevertheless is there some setting I can tell WebFocus or the MSODBC adapter that with sql passthru it should Always return upper case field names?


WebFocus 8206M, iWay DataMigrator, Windows, DB2 Windows V10.5, MS SQL Server, Azure SQL, Hyperstage, ReportCaster
October 18, 2018, 09:24 AM
BabakNYC
Yeah I just tested it in SQL Server and the default is to create the hold master files with mixed case column names. I don't see any settings in the adapter manual that'll let you change that. Is creating the SQL Server tables with uppercase column names an option? I know that's a crazy question but if this is a migration from one system to another, then wouldn't it be reasonable to have identical DDLs for all the SQL tables in the target platform so you don't have to remediate all the code?


WebFOCUS 8206, Unix, Windows
October 18, 2018, 09:27 AM
BabakNYC
I haven't tested this but maybe you could work around the problem using SET ASNAME. Check out the doc for the behaviors you can get out of it. Might be worth a test.

https://webfocusinfocenter.inf...ang/source/out94.htm


WebFOCUS 8206, Unix, Windows
October 18, 2018, 10:39 AM
Wep5622
quote:
Originally posted by Martin vK:
in SQL Server we do use a case sensitive collation.


Apparently, in SQL server, identifier case sensitivity is an optional server feature and this can be queried. Possibly, the WF adapter uses that information to decide how to behave.

If possible, test what happens if you turn off SQL server's case sensitivity.

quote:

SQL server has created column names in lower cases, whereas DB2 had made them uppercase column names.


That's not entirely accurate. DB2 column names are case insensitive. They "fold" to upper case when presented, but you can address them in any case, upper, lower or mixed.


WebFOCUS 8.1.03, Windows 7-64/2008-64, IBM DB2/400, Oracle 11g & RDB, MS SQL-Server 2005, SAP, PostgreSQL 11, Output: HTML, PDF, Excel 2010
: Member of User Group Benelux :
October 18, 2018, 11:47 AM
Martin vK
I can not change the case sensitivity in SQL Server, that is not my decision, I have to live with that.

We did find a way to get around it, preventing we have to change all our sql passthru. We made following standard routine to add define's in upper case.
-DEFAULTH &SQLOUT_HOLDFILE = 'HOLD000';

CHECK FILE &SQLOUT_HOLDFILE HOLD AS TEMPHOLD

FILEDEF INCLUDE_DEFINE DISK include_define.fex (APPEND
-RUN

-WRITE INCLUDE_DEFINE DEFINE FILE &SQLOUT_HOLDFILE ADD

TABLE FILE TEMPHOLD
  PRINT
    COMPUTE LINE/A1200 = UPPER(FIELDNAME) || '/' || FORMAT || '=' || FIELDNAME || ';' ;
  ON TABLE HOLD AS INCLUDE_DEFINE FORMAT ALPHA
  ON TABLE SET HOLDLIST PRINTONLY
END
-RUN

-WRITE INCLUDE_DEFINE END
-RUN

-INCLUDE include_define

We can include this fex where we need it.


WebFocus 8206M, iWay DataMigrator, Windows, DB2 Windows V10.5, MS SQL Server, Azure SQL, Hyperstage, ReportCaster