Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Select Query

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DB2
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    Post subject: Select Query
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: 24

PostPosted: Sat Jul 09, 2005 10:33 pm    Post subject: Re: Select Query
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    Post subject:
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    Post subject: Re: Select Query
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    Post subject:
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    Post subject:
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    Post subject:
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    Post subject: SQL Query
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: 1452
Location: Chicago, IL

PostPosted: Wed Jul 13, 2005 4:06 pm    Post subject: Re: Select Query
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    IBMMAINFRAMES.com Support Forums -> DB2 All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Join in SQL Query vickey_dw DB2 2 Tue Jan 17, 2017 12:15 am
This topic is locked: you cannot edit posts or make replies. MQ setup query mohitsaini Java & MQSeries 4 Sun Jan 08, 2017 1:53 am
No new posts DB2 query Using Recursion, Converting... smilewithashu2 DB2 1 Tue Jan 03, 2017 12:50 pm
No new posts SQL query to run through list of valu... Ni3-db2 DB2 14 Wed Dec 14, 2016 9:52 am
This topic is locked: you cannot edit posts or make replies. Db2 SQL query to convert rows into co... subratarec DB2 5 Thu Nov 17, 2016 4:51 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us