SQL0312 Error
Last Post 10 Dec 2012 08:06 AM by gio.cot. 2 Replies.
AddThis - Bookmarking and Sharing Button Printer Friendly
  •  
  •  
  •  
  •  
  •  
Sort:
PrevPrev NextNext
You are not authorized to post a reply.
Author Messages
gio.cot
Basic Member
Basic Member
Posts:267

--
10 Dec 2012 06:41 AM

Hi all

i iva seen many discussion about the error SQL0312, but sincerely, i don't be able to undestand why i receive this error;

if i compile a program with this instruction :

......

      D QCUSTCDT      E DS                  Qualified Template     
      D MainDs          DS                  Qualified              
      D  CUSNUM_W                           Like(CUSNUM)           
      D  LSTNAM_W                           Like(LSTNAM)           
       // <<<<<<<<<<<<<<<<<<<<<<<<<<<<<                           
  .....

          ExEC SQL                                           
             FETCH NEXT FROM mainCursor INTO :MAINDS;        
                                                             
        Dow SqlStt = '00000' and   ySflNrrPag <=ySfl££SfPg;  
                                                             
          pri_ScanRek();                                     
                                                            
....

receive the following error 

Position 48 Variable MAINDS not defined or not  usable.    

 

If i change  the field definition in the mainds in this way:

     D QCUSTCDT      E DS                  Qualified Template    
     D MainDs          DS                  Qualified             
     D  CUSNUM_W                      6S 0                       
     D  LSTNAM_W                      8                         

i compile with no error  SQL0312

why happend this, and wich workarounf if i want define my fields with like ??

i have to use this code in v5r4 and v6r1

 

thanks in adcance

P.S. how i have to do to post code ?? 

B.Hauser
Veteran Member
Veteran Member
Posts:2014

--
10 Dec 2012 07:00 AM
Where are CUSNUM and LSTNAM defined? In QCUSTCDT?
If so you need to qualify the reference field, i.e. Like(QCUSTCDT.CusNum), because your reference data structure is qualified.
Also I'm not sure if the SQL precompiler can handle the keyword TEMPLATE.

Birgitta
gio.cot
Basic Member
Basic Member
Posts:267

--
10 Dec 2012 08:06 AM

Hi Birgitta

 

ok i have understand the thanks to your suggestion; but now i have another question:

suppose that the two fields (CUSNUM and LSTNAM) are defined in the dispaly files and so i have this situation:

D*QCUSTCDT      E DS                                      
   D MainDs          DS                                      
   D  CUSNUM                                                 
   D  LSTNAM                                                

why i receive the same error message ? SQL0312. I can't use the DSPF'S fields are result of my select into ?

is there and option the show the RPG errors to well understand the SQL problems ? example: if before i could see that my two fields were not definied because the referenced ds was qualified i could see the problem in a small time.

Thanks

You are not authorized to post a reply.

Acceptable Use Policy