Thread: What does this error mean?

  1. #1
    Registered User
    Join Date
    Apr 2008
    Posts
    115

    What does this error mean?

    ESQL project.sc:
    %% Error in file project.sc, Line 44:
    E_E00004 Last component of structure reference 'cc_lkup[y].cc' is illegal.

    %% Error in file project.sc, Line 44:
    E_E00004 Last component of structure reference 'cc_lkup[y].cc_sn' is
    illegal.

    %% Error in file project.sc, Line 44:
    E_E00004 Last component of structure reference 'cc_lkup[y].cc_desc' is
    illegal.

    %% Error in file project.sc, Line 45:
    E_E00004 Last component of structure reference 'cc_lkup[y].cc_grp' is
    illegal.

    make: 1254-004 The error code from the last command is 255.


    Code:
    #include <stdio.h>
    #include<stdlib.h>
    #include<strings.h>
    #include<string.h>
    #include"imcs_params.h"
    #include"jnl_struct.h"
    #include"misc.h"
    #include"err_supv.h"
    
    
    int main (int argc, char **argv)
    {
     int reccnt = 0;
     JNL_STRUCT   jnl;
     int y = 0;
     int x = 0;
     char log_file[] = "stdout";
    
    EXEC SQL BEGIN DECLARE SECTION;
    
    typedef struct cc_lkup_ {
        short   cc;
        char    cc_suf[2];
        char    cc_sn[11];
        char    cc_desc[41];
        short   prd_rpt_id;
        short   rpt_cc;
        char    sfdc_grp[41];
        char    cc_grp[41];
        char    proc_grp[3];
        char    proc_grp_desc[16];
        short   cc_typ;
        char    resp_company[4];
        char    rpt_tbl[33];
      } cc_lkup;
    
    EXEC SQL END DECLARE SECTION;
    
    memset (&cc_lkup, 0, sizeof(cc_lkup));
    
    /*Get records from database table cc_lkup*/
    EXEC SQL SELECT cc, cc_sn, cc_desc, cc_grp
             INTO :cc_lkup[y].cc, :cc_lkup[y].cc_sn, :cc_lkup[y].cc_desc, :cc_lkup[y].cc_grp
             FROM cc_lkup;
             EXEC SQL BEGIN;
             ++y;
             EXEC SQL END;
    
    /* Verify no errors were encountered during SELECT statement */
     status = err_supv(apl_nm, prog_nm, jnl.blk, stmt_purpose, &retry_cnt,
              &err_num, err_txt, &row_count, jnl.val1, jnl.val2, popup_flag);
    
    /* EXIT PROGRAM IF ERROR SELECTING RECORDS*/
     if (status != IMCS_DB_SUCCESS)
         exit(1);
    
    /*WRITE PURPOSE OF CODE TO THE LOG FILE*/
    jnl.blk = 1999;
    sprintf(stmt_purpose,"selecting all records in the table cc_lkup by Carl J");
    log_it(log_file, jnl);
    "project.sc" 78L, 1872C
    
    log_it(log_file, jnl);
    
    /* PRINT TO SCREEN */
    
    /*READ ALL RECORDS FOUND IN TABLE - TOTAL IS STORED IN variable COUNT*/
     for( x = 0; x < row_count; x++ )
      {
      printf("COST CENTER NUMBER:%d  LOCATION:%s  DESCRIPTION:%s  GROUP NUMBER:%s\n", cc_lkup[x].cc,  cc_lkup[x].cc_sn,  cc_lkup[x].cc_desc,  cc_lkup[x].cc_grp);
      }
    
    return 0;
    }

  2. #2
    Jack of many languages Dino's Avatar
    Join Date
    Nov 2007
    Location
    Chappell Hill, Texas
    Posts
    2,332
    It means you are referencing a non-array variable declaration as an array.

    cc_lkup is not an array of structures, it's just a single instance of a structure.
    Mainframe assembler programmer by trade. C coder when I can.

  3. #3
    Jack of many languages Dino's Avatar
    Join Date
    Nov 2007
    Location
    Chappell Hill, Texas
    Posts
    2,332
    This is what we've been saying:

    Code:
    #include <stdio.h>
    #include<stdlib.h>
    #include<strings.h>
    #include<string.h>
    #include"imcs_params.h"
    #include"jnl_struct.h"
    #include"misc.h"
    #include"err_supv.h"
    
    int main (int argc, char **argv)
    {
    	int reccnt = 0;
    	JNL_STRUCT   jnl;
    	char log_file[] = "stdout";
    
    EXEC SQL BEGIN DECLARE SECTION;
    
    	typedef struct cc_lkup_ {
    	short   cc;
    	char    cc_suf[2];
    	char    cc_sn[11];
    	char    cc_desc[41];
    	short   prd_rpt_id;
    	short   rpt_cc;
    	char    sfdc_grp[41];
    	char    cc_grp[41];
    	char    proc_grp[3];
    	char    proc_grp_desc[16];
    	short   cc_typ;
    	char    resp_company[4];
    	char    rpt_tbl[33];
    } cc_lkup;
    
    EXEC SQL END DECLARE SECTION;
    
    memset (&cc_lkup, 0, sizeof(cc_lkup));
    
    /*Get records from database table cc_lkup*/
    EXEC SQL SELECT cc, cc_sn, cc_desc, cc_grp
    		INTO :cc_lkup.cc, :cc_lkup.cc_sn, :cc_lkup.cc_desc, :cc_lkup.cc_grp
    		FROM cc_lkup;
    
    /* Verify no errors were encountered during SELECT statement */
    	status = err_supv(apl_nm, prog_nm, jnl.blk, stmt_purpose, &retry_cnt,
    		&err_num, err_txt, &row_count, jnl.val1, jnl.val2, popup_flag);
    
    /* EXIT PROGRAM IF ERROR SELECTING RECORDS*/
    	if (status != IMCS_DB_SUCCESS)
    		exit(1);
    
    /*WRITE PURPOSE OF CODE TO THE LOG FILE*/
    	jnl.blk = 1999;
    	sprintf(stmt_purpose,"selecting all records in the table cc_lkup by Carl J");
    	log_it(log_file, jnl);
    //	"project.sc" 78L, 1872C
    //	log_it(log_file, jnl);
    
    /*PRINT THE ONLY RECORD RETURNED */
    
    	printf("COST CENTER NUMBER:%d  LOCATION:%s  DESCRIPTION:%s  GROUP NUMBER:%s\n", 
    	cc_lkup.cc,  cc_lkup.cc_sn,  cc_lkup.cc_desc,  cc_lkup.cc_grp);
    
    	return 0;
    }
    Mainframe assembler programmer by trade. C coder when I can.

  4. #4
    Registered User slingerland3g's Avatar
    Join Date
    Jan 2008
    Location
    Seattle
    Posts
    603
    The syntax should be more like:

    [code]
    INTO :cc_lkup.cc[y], :cc_lkup.cc_sn[y], :cc_lkup.cc_desc[y], :cc_lkup.cc_grp[y]
    [code/]

    But this even looks odd, as I believe your assigned array sizes for those are not all equal. If y increments outside of one of your sized arrays, you will be going out of bounds and corrupting your memory stack. Also using memset, you may need to consider any padding issues with your struct.

  5. #5
    Registered User
    Join Date
    Apr 2008
    Posts
    115

    Finally - It works - Thanks for everyone's help - The code I used is below

    There is 2 functions not shown - log_it and ssw_opendb() - They are called from header files and open db and set some paramaters based on my .profile. Thanks again for everyone's help.

    -Carl

    Code:
    #include <stdio.h>
    #include<stdlib.h>
    #include<strings.h>
    #include<string.h>
    #include"imcs_params.h"
    #include"jnl_struct.h"
    #include"misc.h"
    #include"err_supv.h"
    
    #define mysize 500
    
    int init_db();
    JNL_STRUCT   jnl;
    char log_file[] = "stdout";
    char db_open='N';
    
    int main (int argc, char **argv)
    {
     int reccnt = 0;
     int y = 0;
     int x = 0;
    
    /* open db, set lockmode, and set rollback to transaction level*/
    /*INITIALIZE THE DATABASE*/
    if (init_db() != 0)
            exit(1);
    
    /*Write purpose of code to log*/
    jnl.blk = 1991;
    sprintf(stmt_purpose,"Initialized the DB by Carl J");
    log_it(log_file, jnl);
    
    /*************************************************/
    EXEC SQL BEGIN DECLARE SECTION;
    EXEC SQL INCLUDE "/imcs/devl/utl/inc/cc_lkup.h";
    struct cc_lkup_  cc_lkup2[mysize];
    EXEC SQL END DECLARE SECTION;
    /************************************************/
    
    /*INITIALIZE - ZERO OUT ARRAY OF STRUCTURES*/
    memset (&cc_lkup2, 0, sizeof(cc_lkup2));
    
    /*EXEC SQL DECLARE CURSOR CURSOR1 FOR SELECT cc, cc_sn, cc_desc, cc_grp
             FROM cc_lkup ;
    
    EXEC SQL OPEN CURSOR1 ;
    
    EXEC SQL FETCH CURSOR1 INTO  :cc, :cc_sn, :cc_desc, :cc_grp ;
    
    EXEC SQL CLOSE CURSOR1 ;*/
    
    /*Get records from database table cc_lkup*/
    EXEC SQL SELECT cc, cc_sn, cc_desc, cc_grp
             INTO :cc_lkup2[y].cc, :cc_lkup2[y].cc_sn, :cc_lkup2[y].cc_desc, :cc_lkup2[y].cc_grp
             FROM cc_lkup;
             EXEC SQL BEGIN;
             ++y;
             EXEC SQL END;
    
    /* Verify no errors were encountered during SELECT statement */
     status = err_supv(apl_nm, prog_nm, jnl.blk, stmt_purpose, &retry_cnt,
              &err_num, err_txt, &row_count, jnl.val1, jnl.val2, popup_flag);
    
    /* EXIT PROGRAM IF ERROR SELECTING RECORDS*/
     if (status != IMCS_DB_SUCCESS)
         exit(1);
    
    /*WRITE PURPOSE OF CODE TO THE LOG FILE*/
    jnl.blk = 1999;
    sprintf(stmt_purpose,"selecting all records in the table cc_lkup by Carl J");
    log_it(log_file, jnl);
    
    /* PRINT TO SCREEN */
    
    /*READ ALL RECORDS FOUND IN TABLE - TOTAL IS STORED IN variable COUNT*/
     for( x = 0; x < row_count; x++ )
      {
      printf("COST CENTER NUMBER:%d  LOCATION:%s  DESCRIPTION:%s  GROUP NUMBER:%s\n", cc_lkup2[x].cc,  cc_lkup2[x].cc_sn,  cc_lkup2[x].cc_desc,  cc_lkup2[x].cc_grp);
      }
    
    return (0);
    }
    
    int init_db()
    {
        if (ssw_opendb("imcsdb") != 0)
        {
            sprintf(jnl.mesg,"Unable to open database");
            log_it(log_file,jnl);
            return(1);
        }
    
        db_open = 'Y';
    
        strcpy(stmt_purpose,"set lockmode");
    
        EXEC SQL SET LOCKMODE SESSION WHERE READLOCK = NOLOCK, TIMEOUT=30;
    
        status = err_supv(apl_nm, prog_nm, jnl.blk, stmt_purpose, &retry_cnt,
            &err_num, err_txt, &row_count, jnl.val1, jnl.val2, popup_flag);
        if (status != IMCS_DB_SUCCESS)
        {
            sprintf(jnl.mesg,"Unable to %s",stmt_purpose);
            log_it(log_file,jnl);
            return(1);
        }
        else
            EXEC SQL COMMIT;
    
        strcpy(stmt_purpose,"set session to rollback transaction");
    
        EXEC SQL SET SESSION WITH ON_ERROR = ROLLBACK TRANSACTION;
    
        status = err_supv(apl_nm, prog_nm, jnl.blk, stmt_purpose, &retry_cnt,
            &err_num, err_txt, &row_count, jnl.val1, jnl.val2, popup_flag);
        if (status != IMCS_DB_SUCCESS)
        {
            sprintf(jnl.mesg,"Unable to %s",stmt_purpose);
            log_it(log_file,jnl);
            return(1);
        }
        else
            EXEC SQL COMMIT;
    
        return(0);
    }

  6. #6
    Jack of many languages Dino's Avatar
    Join Date
    Nov 2007
    Location
    Chappell Hill, Texas
    Posts
    2,332
    Well, it might work, but it ain't right.

    There's no point to have a loop or an array of 500 cc_lkup2's.
    Mainframe assembler programmer by trade. C coder when I can.

Popular pages Recent additions subscribe to a feed