By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
437,924 Members | 1,793 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 437,924 IT Pros & Developers. It's quick & easy.

how to insert a null value in a db2 datetime column ?

P: 2
Hi,

I have a PL1 program to load a DB2 table with datetime zone (null allowed)

Usually when i have to load null values, I used nullindicator with -1 value but here, with a datetime variable i received sqlcode = -180.

How can I do ?

Thx

here is the code :
Expand|Select|Wrap|Line Numbers
  1.  PTXB003: PROC OPTIONS(MAIN);                                           
  2.  
  3. -EXEC SQL INCLUDE SQLCA;                                                
  4.  EXEC SQL DECLARE GTXCINDI.RELEVE_PRIJSOPNAME TABLE                     
  5.            ( . . .                                                      
  6.              D_MODIFIED_NOW_TS              TIMESTAMP,                  
  7.              . . .                                                      
  8.             ) ;                                                         
  9.  /*********************************************************************/
  10.  /* PLI DECLARATION FOR INPUT SEQ FILE                                */
  11.  /*********************************************************************/
  12. 1/* ----------------------------------------------------------------- */
  13.  /* INPUT                                                             */
  14.  /* ----------------------------------------------------------------- */
  15. -DCL INFIL FILE RECORD;                                                 
  16. 0DCL  1 RELEVEP,                                                        
  17.       5 ...                                                             
  18.       5 D_MODIFIED_NOW_TS                   CHAR(26),                   
  19.       5 ...;                                                            
  20. 0ON ENDFILE(INFIL) BEGIN;                                               
  21.     GOTO FIN;                                                           
  22.     END;                                                                
  23. 1/* ----------------------------------------------------------------- */
  24.  /* VARIABLES                                                         */
  25.  /* ----------------------------------------------------------------- */
  26. 0DCL (STRING,SUBSTR,TRANSLATE,MOD,INDEX,TIME,DATE) BUILTIN;             
  27.  DCL PLIRETC BUILTIN;                                                   
  28. DCL CTR PIC'999999' INIT(0);                                        
  29. DCL IND1  BIN FIXED(15) INIT(-1);                                   
  30.    /* ------------------------------------------------ */           
  31.    /*                  DEBUT TRAITEMENT                */           
  32.    /* ------------------------------------------------ */           
  33.          OPEN FILE(INFIL) INPUT;                                    
  34.     /* --------------------------------------------------------- */ 
  35.     /* TRAITEMENT                                                */ 
  36.     /* --------------------------------------------------------- */ 
  37. LECTURE: READ FILE(INFIL) INTO(RELEVEP);                            
  38.          IF RELEVEP.D_MODIFIED_NOW_TS ^= '' THEN IND1 = 0;          
  39.                                     ELSE IND1 = -1;                 
  40.          EXEC SQL INSERT INTO GTXCINDI.RELEVE_PRIJSOPNAME           
  41.           ( ...,                                                    
  42.             D_MODIFIED_NOW_TS,                                      
  43.             ...)                                                    
  44.          VALUES                                                     
  45.           ( :...,                                                   
  46.             :RELEVEP.D_MODIFIED_NOW_TS :IND1,                       
  47.             :...);                                                  
  48.          IF SQLCODE ^= 0 THEN DO;                                   
  49.            PUT SKIP EDIT('ERREUR CREATION RELEVE_PRIJSOPNAME')(A);  
  50.            GOTO ERRSQL;                                             
  51.            END;                                                     
  52.          CTR = CTR + 1;                                             
  53.          GOTO LECTURE;                                              
  54.     /* --------------------------------------------------------- */ 
  55.     /* ERREUR SQL                                                */ 
  56. ERRSQL: PUT SKIP LIST ('ERROR RAISED ON FETCH :' , SQLCODE);      
  57.         CALL PLIRETC(99);                                         
  58. FIN:   PUT SKIP DATA(CTR);                                        
  59.        CLOSE FILE(INFIL);                                         
  60. END PTXB003;
  61.  
Nov 19 '07 #1
Share this Question
Share on Google+
1 Reply


P: 2
sorry guys the problem is not a problem but a mistake in my input file.

Sorry for that
Nov 19 '07 #2

Post your reply

Sign in to post your reply or Sign up for a free account.