MVSFORUMS.com Forum Index MVSFORUMS.com
A Community of and for MVS Professionals
 
 FAQFAQ   SearchSearch   Quick Manuals   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Regarding select * in embeded SQL

 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Database
View previous topic :: View next topic  
Author Message
drajasekharreddy
Beginner


Joined: 08 Apr 2004
Posts: 16
Topics: 14

PostPosted: Thu Jul 15, 2004 4:08 am    Post subject: Regarding select * in embeded SQL Reply with quote

Hi.

can i use SELECT * statement in embded SQl. like in cobol can i use this stetemnet. if yes can any one give me the syntax.


exec sql
select * into ......
end-exec.

what host varibles i have give.

thanx
raja
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12378
Topics: 75
Location: San Jose

PostPosted: Thu Jul 15, 2004 4:40 am    Post subject: Reply with quote

drajasekharreddy,

Define the query as a cursor and fetch the values into the host variables of the table.

Hope this helps...

Cheers

Kolusu
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
bauer
Intermediate


Joined: 10 Oct 2003
Posts: 317
Topics: 50
Location: Germany

PostPosted: Sat Jul 17, 2004 9:35 am    Post subject: Reply with quote

drajasekharreddy

yes you can code

EXEC SQL SELECT * INTO :HOSTVAR1, :HOSTVAR2, :HOSTVAR3 FROM TABELE WHERE .......

this works, in TABLE has 3 columns in this sample, COL1 is mapped to HOSTVAR1, COL2 is mapped to HOSTVAR2, ......


Problem: If TABLE is altered, one column added, the SELECT * ...... retrieves 4 columns, but only 3 HOSTVARs are coded, result is negativ sql code ......

So, not recommended to code SELECT * ...... in embeded SQL.

bauer
Back to top
View user's profile Send private message
Arshad
Beginner


Joined: 21 Jul 2004
Posts: 1
Topics: 0

PostPosted: Wed Jul 21, 2004 10:21 am    Post subject: Reply with quote

You need to handle it properly using a cursor. Whenever it returns more than one record it throws a bad SQL code.

Rgds,
Arshad
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Database All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


MVSFORUMS
Powered by phpBB © 2001, 2005 phpBB Group