IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Select Query


IBM Mainframe Forums -> DB2
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
kvivek

New User


Joined: 09 May 2005
Posts: 51
Location: Singapore

PostPosted: Sat Jul 09, 2005 5:37 am
Reply with quote

Hi All,

I faced a strange problem in select query. In my program I tried to select all the columns from a particular table in the order other than the table's column sequence.

For example Table1 is defined with the following column sequence Var1, Var2 , Var3 and my selection order is Va2, Var1, Var3. During execution Value of Var1 is moved to Var2 and Value of Var2 is moved to Var1. (which is the table's column sequence). In INTO I have given the dclgen variables in the selection order only(i.e. DCLVar2, DCLVar1 and DCLVar3).

Table has around 60 columns. This happens only if i select all the fields and I tried selecting some of the fields (In different order) and got the proper result.

What could be the reason for this? Is this due to Installation problem??

Thanks,
Vivek
Back to top
View user's profile Send private message
jayesh_g

New User


Joined: 03 Mar 2004
Posts: 23

PostPosted: Sat Jul 09, 2005 10:33 pm
Reply with quote

Well......did you use
Code:
SELECT VAR2, VAR1, VAR3 INTO :DCLVAR2, :DCLVAR1, :DCLVAR3
or
Code:
SELECT * INTO :DCLVAR2, :DCLVAR1, :DCLVAR3
?
Back to top
View user's profile Send private message
parikshit123

Active User


Joined: 01 Jul 2005
Posts: 269
Location: India

PostPosted: Sun Jul 10, 2005 2:09 am
Reply with quote

jayesh,
I think,



is not a solution

SELECT VAR2, VAR1, VAR3 INTO :DCLVAR2, :DCLVAR1, :DCLVAR3
or
Coding SELECT * INTO :DCLVAR2, :DCLVAR1, :DCLVAR3
both are same if var1,var2 and var3 are the only attributes in the relation.

There might be something else wrong.

Vivek, Can you give the exact SQL statement you issued?
Back to top
View user's profile Send private message
gvt460

New User


Joined: 04 Mar 2005
Posts: 23

PostPosted: Mon Jul 11, 2005 11:57 am
Reply with quote

vivek u should give like this


SELECT VAR2, VAR1, VAR3 INTO :DCLVAR2, :DCLVAR1, :DCLVAR3
or
Coding SELECT * INTO :DCLtablename

if i am wrong let me know.

byee
venkatesh.
Back to top
View user's profile Send private message
kvivek

New User


Joined: 09 May 2005
Posts: 51
Location: Singapore

PostPosted: Mon Jul 11, 2005 8:30 pm
Reply with quote

Hi parikshit123,

I have issued the following statement
Code:
SELECT VAR2, VAR1, VAR3 INTO :DCLVAR2, :DCLVAR1, :DCLVAR3

I have received the values in the order of table declaration. Let's say VAR1 is 3 bytes, VAR2 is 4 bytes and VAR3 is 2 bytes. In my output i received like this
Code:
DCLVAR2 = VAR1(3) + VAR2(1)
DCLVAR1 = VAR2(2:3)
DCLVAR3 = VAR3

This happens only if i select all the fields (Around 60 fields, jayesh_g I never use Select * in my program icon_smile.gif )
If I select some of the fields (I tried upto 10 fields), It was working fine irrespective of the order of selection.
I guess this is due to Installation problem, Please let me know if you come across this type of error.

Thanks,
Vivek
Back to top
View user's profile Send private message
somasundaran_k

Active User


Joined: 03 Jun 2003
Posts: 134

PostPosted: Mon Jul 11, 2005 9:49 pm
Reply with quote

Vivek
Sound interesting.
Can you please post the SQL query (exactly as in your program) ?

Regds
-Som
Back to top
View user's profile Send private message
kvivek

New User


Joined: 09 May 2005
Posts: 51
Location: Singapore

PostPosted: Mon Jul 11, 2005 10:24 pm
Reply with quote

Hi somasundaran_k,

Due to data security I could not send the exact query. Please let me know if you have any queries, I will try to explain as much as possible. I am sorry for not sending you the exact code.

Thanks,
Vivek
Back to top
View user's profile Send private message
mayaganesh
Warnings : 1

New User


Joined: 07 Jul 2005
Posts: 1

PostPosted: Wed Jul 13, 2005 9:38 am
Reply with quote

Hi Guies,

I want to find the forth max value in the table. pls send the query.
thanks
Back to top
View user's profile Send private message
priyesh.agrawal

Senior Member


Joined: 28 Mar 2005
Posts: 1448
Location: Chicago, IL

PostPosted: Wed Jul 13, 2005 4:06 pm
Reply with quote

Hi Mayaganesh,

Please start a new topic....after making a proper search.....

http://ibmmainframes.com/viewtopic.php?t=46
http://ibmmainframes.com/viewtopic.php?t=1638
http://ibmmainframes.com/viewtopic.php?t=1227
http://ibmmainframes.com/viewtopic.php?t=403

Regards,

Priyesh.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DB2

 


Similar Topics
Topic Forum Replies
No new posts RC query -Time column CA Products 3
No new posts Dynamically pass table name to a sele... DB2 2
No new posts Query on edit primary command CLIST & REXX 5
No new posts Query on edit primary command CLIST & REXX 1
No new posts SELECT from data change table DB2 5
Search our Forums:

Back to Top