473,395 Members | 1,568 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

case issue in fetchrow_hashref

Version Info
DBI 1.48
DBD Driver for DB2 UDB: 0.78
DB2 8.2.3
Perl 5.6.1

8 my $sql = "select start_time , max(seqnum) as num_tapes
9 from table(admin_list_hist()) as lh
10 where operation = 'B'
11 group by start_time " ;
12
13 my $sth = $DBH->prepare($sql);
14 $sth->execute() or die "can not execute" ;
15 while (my $v_data = $sth->fetchrow_hashref() ) {
16 my $startime = $v_data->{'START_TIME'} ;
17 my $num_tapes = $v_data->{'NUM_TAPES'} ;
18 print "|$startime|$num_tapes|\n" ;
19 }

It seems fetchrow_hashref converts column name into upper case even
though
the select statement uses the column name in lower case. When I wrote
START_TIME
as start_time in line 16 , I could not get any data.

Is this an accepted and documented behaviour of DBI with DB2?

Thanks.

Oct 26 '06 #1
2 2078
dc********@aim.com wrote:
Version Info
DBI 1.48
DBD Driver for DB2 UDB: 0.78
DB2 8.2.3
Perl 5.6.1

8 my $sql = "select start_time , max(seqnum) as num_tapes
9 from table(admin_list_hist()) as lh
10 where operation = 'B'
11 group by start_time " ;
12
13 my $sth = $DBH->prepare($sql);
14 $sth->execute() or die "can not execute" ;
15 while (my $v_data = $sth->fetchrow_hashref() ) {
16 my $startime = $v_data->{'START_TIME'} ;
17 my $num_tapes = $v_data->{'NUM_TAPES'} ;
18 print "|$startime|$num_tapes|\n" ;
19 }

It seems fetchrow_hashref converts column name into upper case even
though
the select statement uses the column name in lower case. When I wrote
START_TIME
as start_time in line 16 , I could not get any data.

Is this an accepted and documented behaviour of DBI with DB2?
This is documented behavior of ANSI SQL. If you want to preserve case
you need to double-quote when you create and use the column.

Cheers
Serge
--
Serge Rielau
DB2 Solutions Development
IBM Toronto Lab

IOD Conference
http://www.ibm.com/software/data/ond...ness/conf2006/
Oct 26 '06 #2
Ian
dc********@aim.com wrote:
Version Info
DBI 1.48
DBD Driver for DB2 UDB: 0.78
DB2 8.2.3
Perl 5.6.1

8 my $sql = "select start_time , max(seqnum) as num_tapes
9 from table(admin_list_hist()) as lh
10 where operation = 'B'
11 group by start_time " ;
12
13 my $sth = $DBH->prepare($sql);
14 $sth->execute() or die "can not execute" ;
15 while (my $v_data = $sth->fetchrow_hashref() ) {
16 my $startime = $v_data->{'START_TIME'} ;
17 my $num_tapes = $v_data->{'NUM_TAPES'} ;
18 print "|$startime|$num_tapes|\n" ;
19 }

It seems fetchrow_hashref converts column name into upper case even
though
the select statement uses the column name in lower case. When I wrote
START_TIME
as start_time in line 16 , I could not get any data.

Is this an accepted and documented behaviour of DBI with DB2?
Yes. See the FetchHashKeyName attribute for your handle. The default
for DBI is to give you what the database returns, but you can force
DBI to convert to either upper or lower case.

DB2 folds all names to upper case, unless you are explicit:

select max_seqnum as num_tapes -- NUM_TAPES
select max_seqnum as "Num_Tapes" -- Num_Tapes

Beware of using mixed case in your database, it quickly becomes a PITA.


Oct 26 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

32
by: Elliot Temple | last post by:
Hi I have two questions. Could someone explain to me why Python is case sensitive? I find that annoying. Also, why aren't there multiline comments? Would adding them cause a problem of some...
4
by: semovrs | last post by:
Hello, everyone! I would appreciate any input or advice on the following quite simple issue: If I search through a file list using grep -E '.*$' it will not pull files ending in JPG and files...
10
by: Lakshmi Narayanan.R | last post by:
Hi Experts, Using keyword "To" in select case giving error.The following code is got from www.microsrosoft.com itself. What is the wrong with this?. <% Dim Number1 Number1 = 7 ' Initialize...
761
by: Neo-LISPer | last post by:
Hey Recently, I researched using C++ for game programming and here is what I found: C++ game developers spend a lot of their time debugging corrupted memory. Few, if any, compilers offer...
7
by: Lauren Quantrell | last post by:
Is there any speed/resource advantage/disadvantage in using Select Case x Case 1 Case 2 etc. many more cases... End Select VS.
16
by: ME | last post by:
In C# the following code generates a compiler error ("A constant value is expected"): public void Test(string value) { switch (value) { case SimpleEnum.One.ToString(): MessageBox.Show("Test...
110
by: alf | last post by:
Hi, is it possible that due to OS crash or mysql itself crash or some e.g. SCSI failure to lose all the data stored in the table (let's say million of 1KB rows). In other words what is the worst...
7
by: Kurt | last post by:
Hi. I have a c++ project that is basically a set of implementation hiding classes, so that we can convert a static lib with a lot of dependancies into a dynamic lib with less dependancies, so that...
11
by: Rafe | last post by:
Hi, I'm working within an application (making a lot of wrappers), but the application is not case sensitive. For example, Typing obj.name, obj.Name, or even object.naMe is all fine (as far as...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.