IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

Interfaces de programmation Oracle Discussion :

[PRO*C] Compilation gcc


Sujet :

Interfaces de programmation Oracle

  1. #1
    Membre du Club
    Profil pro
    Inscrit en
    Mai 2006
    Messages
    105
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Mai 2006
    Messages : 105
    Points : 52
    Points
    52
    Par défaut [PRO*C] Compilation gcc
    je suis sous oracle 11g (fusion middleware 11g)

    J'ai un fichier dtesys.pc. A l'aide de la commande suivante je génère mon dtesys.c :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    ./proc code=c iname=dtesys.pc oname=dtesys.c userid=log/pass@SID\ SQLCHECK=FULL
    Ensuite je lance la commande :
    Mais là j'ai l'erreur suivante :
    dtesys.c:117: error: expected identifier or '(' before string constant
    dtesys.c:131: error: expected identifier or '(' before string constant
    L'erreur est dû à la partie du code :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    // Prototypes
    extern "C" {
      void sqlcxt (void **, unsigned int *,
                   struct sqlexd *, const struct sqlcxp *);
      void sqlcx2t(void **, unsigned int *,
                   struct sqlexd *, const struct sqlcxp *);
      void sqlbuft(void **, char *);
      void sqlgs2t(void **, char *);
      void sqlorat(void **, unsigned int *, void *);
    }
     
    // Forms Interface
    static const int IAPSUCC = 0;
    static const int IAPFAIL = 1403;
    static const int IAPFTL  = 535;
    extern "C" { void sqliem(unsigned char *, signed int *); }
    Dans le fichier dtesys.c mais je ne comprend pas.
    Je suis gros débutant dans le domaine

    Merci de votre aide.

    Mon fichier dtesys.pc :
    /* PROGRAM: DTESYS */


    #include "retek.h"

    int init();
    int do_eom();
    int do_eow();

    EXEC SQL INCLUDE SQLCA.H;

    EXEC SQL BEGIN DECLARE SECTION;
    char os_indate[NULL_DATE];
    EXEC SQL VAR os_indate IS STRING(NULL_DATE);
    EXEC SQL END DECLARE SECTION;

    long SQLCODE;
    int pi_day_increment_sw;

    main(argc, argv)
    int argc;
    char *argv[];
    {
    strcpy(PROGRAM, "dtesys");

    if (argc != 2 && argc != 3)
    {
    fprintf(stderr,
    "Usage: dtesys userid/passwd [indate--YYYYMMDD format]\n");
    exit(-1);
    }

    if (LOGON(argc, argv) < 0) exit(-1);

    EXEC SQL ALTER SESSION
    SET NLS_DATE_FORMAT = 'YYYYMMDD';

    if (argc == 2) { /* vdate will increment by 1 */
    pi_day_increment_sw = 1;
    }
    else { /* user is providing the next vdate */
    pi_day_increment_sw = 0;
    strcpy(os_indate, argv[2]);
    }

    if (init( ) < 0) {
    EXEC SQL ROLLBACK WORK RELEASE;
    LOG_MESSAGE("Terminated with errors ********************");
    exit(-1);
    }

    if (process() < 0) {
    EXEC SQL ROLLBACK WORK RELEASE;
    LOG_MESSAGE("Terminated with errors ********************");
    exit(-1);
    }

    if (final() < 0) {
    EXEC SQL ROLLBACK WORK RELEASE;
    LOG_MESSAGE("Terminated with errors ********************");
    exit(-1);
    } else {
    EXEC SQL COMMIT WORK RELEASE;
    if (CHECK_STATUS("Logoff") < 0) exit(-1);
    LOG_MESSAGE("Terminated OK");
    exit(0);
    }

    }

    int init()
    {
    return(0);
    }

    EXEC SQL BEGIN DECLARE SECTION;
    int oi_calendar_454_ind;
    int oi_cal_day;
    int oi_cal_month;
    int oi_cal_year;
    int oi_day_454;
    int oi_week_454;
    int oi_month_454;
    int oi_year_454;
    int oi_half_no;
    int oi_month_no;
    int oi_work_day;
    int oi_work_month;
    int oi_work_year;
    char os_fdow[NULL_DATE];
    EXEC SQL VAR os_fdow IS STRING(NULL_DATE);
    char os_ldow[NULL_DATE];
    EXEC SQL VAR os_ldow IS STRING(NULL_DATE);
    char os_fdoh[NULL_DATE];
    EXEC SQL VAR os_fdoh IS STRING(NULL_DATE);
    char os_ldoh[NULL_DATE];
    EXEC SQL VAR os_ldoh IS STRING(NULL_DATE);
    char os_fdom[NULL_DATE];
    EXEC SQL VAR os_fdom IS STRING(NULL_DATE);
    char os_midm[NULL_DATE];
    EXEC SQL VAR os_midm IS STRING(NULL_DATE);
    char os_ldom[NULL_DATE];
    EXEC SQL VAR os_ldom IS STRING(NULL_DATE);
    int oi_next_half;
    int oi_week_no;
    int oi_sysavail;
    /* added for eom */
    int oi_next_fdom_day;
    int oi_next_fdom_month;
    int oi_next_fdom_year;
    int oi_next_eom_day;
    int oi_next_eom_month;
    int oi_next_eom_year;
    char os_next_eom_date_unit[NULL_DATE];
    EXEC SQL VAR os_next_eom_date_unit IS STRING(NULL_DATE);

    /* added for eow */
    char os_next_eow_date_unit[NULL_DATE];
    EXEC SQL VAR os_next_eow_date_unit IS STRING(NULL_DATE);

    /* added for indate checking */
    char os_vdate_inc[NULL_DATE];
    EXEC SQL VAR os_vdate_inc IS STRING(NULL_DATE);

    EXEC SQL END DECLARE SECTION;


    EXEC SQL DECLARE c_date CURSOR FOR
    SELECT DECODE(system_options.calendar_454_ind,'C',1,0),
    period.vdate + 1,
    period.sysavail,
    system_variables.next_eow_date_unit,
    system_variables.next_eom_date_unit
    FROM system_options,
    period,
    system_variables;


    int process()
    {
    char *function = "process";

    EXEC SQL OPEN c_date;
    if SQL_ERROR_FOUND
    {
    sprintf(err_data,"Error opening c_date");
    WRITE_ERROR(SQLCODE,function,"system_options,period",err_data);
    return(-1);
    }
    EXEC SQL FETCH c_date
    INTO :oi_calendar_454_ind,
    :os_vdate_inc,
    :oi_sysavail,
    :os_next_eow_date_unit,
    :os_next_eom_date_unit;
    if (SQL_ERROR_FOUND || NO_DATA_FOUND)
    {
    sprintf(err_data,"Error fetching c_date");
    sprintf(table,"system_options,period,system_variables");
    WRITE_ERROR(SQLCODE,function,table,err_data);
    return(-1);
    }
    EXEC SQL CLOSE c_date;
    if SQL_ERROR_FOUND
    {
    sprintf(err_data,"Error closing c_date");
    sprintf(table,"system_options,period,system_variables");
    WRITE_ERROR(SQLCODE,function,"table",err_data);
    return(-1);
    }

    if ( pi_day_increment_sw )
    {
    sscanf(os_vdate_inc,"%4d%2d%2d",&oi_cal_year,&oi_cal_month,&oi_cal_day);

    }
    else
    { /* indate is provided */
    sscanf(os_indate,"%4d%2d%2d",&oi_cal_year,&oi_cal_month,&oi_cal_day);

    }

    if (calc_half() < 0) return(-1);
    if (calc_month() < 0) return(-1);
    if (calc_week() < 0) return(-1);


    EXEC SQL UPDATE period
    SET sysavail = :oi_sysavail,
    vdate = :os_indate,
    start_454_half = :os_fdoh,
    end_454_half = :os_ldoh,
    start_454_month = :os_fdom,
    mid_454_month = :os_midm,
    end_454_month = :os_ldom,
    half_no = :oi_half_no,
    next_half_no = :oi_next_half,
    curr_454_day = :oi_day_454,
    curr_454_week = :oi_week_454,
    curr_454_month = :oi_month_454,
    curr_454_year = :oi_year_454,
    curr_454_month_in_half = :oi_month_no,
    curr_454_week_in_half = :oi_week_no;
    if SQL_ERROR_FOUND
    {
    sprintf(err_data,"Update");
    WRITE_ERROR(SQLCODE,function,"period",err_data);
    return(-1);
    }
    /* After vdate is changed, see if update needed for eow, eom */
    /* ** See if new indate is in the future or in the past. */

    if (update_unit() < 0) return (-1);

    return(0);

    } /* end of process */


    int calc_half()
    {
    char *function= "calc_half";

    if (CAL_TO_454(oi_cal_day, oi_cal_month, oi_cal_year,
    &oi_day_454, &oi_week_454, &oi_month_454, &oi_year_454) < 0)
    {
    sprintf(err_data,"CAL_TO_454 conversion error");
    WRITE_ERROR(RET_FUNCTION_ERR,function,"",err_data);
    return(-1);
    }

    sprintf(os_indate,"%.04d%.02d%.02d", oi_cal_year,oi_cal_month,oi_cal_day);

    if (CAL_TO_454_HALF(oi_cal_day, oi_cal_month, oi_cal_year,
    &oi_half_no, &oi_month_no) < 0)
    {
    sprintf(err_data,"CAL_TO_454_HALF error");
    WRITE_ERROR(RET_FUNCTION_ERR,function,"",err_data);
    return(-1);
    }

    if (HALF_TO_454_FDOH(oi_half_no, &oi_work_day, &oi_work_month, &oi_work_year)
    < 0)
    {
    sprintf(err_data,"HALF_TO_454_FDOH conversion error");
    WRITE_ERROR(RET_FUNCTION_ERR,function,"",err_data);
    return(-1);
    }

    sprintf(os_fdoh, "%.04d%.02d%.02d", oi_work_year, oi_work_month, oi_work_day);

    if (HALF_TO_454_LDOH(oi_half_no, &oi_work_day, &oi_work_month, &oi_work_year) < 0)
    {
    sprintf(err_data,"HALF_TO_454_LDOH conversion error");
    WRITE_ERROR(RET_FUNCTION_ERR,function,"",err_data);
    return(-1);
    }

    sprintf(os_ldoh, "%.04d%.02d%.02d", oi_work_year, oi_work_month, oi_work_day);

    if (oi_half_no % 10 - 1)
    oi_next_half = oi_half_no + 9;
    else
    oi_next_half = oi_half_no + 1;


    return(0);
    } /* end of calc_half */

    int calc_month()
    {
    char *function = "calc_month";

    if (CAL_TO_454_FDOM(oi_cal_day, oi_cal_month, oi_cal_year,
    &oi_work_day, &oi_work_month, &oi_work_year) < 0)
    {
    sprintf(err_data,"CAL_TO_454_FDOM conversion error ");
    WRITE_ERROR(RET_FUNCTION_ERR,function,"",err_data);
    return(-1);
    }

    sprintf(os_fdom, "%.04d%.02d%.02d", oi_work_year, oi_work_month, oi_work_day);

    sprintf(os_midm, "%.04d%.02d15", oi_year_454, oi_month_454);

    if (CAL_TO_454_LDOM(oi_cal_day, oi_cal_month, oi_cal_year,
    &oi_work_day, &oi_work_month, &oi_work_year) < 0)
    {
    sprintf(err_data,"CAL_TO_454_LDOM conversion error ");
    WRITE_ERROR(RET_FUNCTION_ERR,function,"",err_data);
    return(-1);
    }
    sprintf(os_ldom, "%.04d%.02d%.02d", oi_work_year, oi_work_month, oi_work_day);

    return(0);
    } /* end of calc_month */

    int calc_week()
    {
    char *function = "calc_week";

    if (CAL_TO_454_WNO(oi_cal_day, oi_cal_month, oi_cal_year, &oi_week_no) < 0)
    {
    sprintf(err_data,"CAL_TO_454_WNO conversion error ");
    WRITE_ERROR(RET_FUNCTION_ERR,function,"",err_data);
    return(-1);
    }

    /* calculate the new first and last day of the week from 4_5_4 date.*/
    if (C454_TO_CAL(1,oi_week_454,oi_month_454,oi_year_454,
    &oi_work_day, &oi_work_month, &oi_work_year) < 0)
    {
    sprintf(err_data,"C454_TO_CAL conversion error ");
    WRITE_ERROR(RET_FUNCTION_ERR,function,"",err_data);
    return(-1);
    }

    sprintf(os_fdow, "%.04d%.02d%.02d", oi_work_year, oi_work_month, oi_work_day);

    if (C454_TO_CAL(7,oi_week_454,oi_month_454,oi_year_454,
    &oi_work_day, &oi_work_month, &oi_work_year) < 0)
    {
    sprintf(err_data,"C454_TO_CAL conversion error ");
    WRITE_ERROR(RET_FUNCTION_ERR,function,"",err_data);
    return(-1);
    }

    sprintf(os_ldow, "%.04d%.02d%.02d", oi_work_year, oi_work_month, oi_work_day);
    return(0);
    } /* end of calc_week */

    /**********************************/
    /* added for eow / eom */
    /**********************************/
    int update_unit()
    {
    char *function = "update_unit";
    EXEC SQL UPDATE system_variables
    SET system_variables.last_eom_date_unit
    = TO_DATE(:os_fdom) - 1,
    system_variables.next_eom_date_unit
    = TO_DATE(:os_ldom),
    system_variables.last_eow_date_unit
    = TO_DATE(:os_fdow) - 1,
    system_variables.next_eow_date_unit
    = TO_DATE(:os_ldow);
    if SQL_ERROR_FOUND
    {
    sprintf(err_data,"Update");
    WRITE_ERROR(SQLCODE,function,"system_variables",err_data);
    return(-1);
    }

    /* check to see if the previous next_eom_date_unit is the same as the
    current last_eom_date_unit. If they are not and the ldom is actually
    greater than the previous next_eom_date_unit, a log message will be
    written to indicate that a period has been skipped.
    */
    if (!pi_day_increment_sw)
    {
    if (strcmp(os_ldom, os_next_eom_date_unit) > 0)
    {
    LOG_MESSAGE("Alert condition: Current date has been\n" \
    "advanced to a period beyond the expected next unit month.");
    }
    if (strcmp(os_ldow, os_next_eow_date_unit) > 0)
    {
    LOG_MESSAGE("Alert condition: Current date has been\n" \
    "advanced to a period beyond the expected next unit week.");

    }
    }

    return(0);
    }



    int final()
    {
    return(0);
    }

    mon fichier

    /* Result Sets Interface */
    #ifndef SQL_CRSR
    # define SQL_CRSR
    struct sql_cursor
    {
    unsigned int curocn;
    void *ptr1;
    void *ptr2;
    unsigned int magic;
    };
    typedef struct sql_cursor sql_cursor;
    typedef struct sql_cursor SQL_CURSOR;
    #endif /* SQL_CRSR */

    /* Thread Safety */
    typedef void * sql_context;
    typedef void * SQL_CONTEXT;

    /* Object support */
    struct sqltvn
    {
    unsigned char *tvnvsn;
    unsigned short tvnvsnl;
    unsigned char *tvnnm;
    unsigned short tvnnml;
    unsigned char *tvnsnm;
    unsigned short tvnsnml;
    };
    typedef struct sqltvn sqltvn;

    struct sqladts
    {
    unsigned int adtvsn;
    unsigned short adtmode;
    unsigned short adtnum;
    sqltvn adttvn[1];
    };
    typedef struct sqladts sqladts;

    static struct sqladts sqladt = {
    1,1,0,
    };

    /* Binding to PL/SQL Records */
    struct sqltdss
    {
    unsigned int tdsvsn;
    unsigned short tdsnum;
    unsigned char *tdsval[1];
    };
    typedef struct sqltdss sqltdss;
    static struct sqltdss sqltds =
    {
    1,
    0,
    };

    /* File name & Package Name */
    struct sqlcxp
    {
    unsigned short fillen;
    char filnam[52];
    };
    static const struct sqlcxp sqlfpn =
    {
    51,
    "/apps/rms9000/rms9000_src/oracle/proc/src/dtesys.pc"
    };


    static unsigned int sqlctx = 1552032413;


    static struct sqlexd {
    unsigned int sqlvsn;
    unsigned int arrsiz;
    unsigned int iters;
    unsigned int offset;
    unsigned short selerr;
    unsigned short sqlety;
    unsigned int occurs;
    const short *cud;
    unsigned char *sqlest;
    const char *stmt;
    sqladts *sqladtp;
    sqltdss *sqltdsp;
    void **sqphsv;
    unsigned int *sqphsl;
    int *sqphss;
    void **sqpind;
    int *sqpins;
    unsigned int *sqparm;
    unsigned int **sqparc;
    unsigned short *sqpadto;
    unsigned short *sqptdso;
    unsigned int sqlcmax;
    unsigned int sqlcmin;
    unsigned int sqlcincr;
    unsigned int sqlctimeout;
    unsigned int sqlcnowait;
    int sqfoff;
    unsigned int sqcmod;
    unsigned int sqfmod;
    void *sqhstv[15];
    unsigned int sqhstl[15];
    int sqhsts[15];
    void *sqindv[15];
    int sqinds[15];
    unsigned int sqharm[15];
    unsigned int *sqharc[15];
    unsigned short sqadto[15];
    unsigned short sqtdso[15];
    } sqlstm = {12,15};

    // Prototypes
    extern "C" {
    void sqlcxt (void **, unsigned int *,
    struct sqlexd *, const struct sqlcxp *);
    void sqlcx2t(void **, unsigned int *,
    struct sqlexd *, const struct sqlcxp *);
    void sqlbuft(void **, char *);
    void sqlgs2t(void **, char *);
    void sqlorat(void **, unsigned int *, void *);
    }

    // Forms Interface
    static const int IAPSUCC = 0;
    static const int IAPFAIL = 1403;
    static const int IAPFTL = 535;
    extern "C" { void sqliem(unsigned char *, signed int *); }

    static const char *sq0006 =
    "select DECODE(system_options.calendar_454_ind,'C',1,0) ,(period.vdate+1) ,pe\
    riod.sysavail ,system_variables.next_eow_date_unit ,system_variables.next_eom_\
    date_unit from system_options ,period ,system_variables ";

    typedef struct { unsigned short len; unsigned char arr[1]; } VARCHAR;
    typedef struct { unsigned short len; unsigned char arr[1]; } varchar;

    /* cud (compilation unit data) array */
    static const short sqlcud0[] =
    {12,4130,31,0,0,
    5,0,0,1,46,0,1,35,0,0,0,0,0,1,0,
    20,0,0,2,0,0,32,47,0,0,0,0,0,1,0,
    35,0,0,3,0,0,32,53,0,0,0,0,0,1,0,
    50,0,0,4,0,0,32,59,0,0,0,0,0,1,0,
    65,0,0,5,0,0,30,63,0,0,0,0,0,1,0,
    80,0,0,6,222,0,9,143,0,0,0,0,0,1,0,
    95,0,0,6,0,0,13,150,0,0,5,0,0,1,0,2,3,0,0,2,5,0,0,2,3,0,0,2,5,0,0,2,5,0,0,
    130,0,0,6,0,0,15,163,0,0,0,0,0,1,0,
    145,0,0,7,292,0,5,188,0,0,15,15,0,1,0,1,3,0,0,1,5,0,0,1,5,0,0,1,5,0,0,1,5,0,0,
    1,5,0,0,1,5,0,0,1,3,0,0,1,3,0,0,1,3,0,0,1,3,0,0,1,3,0,0,1,3,0,0,1,3,0,0,1,3,0,
    0,
    220,0,0,8,232,0,5,338,0,0,4,4,0,1,0,1,5,0,0,1,5,0,0,1,5,0,0,1,5,0,0,
    };


    /* PROGRAM: DTESYS */


    #include "retek.h"

    int init();
    int do_eom();
    int do_eow();

    /* EXEC SQL INCLUDE SQLCA.H;
    */
    /*
    * $Header: sqlca.h 24-apr-2003.12:50:58 mkandarp Exp $ sqlca.h
    */

    /* Copyright (c) 1985, 2003, Oracle Corporation. All rights reserved. */

    /*
    NAME
    SQLCA : SQL Communications Area.
    FUNCTION
    Contains no code. Oracle fills in the SQLCA with status info
    during the execution of a SQL stmt.
    NOTES
    **************************************************************
    *** ***
    *** This file is SOSD. Porters must change the data types ***
    *** appropriately on their platform. See notes/pcport.doc ***
    *** for more information. ***
    *** ***
    **************************************************************

    If the symbol SQLCA_STORAGE_CLASS is defined, then the SQLCA
    will be defined to have this storage class. For example:

    #define SQLCA_STORAGE_CLASS extern

    will define the SQLCA as an extern.

    If the symbol SQLCA_INIT is defined, then the SQLCA will be
    statically initialized. Although this is not necessary in order
    to use the SQLCA, it is a good pgming practice not to have
    unitialized variables. However, some C compilers/OS's don't
    allow automatic variables to be init'd in this manner. Therefore,
    if you are INCLUDE'ing the SQLCA in a place where it would be
    an automatic AND your C compiler/OS doesn't allow this style
    of initialization, then SQLCA_INIT should be left undefined --
    all others can define SQLCA_INIT if they wish.

    If the symbol SQLCA_NONE is defined, then the SQLCA variable will
    not be defined at all. The symbol SQLCA_NONE should not be defined
    in source modules that have embedded SQL. However, source modules
    that have no embedded SQL, but need to manipulate a sqlca struct
    passed in as a parameter, can set the SQLCA_NONE symbol to avoid
    creation of an extraneous sqlca variable.

    MODIFIED
    lvbcheng 07/31/98 - long to int
    jbasu 12/12/94 - Bug 217878: note this is an SOSD file
    losborne 08/11/92 - No sqlca var if SQLCA_NONE macro set
    Clare 12/06/84 - Ch SQLCA to not be an extern.
    Clare 10/21/85 - Add initialization.
    Bradbury 01/05/86 - Only initialize when SQLCA_INIT set
    Clare 06/12/86 - Add SQLCA_STORAGE_CLASS option.
    */

    #ifndef SQLCA
    #define SQLCA 1

    struct sqlca
    {
    /* ub1 */ char sqlcaid[8];
    /* b4 */ int sqlabc;
    /* b4 */ int sqlcode;
    struct
    {
    /* ub2 */ unsigned short sqlerrml;
    /* ub1 */ char sqlerrmc[70];
    } sqlerrm;
    /* ub1 */ char sqlerrp[8];
    /* b4 */ int sqlerrd[6];
    /* ub1 */ char sqlwarn[8];
    /* ub1 */ char sqlext[8];
    };

    #ifndef SQLCA_NONE
    #ifdef SQLCA_STORAGE_CLASS
    SQLCA_STORAGE_CLASS struct sqlca sqlca
    #else
    struct sqlca sqlca
    #endif

    #ifdef SQLCA_INIT
    = {
    {'S', 'Q', 'L', 'C', 'A', ' ', ' ', ' '},
    sizeof(struct sqlca),
    0,
    { 0, {0}},
    {'N', 'O', 'T', ' ', 'S', 'E', 'T', ' '},
    {0, 0, 0, 0, 0, 0},
    {0, 0, 0, 0, 0, 0, 0, 0},
    {0, 0, 0, 0, 0, 0, 0, 0}
    }
    #endif
    ;
    #endif

    #endif

    /* end SQLCA */


    /* EXEC SQL BEGIN DECLARE SECTION; */

    char os_indate[NULL_DATE];
    /* EXEC SQL VAR os_indate IS STRING(NULL_DATE); */

    /* EXEC SQL END DECLARE SECTION; */


    long SQLCODE;
    int pi_day_increment_sw;

    main(argc, argv)
    int argc;
    char *argv[];
    {
    strcpy(PROGRAM, "dtesys");

    if (argc != 2 && argc != 3)
    {
    fprintf(stderr,
    "Usage: dtesys userid/passwd [indate--YYYYMMDD format]\n");
    exit(-1);
    }

    if (LOGON(argc, argv) < 0) exit(-1);

    /* EXEC SQL ALTER SESSION
    SET NLS_DATE_FORMAT = 'YYYYMMDD'; */

    {
    struct sqlexd sqlstm;
    sqlstm.sqlvsn = 12;
    sqlstm.arrsiz = 0;
    sqlstm.sqladtp = &sqladt;
    sqlstm.sqltdsp = &sqltds;
    sqlstm.stmt = "alter SESSION SET NLS_DATE_FORMAT = 'YYYYMMDD'";
    sqlstm.iters = (unsigned int )1;
    sqlstm.offset = (unsigned int )5;
    sqlstm.cud = sqlcud0;
    sqlstm.sqlest = (unsigned char *)&sqlca;
    sqlstm.sqlety = (unsigned short)4352;
    sqlstm.occurs = (unsigned int )0;
    sqlcxt((void **)0, &sqlctx, &sqlstm, &sqlfpn);
    }



    if (argc == 2) { /* vdate will increment by 1 */
    pi_day_increment_sw = 1;
    }
    else { /* user is providing the next vdate */
    pi_day_increment_sw = 0;
    strcpy(os_indate, argv[2]);
    }

    if (init( ) < 0) {
    /* EXEC SQL ROLLBACK WORK RELEASE; */

    {
    struct sqlexd sqlstm;
    sqlstm.sqlvsn = 12;
    sqlstm.arrsiz = 0;
    sqlstm.sqladtp = &sqladt;
    sqlstm.sqltdsp = &sqltds;
    sqlstm.iters = (unsigned int )1;
    sqlstm.offset = (unsigned int )20;
    sqlstm.cud = sqlcud0;
    sqlstm.sqlest = (unsigned char *)&sqlca;
    sqlstm.sqlety = (unsigned short)4352;
    sqlstm.occurs = (unsigned int )0;
    sqlcxt((void **)0, &sqlctx, &sqlstm, &sqlfpn);
    }


    LOG_MESSAGE("Terminated with errors ********************");
    exit(-1);
    }

    if (process() < 0) {
    /* EXEC SQL ROLLBACK WORK RELEASE; */

    {
    struct sqlexd sqlstm;
    sqlstm.sqlvsn = 12;
    sqlstm.arrsiz = 0;
    sqlstm.sqladtp = &sqladt;
    sqlstm.sqltdsp = &sqltds;
    sqlstm.iters = (unsigned int )1;
    sqlstm.offset = (unsigned int )35;
    sqlstm.cud = sqlcud0;
    sqlstm.sqlest = (unsigned char *)&sqlca;
    sqlstm.sqlety = (unsigned short)4352;
    sqlstm.occurs = (unsigned int )0;
    sqlcxt((void **)0, &sqlctx, &sqlstm, &sqlfpn);
    }


    LOG_MESSAGE("Terminated with errors ********************");
    exit(-1);
    }

    if (final() < 0) {
    /* EXEC SQL ROLLBACK WORK RELEASE; */

    {
    struct sqlexd sqlstm;
    sqlstm.sqlvsn = 12;
    sqlstm.arrsiz = 0;
    sqlstm.sqladtp = &sqladt;
    sqlstm.sqltdsp = &sqltds;
    sqlstm.iters = (unsigned int )1;
    sqlstm.offset = (unsigned int )50;
    sqlstm.cud = sqlcud0;
    sqlstm.sqlest = (unsigned char *)&sqlca;
    sqlstm.sqlety = (unsigned short)4352;
    sqlstm.occurs = (unsigned int )0;
    sqlcxt((void **)0, &sqlctx, &sqlstm, &sqlfpn);
    }


    LOG_MESSAGE("Terminated with errors ********************");
    exit(-1);
    } else {
    /* EXEC SQL COMMIT WORK RELEASE; */

    {
    struct sqlexd sqlstm;
    sqlstm.sqlvsn = 12;
    sqlstm.arrsiz = 0;
    sqlstm.sqladtp = &sqladt;
    sqlstm.sqltdsp = &sqltds;
    sqlstm.iters = (unsigned int )1;
    sqlstm.offset = (unsigned int )65;
    sqlstm.cud = sqlcud0;
    sqlstm.sqlest = (unsigned char *)&sqlca;
    sqlstm.sqlety = (unsigned short)4352;
    sqlstm.occurs = (unsigned int )0;
    sqlcxt((void **)0, &sqlctx, &sqlstm, &sqlfpn);
    }


    if (CHECK_STATUS("Logoff") < 0) exit(-1);
    LOG_MESSAGE("Terminated OK");
    exit(0);
    }

    }

    int init()
    {
    return(0);
    }

    /* EXEC SQL BEGIN DECLARE SECTION; */

    int oi_calendar_454_ind;
    int oi_cal_day;
    int oi_cal_month;
    int oi_cal_year;
    int oi_day_454;
    int oi_week_454;
    int oi_month_454;
    int oi_year_454;
    int oi_half_no;
    int oi_month_no;
    int oi_work_day;
    int oi_work_month;
    int oi_work_year;
    char os_fdow[NULL_DATE];
    /* EXEC SQL VAR os_fdow IS STRING(NULL_DATE); */

    char os_ldow[NULL_DATE];
    /* EXEC SQL VAR os_ldow IS STRING(NULL_DATE); */

    char os_fdoh[NULL_DATE];
    /* EXEC SQL VAR os_fdoh IS STRING(NULL_DATE); */

    char os_ldoh[NULL_DATE];
    /* EXEC SQL VAR os_ldoh IS STRING(NULL_DATE); */

    char os_fdom[NULL_DATE];
    /* EXEC SQL VAR os_fdom IS STRING(NULL_DATE); */

    char os_midm[NULL_DATE];
    /* EXEC SQL VAR os_midm IS STRING(NULL_DATE); */

    char os_ldom[NULL_DATE];
    /* EXEC SQL VAR os_ldom IS STRING(NULL_DATE); */

    int oi_next_half;
    int oi_week_no;
    int oi_sysavail;
    /* added for eom */
    int oi_next_fdom_day;
    int oi_next_fdom_month;
    int oi_next_fdom_year;
    int oi_next_eom_day;
    int oi_next_eom_month;
    int oi_next_eom_year;
    char os_next_eom_date_unit[NULL_DATE];
    /* EXEC SQL VAR os_next_eom_date_unit IS STRING(NULL_DATE); */


    /* added for eow */
    char os_next_eow_date_unit[NULL_DATE];
    /* EXEC SQL VAR os_next_eow_date_unit IS STRING(NULL_DATE); */


    /* added for indate checking */
    char os_vdate_inc[NULL_DATE];
    /* EXEC SQL VAR os_vdate_inc IS STRING(NULL_DATE); */


    /* EXEC SQL END DECLARE SECTION; */



    /* EXEC SQL DECLARE c_date CURSOR FOR
    SELECT DECODE(system_options.calendar_454_ind,'C',1,0),
    period.vdate + 1,
    period.sysavail,
    system_variables.next_eow_date_unit,
    system_variables.next_eom_date_unit
    FROM system_options,
    period,
    system_variables; */



    int process()
    {
    char *function = "process";

    /* EXEC SQL OPEN c_date; */

    {
    struct sqlexd sqlstm;
    sqlstm.sqlvsn = 12;
    sqlstm.arrsiz = 0;
    sqlstm.sqladtp = &sqladt;
    sqlstm.sqltdsp = &sqltds;
    sqlstm.stmt = sq0006;
    sqlstm.iters = (unsigned int )1;
    sqlstm.offset = (unsigned int )80;
    sqlstm.selerr = (unsigned short)1;
    sqlstm.cud = sqlcud0;
    sqlstm.sqlest = (unsigned char *)&sqlca;
    sqlstm.sqlety = (unsigned short)4352;
    sqlstm.occurs = (unsigned int )0;
    sqlstm.sqcmod = (unsigned int )0;
    sqlcxt((void **)0, &sqlctx, &sqlstm, &sqlfpn);
    }


    if SQL_ERROR_FOUND
    {
    sprintf(err_data,"Error opening c_date");
    WRITE_ERROR(SQLCODE,function,"system_options,period",err_data);
    return(-1);
    }
    /* EXEC SQL FETCH c_date
    INTO :oi_calendar_454_ind,
    :os_vdate_inc,
    :oi_sysavail,
    :os_next_eow_date_unit,
    :os_next_eom_date_unit; */

    {
    struct sqlexd sqlstm;
    sqlstm.sqlvsn = 12;
    sqlstm.arrsiz = 5;
    sqlstm.sqladtp = &sqladt;
    sqlstm.sqltdsp = &sqltds;
    sqlstm.iters = (unsigned int )1;
    sqlstm.offset = (unsigned int )95;
    sqlstm.selerr = (unsigned short)1;
    sqlstm.cud = sqlcud0;
    sqlstm.sqlest = (unsigned char *)&sqlca;
    sqlstm.sqlety = (unsigned short)4352;
    sqlstm.occurs = (unsigned int )0;
    sqlstm.sqfoff = ( int )0;
    sqlstm.sqfmod = (unsigned int )2;
    sqlstm.sqhstv[0] = ( void *)&oi_calendar_454_ind;
    sqlstm.sqhstl[0] = (unsigned int )sizeof(int);
    sqlstm.sqhsts[0] = ( int )0;
    sqlstm.sqindv[0] = ( void *)0;
    sqlstm.sqinds[0] = ( int )0;
    sqlstm.sqharm[0] = (unsigned int )0;
    sqlstm.sqadto[0] = (unsigned short )0;
    sqlstm.sqtdso[0] = (unsigned short )0;
    sqlstm.sqhstv[1] = ( void *)os_vdate_inc;
    sqlstm.sqhstl[1] = (unsigned int )15;
    sqlstm.sqhsts[1] = ( int )0;
    sqlstm.sqindv[1] = ( void *)0;
    sqlstm.sqinds[1] = ( int )0;
    sqlstm.sqharm[1] = (unsigned int )0;
    sqlstm.sqadto[1] = (unsigned short )0;
    sqlstm.sqtdso[1] = (unsigned short )0;
    sqlstm.sqhstv[2] = ( void *)&oi_sysavail;
    sqlstm.sqhstl[2] = (unsigned int )sizeof(int);
    sqlstm.sqhsts[2] = ( int )0;
    sqlstm.sqindv[2] = ( void *)0;
    sqlstm.sqinds[2] = ( int )0;
    sqlstm.sqharm[2] = (unsigned int )0;
    sqlstm.sqadto[2] = (unsigned short )0;
    sqlstm.sqtdso[2] = (unsigned short )0;
    sqlstm.sqhstv[3] = ( void *)os_next_eow_date_unit;
    sqlstm.sqhstl[3] = (unsigned int )15;
    sqlstm.sqhsts[3] = ( int )0;
    sqlstm.sqindv[3] = ( void *)0;
    sqlstm.sqinds[3] = ( int )0;
    sqlstm.sqharm[3] = (unsigned int )0;
    sqlstm.sqadto[3] = (unsigned short )0;
    sqlstm.sqtdso[3] = (unsigned short )0;
    sqlstm.sqhstv[4] = ( void *)os_next_eom_date_unit;
    sqlstm.sqhstl[4] = (unsigned int )15;
    sqlstm.sqhsts[4] = ( int )0;
    sqlstm.sqindv[4] = ( void *)0;
    sqlstm.sqinds[4] = ( int )0;
    sqlstm.sqharm[4] = (unsigned int )0;
    sqlstm.sqadto[4] = (unsigned short )0;
    sqlstm.sqtdso[4] = (unsigned short )0;
    sqlstm.sqphsv = sqlstm.sqhstv;
    sqlstm.sqphsl = sqlstm.sqhstl;
    sqlstm.sqphss = sqlstm.sqhsts;
    sqlstm.sqpind = sqlstm.sqindv;
    sqlstm.sqpins = sqlstm.sqinds;
    sqlstm.sqparm = sqlstm.sqharm;
    sqlstm.sqparc = sqlstm.sqharc;
    sqlstm.sqpadto = sqlstm.sqadto;
    sqlstm.sqptdso = sqlstm.sqtdso;
    sqlcxt((void **)0, &sqlctx, &sqlstm, &sqlfpn);
    }


    if (SQL_ERROR_FOUND || NO_DATA_FOUND)
    {
    sprintf(err_data,"Error fetching c_date");
    sprintf(table,"system_options,period,system_variables");
    WRITE_ERROR(SQLCODE,function,table,err_data);
    return(-1);
    }
    /* EXEC SQL CLOSE c_date; */

    {
    struct sqlexd sqlstm;
    sqlstm.sqlvsn = 12;
    sqlstm.arrsiz = 5;
    sqlstm.sqladtp = &sqladt;
    sqlstm.sqltdsp = &sqltds;
    sqlstm.iters = (unsigned int )1;
    sqlstm.offset = (unsigned int )130;
    sqlstm.cud = sqlcud0;
    sqlstm.sqlest = (unsigned char *)&sqlca;
    sqlstm.sqlety = (unsigned short)4352;
    sqlstm.occurs = (unsigned int )0;
    sqlcxt((void **)0, &sqlctx, &sqlstm, &sqlfpn);
    }


    if SQL_ERROR_FOUND
    {
    sprintf(err_data,"Error closing c_date");
    sprintf(table,"system_options,period,system_variables");
    WRITE_ERROR(SQLCODE,function,"table",err_data);
    return(-1);
    }

    if ( pi_day_increment_sw )
    {
    sscanf(os_vdate_inc,"%4d%2d%2d",&oi_cal_year,&oi_cal_month,&oi_cal_day);

    }
    else
    { /* indate is provided */
    sscanf(os_indate,"%4d%2d%2d",&oi_cal_year,&oi_cal_month,&oi_cal_day);

    }

    if (calc_half() < 0) return(-1);
    if (calc_month() < 0) return(-1);
    if (calc_week() < 0) return(-1);


    /* EXEC SQL UPDATE period
    SET sysavail = :oi_sysavail,
    vdate = :os_indate,
    start_454_half = :os_fdoh,
    end_454_half = :os_ldoh,
    start_454_month = :os_fdom,
    mid_454_month = :os_midm,
    end_454_month = :os_ldom,
    half_no = :oi_half_no,
    next_half_no = :oi_next_half,
    curr_454_day = :oi_day_454,
    curr_454_week = :oi_week_454,
    curr_454_month = :oi_month_454,
    curr_454_year = :oi_year_454,
    curr_454_month_in_half = :oi_month_no,
    curr_454_week_in_half = :oi_week_no; */

    {
    struct sqlexd sqlstm;
    sqlstm.sqlvsn = 12;
    sqlstm.arrsiz = 15;
    sqlstm.sqladtp = &sqladt;
    sqlstm.sqltdsp = &sqltds;
    sqlstm.stmt = "update period set sysavail=:b0,vdate=:b1,start_454_half=\
    :b2,end_454_half=:b3,start_454_month=:b4,mid_454_month=:b5,end_454_month=:b6,h\
    alf_no=:b7,next_half_no=:b8,curr_454_day=:b9,curr_454_week=:b10,curr_454_month\
    =:b11,curr_454_year=:b12,curr_454_month_in_half=:b13,curr_454_week_in_half=:b1\
    4";
    sqlstm.iters = (unsigned int )1;
    sqlstm.offset = (unsigned int )145;
    sqlstm.cud = sqlcud0;
    sqlstm.sqlest = (unsigned char *)&sqlca;
    sqlstm.sqlety = (unsigned short)4352;
    sqlstm.occurs = (unsigned int )0;
    sqlstm.sqhstv[0] = ( void *)&oi_sysavail;
    sqlstm.sqhstl[0] = (unsigned int )sizeof(int);
    sqlstm.sqhsts[0] = ( int )0;
    sqlstm.sqindv[0] = ( void *)0;
    sqlstm.sqinds[0] = ( int )0;
    sqlstm.sqharm[0] = (unsigned int )0;
    sqlstm.sqadto[0] = (unsigned short )0;
    sqlstm.sqtdso[0] = (unsigned short )0;
    sqlstm.sqhstv[1] = ( void *)os_indate;
    sqlstm.sqhstl[1] = (unsigned int )15;
    sqlstm.sqhsts[1] = ( int )0;
    sqlstm.sqindv[1] = ( void *)0;
    sqlstm.sqinds[1] = ( int )0;
    sqlstm.sqharm[1] = (unsigned int )0;
    sqlstm.sqadto[1] = (unsigned short )0;
    sqlstm.sqtdso[1] = (unsigned short )0;
    sqlstm.sqhstv[2] = ( void *)os_fdoh;
    sqlstm.sqhstl[2] = (unsigned int )15;
    sqlstm.sqhsts[2] = ( int )0;
    sqlstm.sqindv[2] = ( void *)0;
    sqlstm.sqinds[2] = ( int )0;
    sqlstm.sqharm[2] = (unsigned int )0;
    sqlstm.sqadto[2] = (unsigned short )0;
    sqlstm.sqtdso[2] = (unsigned short )0;
    sqlstm.sqhstv[3] = ( void *)os_ldoh;
    sqlstm.sqhstl[3] = (unsigned int )15;
    sqlstm.sqhsts[3] = ( int )0;
    sqlstm.sqindv[3] = ( void *)0;
    sqlstm.sqinds[3] = ( int )0;
    sqlstm.sqharm[3] = (unsigned int )0;
    sqlstm.sqadto[3] = (unsigned short )0;
    sqlstm.sqtdso[3] = (unsigned short )0;
    sqlstm.sqhstv[4] = ( void *)os_fdom;
    sqlstm.sqhstl[4] = (unsigned int )15;
    sqlstm.sqhsts[4] = ( int )0;
    sqlstm.sqindv[4] = ( void *)0;
    sqlstm.sqinds[4] = ( int )0;
    sqlstm.sqharm[4] = (unsigned int )0;
    sqlstm.sqadto[4] = (unsigned short )0;
    sqlstm.sqtdso[4] = (unsigned short )0;
    sqlstm.sqhstv[5] = ( void *)os_midm;
    sqlstm.sqhstl[5] = (unsigned int )15;
    sqlstm.sqhsts[5] = ( int )0;
    sqlstm.sqindv[5] = ( void *)0;
    sqlstm.sqinds[5] = ( int )0;
    sqlstm.sqharm[5] = (unsigned int )0;
    sqlstm.sqadto[5] = (unsigned short )0;
    sqlstm.sqtdso[5] = (unsigned short )0;
    sqlstm.sqhstv[6] = ( void *)os_ldom;
    sqlstm.sqhstl[6] = (unsigned int )15;
    sqlstm.sqhsts[6] = ( int )0;
    sqlstm.sqindv[6] = ( void *)0;
    sqlstm.sqinds[6] = ( int )0;
    sqlstm.sqharm[6] = (unsigned int )0;
    sqlstm.sqadto[6] = (unsigned short )0;
    sqlstm.sqtdso[6] = (unsigned short )0;
    sqlstm.sqhstv[7] = ( void *)&oi_half_no;
    sqlstm.sqhstl[7] = (unsigned int )sizeof(int);
    sqlstm.sqhsts[7] = ( int )0;
    sqlstm.sqindv[7] = ( void *)0;
    sqlstm.sqinds[7] = ( int )0;
    sqlstm.sqharm[7] = (unsigned int )0;
    sqlstm.sqadto[7] = (unsigned short )0;
    sqlstm.sqtdso[7] = (unsigned short )0;
    sqlstm.sqhstv[8] = ( void *)&oi_next_half;
    sqlstm.sqhstl[8] = (unsigned int )sizeof(int);
    sqlstm.sqhsts[8] = ( int )0;
    sqlstm.sqindv[8] = ( void *)0;
    sqlstm.sqinds[8] = ( int )0;
    sqlstm.sqharm[8] = (unsigned int )0;
    sqlstm.sqadto[8] = (unsigned short )0;
    sqlstm.sqtdso[8] = (unsigned short )0;
    sqlstm.sqhstv[9] = ( void *)&oi_day_454;
    sqlstm.sqhstl[9] = (unsigned int )sizeof(int);
    sqlstm.sqhsts[9] = ( int )0;
    sqlstm.sqindv[9] = ( void *)0;
    sqlstm.sqinds[9] = ( int )0;
    sqlstm.sqharm[9] = (unsigned int )0;
    sqlstm.sqadto[9] = (unsigned short )0;
    sqlstm.sqtdso[9] = (unsigned short )0;
    sqlstm.sqhstv[10] = ( void *)&oi_week_454;
    sqlstm.sqhstl[10] = (unsigned int )sizeof(int);
    sqlstm.sqhsts[10] = ( int )0;
    sqlstm.sqindv[10] = ( void *)0;
    sqlstm.sqinds[10] = ( int )0;
    sqlstm.sqharm[10] = (unsigned int )0;
    sqlstm.sqadto[10] = (unsigned short )0;
    sqlstm.sqtdso[10] = (unsigned short )0;
    sqlstm.sqhstv[11] = ( void *)&oi_month_454;
    sqlstm.sqhstl[11] = (unsigned int )sizeof(int);
    sqlstm.sqhsts[11] = ( int )0;
    sqlstm.sqindv[11] = ( void *)0;
    sqlstm.sqinds[11] = ( int )0;
    sqlstm.sqharm[11] = (unsigned int )0;
    sqlstm.sqadto[11] = (unsigned short )0;
    sqlstm.sqtdso[11] = (unsigned short )0;
    sqlstm.sqhstv[12] = ( void *)&oi_year_454;
    sqlstm.sqhstl[12] = (unsigned int )sizeof(int);
    sqlstm.sqhsts[12] = ( int )0;
    sqlstm.sqindv[12] = ( void *)0;
    sqlstm.sqinds[12] = ( int )0;
    sqlstm.sqharm[12] = (unsigned int )0;
    sqlstm.sqadto[12] = (unsigned short )0;
    sqlstm.sqtdso[12] = (unsigned short )0;
    sqlstm.sqhstv[13] = ( void *)&oi_month_no;
    sqlstm.sqhstl[13] = (unsigned int )sizeof(int);
    sqlstm.sqhsts[13] = ( int )0;
    sqlstm.sqindv[13] = ( void *)0;
    sqlstm.sqinds[13] = ( int )0;
    sqlstm.sqharm[13] = (unsigned int )0;
    sqlstm.sqadto[13] = (unsigned short )0;
    sqlstm.sqtdso[13] = (unsigned short )0;
    sqlstm.sqhstv[14] = ( void *)&oi_week_no;
    sqlstm.sqhstl[14] = (unsigned int )sizeof(int);
    sqlstm.sqhsts[14] = ( int )0;
    sqlstm.sqindv[14] = ( void *)0;
    sqlstm.sqinds[14] = ( int )0;
    sqlstm.sqharm[14] = (unsigned int )0;
    sqlstm.sqadto[14] = (unsigned short )0;
    sqlstm.sqtdso[14] = (unsigned short )0;
    sqlstm.sqphsv = sqlstm.sqhstv;
    sqlstm.sqphsl = sqlstm.sqhstl;
    sqlstm.sqphss = sqlstm.sqhsts;
    sqlstm.sqpind = sqlstm.sqindv;
    sqlstm.sqpins = sqlstm.sqinds;
    sqlstm.sqparm = sqlstm.sqharm;
    sqlstm.sqparc = sqlstm.sqharc;
    sqlstm.sqpadto = sqlstm.sqadto;
    sqlstm.sqptdso = sqlstm.sqtdso;
    sqlcxt((void **)0, &sqlctx, &sqlstm, &sqlfpn);
    }


    if SQL_ERROR_FOUND
    {
    sprintf(err_data,"Update");
    WRITE_ERROR(SQLCODE,function,"period",err_data);
    return(-1);
    }
    /* After vdate is changed, see if update needed for eow, eom */
    /* ** See if new indate is in the future or in the past. */

    if (update_unit() < 0) return (-1);

    return(0);

    } /* end of process */


    int calc_half()
    {
    char *function= "calc_half";

    if (CAL_TO_454(oi_cal_day, oi_cal_month, oi_cal_year,
    &oi_day_454, &oi_week_454, &oi_month_454, &oi_year_454) < 0)
    {
    sprintf(err_data,"CAL_TO_454 conversion error");
    WRITE_ERROR(RET_FUNCTION_ERR,function,"",err_data);
    return(-1);
    }

    sprintf(os_indate,"%.04d%.02d%.02d", oi_cal_year,oi_cal_month,oi_cal_day);

    if (CAL_TO_454_HALF(oi_cal_day, oi_cal_month, oi_cal_year,
    &oi_half_no, &oi_month_no) < 0)
    {
    sprintf(err_data,"CAL_TO_454_HALF error");
    WRITE_ERROR(RET_FUNCTION_ERR,function,"",err_data);
    return(-1);
    }

    if (HALF_TO_454_FDOH(oi_half_no, &oi_work_day, &oi_work_month, &oi_work_year)
    < 0)
    {
    sprintf(err_data,"HALF_TO_454_FDOH conversion error");
    WRITE_ERROR(RET_FUNCTION_ERR,function,"",err_data);
    return(-1);
    }

    sprintf(os_fdoh, "%.04d%.02d%.02d", oi_work_year, oi_work_month, oi_work_day);

    if (HALF_TO_454_LDOH(oi_half_no, &oi_work_day, &oi_work_month, &oi_work_year) < 0)
    {
    sprintf(err_data,"HALF_TO_454_LDOH conversion error");
    WRITE_ERROR(RET_FUNCTION_ERR,function,"",err_data);
    return(-1);
    }

    sprintf(os_ldoh, "%.04d%.02d%.02d", oi_work_year, oi_work_month, oi_work_day);

    if (oi_half_no % 10 - 1)
    oi_next_half = oi_half_no + 9;
    else
    oi_next_half = oi_half_no + 1;


    return(0);
    } /* end of calc_half */

    int calc_month()
    {
    char *function = "calc_month";

    if (CAL_TO_454_FDOM(oi_cal_day, oi_cal_month, oi_cal_year,
    &oi_work_day, &oi_work_month, &oi_work_year) < 0)
    {
    sprintf(err_data,"CAL_TO_454_FDOM conversion error ");
    WRITE_ERROR(RET_FUNCTION_ERR,function,"",err_data);
    return(-1);
    }

    sprintf(os_fdom, "%.04d%.02d%.02d", oi_work_year, oi_work_month, oi_work_day);

    sprintf(os_midm, "%.04d%.02d15", oi_year_454, oi_month_454);

    if (CAL_TO_454_LDOM(oi_cal_day, oi_cal_month, oi_cal_year,
    &oi_work_day, &oi_work_month, &oi_work_year) < 0)
    {
    sprintf(err_data,"CAL_TO_454_LDOM conversion error ");
    WRITE_ERROR(RET_FUNCTION_ERR,function,"",err_data);
    return(-1);
    }
    sprintf(os_ldom, "%.04d%.02d%.02d", oi_work_year, oi_work_month, oi_work_day);

    return(0);
    } /* end of calc_month */

    int calc_week()
    {
    char *function = "calc_week";

    if (CAL_TO_454_WNO(oi_cal_day, oi_cal_month, oi_cal_year, &oi_week_no) < 0)
    {
    sprintf(err_data,"CAL_TO_454_WNO conversion error ");
    WRITE_ERROR(RET_FUNCTION_ERR,function,"",err_data);
    return(-1);
    }

    /* calculate the new first and last day of the week from 4_5_4 date.*/
    if (C454_TO_CAL(1,oi_week_454,oi_month_454,oi_year_454,
    &oi_work_day, &oi_work_month, &oi_work_year) < 0)
    {
    sprintf(err_data,"C454_TO_CAL conversion error ");
    WRITE_ERROR(RET_FUNCTION_ERR,function,"",err_data);
    return(-1);
    }

    sprintf(os_fdow, "%.04d%.02d%.02d", oi_work_year, oi_work_month, oi_work_day);

    if (C454_TO_CAL(7,oi_week_454,oi_month_454,oi_year_454,
    &oi_work_day, &oi_work_month, &oi_work_year) < 0)
    {
    sprintf(err_data,"C454_TO_CAL conversion error ");
    WRITE_ERROR(RET_FUNCTION_ERR,function,"",err_data);
    return(-1);
    }

    sprintf(os_ldow, "%.04d%.02d%.02d", oi_work_year, oi_work_month, oi_work_day);
    return(0);
    } /* end of calc_week */

    /**********************************/
    /* added for eow / eom */
    /**********************************/
    int update_unit()
    {
    char *function = "update_unit";
    /* EXEC SQL UPDATE system_variables
    SET system_variables.last_eom_date_unit
    = TO_DATE(:os_fdom) - 1,
    system_variables.next_eom_date_unit
    = TO_DATE(:os_ldom),
    system_variables.last_eow_date_unit
    = TO_DATE(:os_fdow) - 1,
    system_variables.next_eow_date_unit
    = TO_DATE(:os_ldow); */

    {
    struct sqlexd sqlstm;
    sqlstm.sqlvsn = 12;
    sqlstm.arrsiz = 15;
    sqlstm.sqladtp = &sqladt;
    sqlstm.sqltdsp = &sqltds;
    sqlstm.stmt = "update system_variables set system_variables.last_eom_da\
    te_unit=(TO_DATE(:b0)-1),system_variables.next_eom_date_unit=TO_DATE(:b1),syst\
    em_variables.last_eow_date_unit=(TO_DATE(:b2)-1),system_variables.next_eow_dat\
    e_unit=TO_DATE(:b3)";
    sqlstm.iters = (unsigned int )1;
    sqlstm.offset = (unsigned int )220;
    sqlstm.cud = sqlcud0;
    sqlstm.sqlest = (unsigned char *)&sqlca;
    sqlstm.sqlety = (unsigned short)4352;
    sqlstm.occurs = (unsigned int )0;
    sqlstm.sqhstv[0] = ( void *)os_fdom;
    sqlstm.sqhstl[0] = (unsigned int )15;
    sqlstm.sqhsts[0] = ( int )0;
    sqlstm.sqindv[0] = ( void *)0;
    sqlstm.sqinds[0] = ( int )0;
    sqlstm.sqharm[0] = (unsigned int )0;
    sqlstm.sqadto[0] = (unsigned short )0;
    sqlstm.sqtdso[0] = (unsigned short )0;
    sqlstm.sqhstv[1] = ( void *)os_ldom;
    sqlstm.sqhstl[1] = (unsigned int )15;
    sqlstm.sqhsts[1] = ( int )0;
    sqlstm.sqindv[1] = ( void *)0;
    sqlstm.sqinds[1] = ( int )0;
    sqlstm.sqharm[1] = (unsigned int )0;
    sqlstm.sqadto[1] = (unsigned short )0;
    sqlstm.sqtdso[1] = (unsigned short )0;
    sqlstm.sqhstv[2] = ( void *)os_fdow;
    sqlstm.sqhstl[2] = (unsigned int )15;
    sqlstm.sqhsts[2] = ( int )0;
    sqlstm.sqindv[2] = ( void *)0;
    sqlstm.sqinds[2] = ( int )0;
    sqlstm.sqharm[2] = (unsigned int )0;
    sqlstm.sqadto[2] = (unsigned short )0;
    sqlstm.sqtdso[2] = (unsigned short )0;
    sqlstm.sqhstv[3] = ( void *)os_ldow;
    sqlstm.sqhstl[3] = (unsigned int )15;
    sqlstm.sqhsts[3] = ( int )0;
    sqlstm.sqindv[3] = ( void *)0;
    sqlstm.sqinds[3] = ( int )0;
    sqlstm.sqharm[3] = (unsigned int )0;
    sqlstm.sqadto[3] = (unsigned short )0;
    sqlstm.sqtdso[3] = (unsigned short )0;
    sqlstm.sqphsv = sqlstm.sqhstv;
    sqlstm.sqphsl = sqlstm.sqhstl;
    sqlstm.sqphss = sqlstm.sqhsts;
    sqlstm.sqpind = sqlstm.sqindv;
    sqlstm.sqpins = sqlstm.sqinds;
    sqlstm.sqparm = sqlstm.sqharm;
    sqlstm.sqparc = sqlstm.sqharc;
    sqlstm.sqpadto = sqlstm.sqadto;
    sqlstm.sqptdso = sqlstm.sqtdso;
    sqlcxt((void **)0, &sqlctx, &sqlstm, &sqlfpn);
    }


    if SQL_ERROR_FOUND
    {
    sprintf(err_data,"Update");
    WRITE_ERROR(SQLCODE,function,"system_variables",err_data);
    return(-1);
    }

    /* check to see if the previous next_eom_date_unit is the same as the
    current last_eom_date_unit. If they are not and the ldom is actually
    greater than the previous next_eom_date_unit, a log message will be
    written to indicate that a period has been skipped.
    */
    if (!pi_day_increment_sw)
    {
    if (strcmp(os_ldom, os_next_eom_date_unit) > 0)
    {
    LOG_MESSAGE("Alert condition: Current date has been\n" \
    "advanced to a period beyond the expected next unit month.");
    }
    if (strcmp(os_ldow, os_next_eow_date_unit) > 0)
    {
    LOG_MESSAGE("Alert condition: Current date has been\n" \
    "advanced to a period beyond the expected next unit week.");

    }
    }

    return(0);
    }



    int final()
    {
    return(0);
    }

  2. #2
    Membre à l'essai
    Homme Profil pro
    Architecte technique
    Inscrit en
    Août 2009
    Messages
    12
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 57
    Localisation : France, Hauts de Seine (Île de France)

    Informations professionnelles :
    Activité : Architecte technique
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Août 2009
    Messages : 12
    Points : 15
    Points
    15
    Par défaut
    Je ne comprends pas le code! Ce n'est pas du C!
    Attention à ne pas confondre PRO*C/SQL ou ,PRO*C/PL-SQL et C!

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    IF (argc != 2 && argc != 3)
    est différent de celui-ci à la syntaxe correcte
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    if (argc != 2 && argc != 3)

  3. #3
    Modérateur
    Avatar de Waldar
    Homme Profil pro
    Customer Success Manager @Vertica
    Inscrit en
    Septembre 2008
    Messages
    8 452
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 46
    Localisation : France, Val de Marne (Île de France)

    Informations professionnelles :
    Activité : Customer Success Manager @Vertica
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Septembre 2008
    Messages : 8 452
    Points : 17 820
    Points
    17 820
    Par défaut
    Les IF en majuscule viennent de l'interpréteur de code du forum, qui change la casse des mots clefs qu'il reconnaît.

    En général ça ne pose pas de problème, ici apparemment c'est le cas, je modifie la balise originale.

  4. #4
    Membre à l'essai
    Homme Profil pro
    Architecte technique
    Inscrit en
    Août 2009
    Messages
    12
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 57
    Localisation : France, Hauts de Seine (Île de France)

    Informations professionnelles :
    Activité : Architecte technique
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Août 2009
    Messages : 12
    Points : 15
    Points
    15
    Par défaut
    L'OS cible sur lequel le programme doit fonctionner n'est pas précisé ni la version de gcc...
    Toujours est-il que je préconiserais bien les options suivantes:
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    ./proc code=ANSI_C iname=dtesys.pc oname=dtesys.c userid=log/pass@SID\ SQLCHECK=FULL
    Éventuellement le flag -stdc pour gcc également

  5. #5
    Membre du Club
    Profil pro
    Inscrit en
    Mai 2006
    Messages
    105
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Mai 2006
    Messages : 105
    Points : 52
    Points
    52
    Par défaut
    Merci pour vos réponse malheureusement je suis vraiment null en C. Je viens de tester la dernière commande et une fois mon fichier *.c générer je lance la commande suivante:

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    gcc -o dtesys dtesys.c -Wall
    Et j'obtiens les message suivant :

    /tmp/ccRrJxmL.o: In function `main':
    dtesys.c:(.text+0x77): undefined reference to `LOGON'
    dtesys.c:(.text+0x103): undefined reference to `sqlcxt'
    dtesys.c:(.text+0x1c2): undefined reference to `sqlcxt'
    dtesys.c:(.text+0x1d8): undefined reference to `LOG_MESSAGE'
    Je suppose qu'il ne trouve pas mon lib.h mis en entête du fichier. Y-a-t-il une option pour lui spécifier ce *.h.

    Merci

  6. #6
    Membre du Club
    Profil pro
    Inscrit en
    Mai 2006
    Messages
    105
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Mai 2006
    Messages : 105
    Points : 52
    Points
    52
    Par défaut
    Je viens de modifier la ligne de commande de gcc afin de prendre en compte les librairies et voilà la ligne:

    Avec la première ligne sans le -I/usr/include/linux

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    gcc -o dtesys dtesys.c -I/apps/retek92_fnac_dev/rms9000_src/oracle/lib/src -I/apps/oracle/Middleware/as_1/precomp/public -I/apps/oracle/Middleware/as_1/ -I/apps/oracle/Middleware/as_1/rdbms/public -I/apps/oracle/Middleware/as_1/plsql/include -I/apps/oracle/Middleware/as_1/ohs/include -I/usr/lib/gcc/i686-redhat-linux/4.4.4
    J'obients:

    /tmp/ccutgFu0.o: In function `main':
    dtesys.c:(.text+0x77): undefined reference to `LOGON'
    dtesys.c:(.text+0x103): undefined reference to `sqlcxt'
    dtesys.c:(.text+0x1c2): undefined reference to `sqlcxt'
    dtesys.c:(.text+0x1d8): undefined reference to `LOG_MESSAGE'
    dtesys.c:(.text+0x265): undefined reference to `sqlcxt'
    dtesys.c:(.text+0x27b): undefined reference to `LOG_MESSAGE'
    dtesys.c:(.text+0x308): undefined reference to `sqlcxt'
    dtesys.c:(.text+0x31e): undefined reference to `LOG_MESSAGE'
    dtesys.c:(.text+0x39e): undefined reference to `sqlcxt'
    dtesys.c:(.text+0x3b4): undefined reference to `CHECK_STATUS'
    dtesys.c:(.text+0x3d0): undefined reference to `LOG_MESSAGE'
    /tmp/ccutgFu0.o: In function `process':
    dtesys.c:(.text+0x49e): undefined reference to `sqlcxt'
    dtesys.c:(.text+0x4fe): undefined reference to `WRITE_ERROR'
    dtesys.c:(.text+0x7ae): undefined reference to `sqlcxt'
    dtesys.c:(.text+0x837): undefined reference to `WRITE_ERROR'
    dtesys.c:(.text+0x8cb): undefined reference to `sqlcxt'
    dtesys.c:(.text+0x948): undefined reference to `WRITE_ERROR'
    dtesys.c:(.text+0xf55): undefined reference to `sqlcxt'
    dtesys.c:(.text+0xfb5): undefined reference to `WRITE_ERROR'
    /tmp/ccutgFu0.o: In function `calc_half':
    dtesys.c:(.text+0x1022): undefined reference to `CAL_TO_454'
    dtesys.c:(.text+0x1066): undefined reference to `WRITE_ERROR'
    dtesys.c:(.text+0x10d4): undefined reference to `CAL_TO_454_HALF'
    dtesys.c:(.text+0x1118): undefined reference to `WRITE_ERROR'
    dtesys.c:(.text+0x1147): undefined reference to `HALF_TO_454_FDOH'
    dtesys.c:(.text+0x118b): undefined reference to `WRITE_ERROR'
    dtesys.c:(.text+0x11ed): undefined reference to `HALF_TO_454_LDOH'
    dtesys.c:(.text+0x1231): undefined reference to `WRITE_ERROR'
    /tmp/ccutgFu0.o: In function `calc_month':
    dtesys.c:(.text+0x1304): undefined reference to `CAL_TO_454_FDOM'
    dtesys.c:(.text+0x1348): undefined reference to `WRITE_ERROR'
    dtesys.c:(.text+0x13e7): undefined reference to `CAL_TO_454_LDOM'
    dtesys.c:(.text+0x142b): undefined reference to `WRITE_ERROR'
    /tmp/ccutgFu0.o: In function `calc_week':
    dtesys.c:(.text+0x14a7): undefined reference to `CAL_TO_454_WNO'
    dtesys.c:(.text+0x14eb): undefined reference to `WRITE_ERROR'
    dtesys.c:(.text+0x1536): undefined reference to `C454_TO_CAL'
    dtesys.c:(.text+0x157a): undefined reference to `WRITE_ERROR'
    dtesys.c:(.text+0x15f8): undefined reference to `C454_TO_CAL'
    dtesys.c:(.text+0x163c): undefined reference to `WRITE_ERROR'
    /tmp/ccutgFu0.o: In function `update_unit':
    dtesys.c:(.text+0x18dc): undefined reference to `sqlcxt'
    dtesys.c:(.text+0x193c): undefined reference to `WRITE_ERROR'
    dtesys.c:(.text+0x1970): undefined reference to `LOG_MESSAGE'
    dtesys.c:(.text+0x1994): undefined reference to `LOG_MESSAGE'
    collect2: ld returned 1 exit status
    la seconde ligne avec -I/usr/include/linux

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    gcc -o dtesys dtesys.c -I/apps/retek92_fnac_dev/rms9000_src/oracle/lib/src -I/apps/oracle/Middleware/as_1/precomp/public -I/apps/oracle/Middleware/as_1/ -I/apps/oracle/Middleware/as_1/rdbms/public -I/apps/oracle/Middleware/as_1/plsql/include -I/apps/oracle/Middleware/as_1/ohs/include -I/usr/lib/gcc/i686-redhat-linux/4.4.4 -I/usr/include/linux
    et j'obtiens:

    In file included from /usr/include/stdio.h:75,
    from /usr/include/retek.h:36,
    from dtesys.c:160:
    /usr/include/libio.h:332: error: expected specifier-qualifier-list before âsize_tâ
    /usr/include/libio.h:364: error: expected declaration specifiers or â...â before âsize_tâ
    /usr/include/libio.h:373: error: expected declaration specifiers or â...â before âsize_tâ
    /usr/include/libio.h:495: error: expected â=â, â,â, â;â, âasmâ or â__attribute__â before â_IO_sgetnâ
    In file included from /usr/include/retek.h:36,
    from dtesys.c:160:
    /usr/include/stdio.h:318: error: expected declaration specifiers or â...â before âsize_tâ
    /usr/include/stdio.h:324: error: expected declaration specifiers or â...â before âsize_tâ
    /usr/include/stdio.h:336: error: expected declaration specifiers or â...â before âsize_tâ
    /usr/include/stdio.h:343: error: expected declaration specifiers or â...â before âsize_tâ
    /usr/include/stdio.h:385: error: expected declaration specifiers or â...â before âsize_tâ
    /usr/include/stdio.h:387: error: format string argument not a string type
    /usr/include/stdio.h:389: error: expected declaration specifiers or â...â before âsize_tâ
    /usr/include/stdio.h:661: error: expected declaration specifiers or â...â before âsize_tâ
    /usr/include/stdio.h:664: error: expected declaration specifiers or â...â before âsize_tâ
    /usr/include/stdio.h:674: error: expected declaration specifiers or â...â before âsize_tâ
    /usr/include/stdio.h:704: error: expected â=â, â,â, â;â, âasmâ or â__attribute__â before âfreadâ
    /usr/include/stdio.h:710: error: expected â=â, â,â, â;â, âasmâ or â__attribute__â before âfwriteâ
    /usr/include/stdio.h:732: error: expected â=â, â,â, â;â, âasmâ or â__attribute__â before âfread_unlockedâ
    /usr/include/stdio.h:734: error: expected â=â, â,â, â;â, âasmâ or â__attribute__â before âfwrite_unlockedâ
    In file included from /usr/include/retek.h:37,
    from dtesys.c:160:
    /usr/include/stdlib.h:140: error: expected â=â, â,â, â;â, âasmâ or â__attribute__â before â__ctype_get_mb_cur_maxâ
    In file included from /usr/include/sys/select.h:46,
    from /usr/include/sys/types.h:220,
    from /usr/include/stdlib.h:320,
    from /usr/include/retek.h:37,
    from dtesys.c:160:
    /usr/include/bits/time.h:76: error: redefinition of âstruct timevalâ
    In file included from /usr/include/retek.h:37,
    from dtesys.c:160:
    /usr/include/stdlib.h:337: error: expected declaration specifiers or â...â before âsize_tâ
    /usr/include/stdlib.h:367: error: expected declaration specifiers or â...â before âsize_tâ
    /usr/include/stdlib.h:369: error: nonnull argument with out-of-range operand number (argument 1, operand 4)
    /usr/include/stdlib.h:471: error: expected â)â before â__sizeâ
    /usr/include/stdlib.h:473: error: expected â)â before â__nmembâ
    /usr/include/stdlib.h:485: error: expected declaration specifiers or â...â before âsize_tâ
    In file included from /usr/include/stdlib.h:497,
    from /usr/include/retek.h:37,
    from dtesys.c:160:
    /usr/include/alloca.h:33: error: expected â)â before â__sizeâ
    In file included from /usr/include/retek.h:37,
    from dtesys.c:160:
    /usr/include/stdlib.h:503: error: expected â)â before â__sizeâ
    /usr/include/stdlib.h:508: error: expected declaration specifiers or â...â before âsize_tâ
    /usr/include/stdlib.h:508: error: expected declaration specifiers or â...â before âsize_tâ
    /usr/include/stdlib.h:756: error: expected declaration specifiers or â...â before âsize_tâ
    /usr/include/stdlib.h:756: error: expected declaration specifiers or â...â before âsize_tâ
    /usr/include/stdlib.h:757: error: nonnull argument with out-of-range operand number (argument 1, operand 5)
    /usr/include/stdlib.h:761: error: expected declaration specifiers or â...â before âsize_tâ
    /usr/include/stdlib.h:761: error: expected declaration specifiers or â...â before âsize_tâ
    /usr/include/stdlib.h:762: error: nonnull argument with out-of-range operand number (argument 1, operand 4)
    /usr/include/stdlib.h:840: error: expected declaration specifiers or â...â before âsize_tâ
    /usr/include/stdlib.h:843: error: expected declaration specifiers or â...â before âsize_tâ
    /usr/include/stdlib.h:847: error: expected declaration specifiers or â...â before âsize_tâ
    /usr/include/stdlib.h:851: error: expected declaration specifiers or â...â before âsize_tâ
    /usr/include/stdlib.h:860: error: expected declaration specifiers or â...â before âsize_tâ
    /usr/include/stdlib.h:863: error: expected â)â before â*â token
    /usr/include/stdlib.h:867: error: expected declaration specifiers or â...â before âwchar_tâ
    /usr/include/stdlib.h:871: error: expected â=â, â,â, â;â, âasmâ or â__attribute__â before âmbstowcsâ
    /usr/include/stdlib.h:874: error: expected â=â, â,â, â;â, âasmâ or â__attribute__â before âwcstombsâ
    In file included from /usr/include/sys/ioctl.h:30,
    from /usr/include/termio.h:6,
    from /usr/include/retek.h:41,
    from dtesys.c:160:
    /usr/include/bits/ioctl-types.h:29: error: redefinition of âstruct winsizeâ
    /usr/include/bits/ioctl-types.h:38: error: redefinition of âstruct termioâ
    dtesys.c: In function âmainâ:
    dtesys.c:284: warning: incompatible implicit declaration of built-in function âstrcpyâ
    je ne sais plus quoi faire :(

Discussions similaires

  1. [debutant] compilation gcc et makefile
    Par harsh dans le forum Systèmes de compilation
    Réponses: 4
    Dernier message: 08/06/2006, 18h30
  2. Compilation gcc -shared -c *.c Puis archivage ?
    Par FrigoAcide dans le forum Autres éditeurs
    Réponses: 4
    Dernier message: 09/05/2006, 10h24
  3. Erreur compilation GCC
    Par KnightsOfTheRound dans le forum GCC
    Réponses: 8
    Dernier message: 07/11/2005, 15h28
  4. [PRO*C] compilation oracle 8.1.7
    Par fanette dans le forum Interfaces de programmation
    Réponses: 8
    Dernier message: 27/06/2005, 11h07
  5. Option de compilation gcc : sem.h
    Par Luther13 dans le forum Linux
    Réponses: 8
    Dernier message: 29/12/2004, 12h29

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo