0

I have been trying to adapt a working "INSERT" into a SELECT statement and keep finding a error -104

a)Can someone please help me understand the reason why the "." on "where" clause (below) works when I run with an "insert" but gives me an error when using on a "select" clause? b)How should the "INSERT" criteria be written correctly when using a SELECT?

Many thanks in advance for any assistance on this question

Insert:

 INSERT INTO  SISPD2.SIS_DAILY_RECALC                            
         (CIN_NUM,PGM_DIV_FG,NON_CA_FG,PGM_EXCPT_FG,WTW_FG)   
 (SELECT C.CIN_NUM, C.PGM_DIV_FG, C.NON_CA_FG, C.PGM_EXCPT_FG,
         C.WTW_FG                                             
    FROM  SISPD2.SIS_INDV C                                  
   WHERE C.CIN_NUM NOT IN (SELECT CIN_NUM FROM  SISPD2.SIS_DAILY_RECALC)                       

------------------------------------------------------------------------

Select :

    SELECT C.CIN_NUM  ||','||                                          
         C.PGM_DIV_FG ||','||                                        
         C.NON_CA_FG  ||','||                                        
         C.PGM_EXCPT_FG ||','||                                     
         C.WTW_FG   ||','||                                        
  WHERE (C.CIN_NUM NOT IN (SELECT A.CIN_NUM                        
                            FROM  SISPD2.SIS_DAILY_RECALC A));      

DSNT408I SQLCODE = -104, ERROR: ILLEGAL SYMBOL ".". SOME SYMBOLS THAT MIGHT
BE LEGAL ARE: , FROM INTO
DSNT418I SQLSTATE = 42601 SQLSTATE RETURN CODE

mustaccio
  • 18,234
  • 16
  • 48
  • 57
Wanda Larangeira
  • 69
  • 1
  • 2
  • 10

1 Answers1

0

You shouldn't be concatenating a statement together unless you're building a dynamic statement you intend to PREPARE and EXECUTE

 SELECT C.CIN_NUM  
         , C.PGM_DIV_FG
         , C.NON_CA_FG
         , C.PGM_EXCPT_FG
         , C.WTW_FG
  WHERE (C.CIN_NUM NOT IN (SELECT A.CIN_NUM
                            FROM  SISPD2.SIS_DAILY_RECALC A)); 
Charles
  • 21,637
  • 1
  • 20
  • 44