| View previous topic :: View next topic | 
	
	
		| Author | Message | 
	
		| drajasekharreddy Beginner
 
 
 Joined: 08 Apr 2004
 Posts: 16
 Topics: 14
 
 
 | 
			
				|  Posted: Thu Jul 15, 2004 4:08 am    Post subject: Regarding select * in embeded SQL |   |  
				| 
 |  
				| 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 |  | 
	
		|  | 
	
		| kolusu Site Admin
 
  
 
 Joined: 26 Nov 2002
 Posts: 12394
 Topics: 75
 Location: San Jose
 
 | 
			
				|  Posted: Thu Jul 15, 2004 4:40 am    Post subject: |   |  
				| 
 |  
				| 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 |  | 
	
		|  | 
	
		| bauer Intermediate
 
 
 Joined: 10 Oct 2003
 Posts: 317
 Topics: 50
 Location: Germany
 
 | 
			
				|  Posted: Sat Jul 17, 2004 9:35 am    Post subject: |   |  
				| 
 |  
				| 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 |  | 
	
		|  | 
	
		| Arshad Beginner
 
 
 Joined: 21 Jul 2004
 Posts: 1
 Topics: 0
 
 
 | 
			
				|  Posted: Wed Jul 21, 2004 10:21 am    Post subject: |   |  
				| 
 |  
				| 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 |  | 
	
		|  | 
	
		|  | 
	
		|  |