» »

[ C ] floating point not loaded !!?

[ C ] floating point not loaded !!?

Fizikalko ::

Torej, ko izvajam C program (kompajliran z Borland VC 6.0) , mi vrže:

6002 error: floating point not loaded

Želim brat iz ebega fajla in pisat v bazo. Koda je 100% ok. Menda je treba neko opcijo dodat pri kompajliranju, da dodaš podporo za FP...

Prosim pomoč, čim prej...

Hvala že vnaprej.

Zvedavec ::

Zdi se mi, da je včasih pomagalo že, če si naredil v kodi eno spremenljivko tipa float in ji priredil eno vrednost (recimo 1.1) v kodi, da je prevajalnik opazil, da boš potreboval podporo za FP.

Fizikalko ::

Nak, ne pomaga... še kakšna ideja?

luli ::

Kaj če bi pokazal kodo?

Fizikalko ::

sem dodal v main:

float slo=sqrt(5);

Program se SESUJE! WTF?

Access violation.

Zgodovina sprememb…

  • spremenilo: Fizikalko ()

Fizikalko ::

Kako dodaš kodo sloh na forum? Ker zgleda pričakuje html in se pritožuje...

Trubadur ::

(st.koda c) (/st.koda c)

Zamenjaj () z []
Berite Thomasa!

Fizikalko ::

Ne štekam. Kje zdej pride koda - v oglatih oklepajih al kaj= Probal vse živo, pa noče vzet. Call me stupid, ampak, kako si to mislil

"st.kodac"??? Kaj je st? Res ne razumem...

Zgodovina sprememb…

  • spremenilo: Fizikalko ()

MaCoFaCo ::

Fizikalko ::


static char sqla_program_id[162] = 
{
 42,0,65,68,65,75,65,73,82,69,83,84,65,82,84,32,119,65,66,83,
 86,88,68,87,48,49,49,49,49,32,50,32,8,0,71,82,69,71,65,32,
 32,32,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
 0,0
};

#include "sqladef.h"

static struct sqla_runtime_info sqla_rtinfo = 
{{'S','Q','L','A','R','T','I','N'}, sizeof(wchar_t), 0, {' ',' ',' ',' '}};


static const short sqlIsLiteral   = SQL_IS_LITERAL;
static const short sqlIsInputHvar = SQL_IS_INPUT_HVAR;


#line 1 "restart.sqc"


/* Restart Program                                                   */ 
/*********************************************************************/
/* THIS BATCH PROGRAM READS IN EMPLOYEE DATA CONCERNING THEIR TAX    */
/* CLASS WITH MONTHLY AND YEARLY TAX EXEMPTIONS AND INSERTS THE      */
/* DETAILS ON TO A DB2 TABLE. EVERY 20 INSERTS ARE COMMITTED AND     */
/* CHECKPOINTED BY PUTTING THE DETAILS ON TO A RESTART TABLE.        */
/*********************************************************************/
/* PGM FLOW                                                          */
/* +---------------------------------------------------------------+ */
/* ! READ RESTART-TABLE (SQL)                                      ! */
/* +---------------------------------------------------------------+ */
/* ! IS THERE A ROW IN THE RESTART TABLE?                          ! */
/* ! YES                     ! NO                          !NEITHER! */
/* +-------------------------+-----------------------------+-------+ */
/* ! **** 1)(RESTART_ROUTINE)! NORMAL_ROUTINE              !4)     ! */
/* +-------------------------+-----------------------------+-------+ */
/* ! **** 2)(NORMAL_ROUTINE)                                       ! */
/* +---------------------------------------------------------------+ */
/* ! DELETE THE ROW IN THE RESTART TABLE (SQL)                     ! */
/* +---------------------------------------------------------------+ */
/* ! DELETE OK                                                     ! */
/* ! YES                                                   ! NO    ! */
/* +-------------------------------------------------------+-------+ */
/* ! END OF PGM                                            ! 4)    ! */
/* +-------------------------------------------------------+-------+ */
/*********************************************************************/
/*********************************************************************/
/* 1) SUBROUTINE RESTART_ROUTINE *********************************** */
/* +-+-------------------------------------------------------------+ */
/* ! ! READ Input-FILE                                             ! */
/* ! +-------------------------------------------------------------+ */
/* ! ! EOF Input-FILE?                                             ! */
/* ! ! NO                  ! YES                                   ! */
/* ! +---------------------+---------------------------------------+ */
/* ! !                     ! ERROR ROUTINE                         ! */
/* ! !          %          +---------------------------------------+ */
/* ! !                     ! ABNORMAL PROGRAM END                  ! */
/* ! +---------------------+---------------------------------------+ */
/* ! DO UNTIL (EOF OR THE DATA FROM THE RESTART TABLE              ! */
/* !                  = THE DATA FROM THE Input-FILE)              ! */
/* +---------------------------------------------------------------+ */
/* ! END OF ROUTINE                                                ! */
/* +---------------------------------------------------------------+ */
/*********************************************************************/
/*--*/
/*********************************************************************/
/* 2) SUBROUTINE NORMAL_ROUTINE ************************************ */
/* +---------------------------------------------------------------+ */
/* ! READ  Input-FILE (FIRST RECORD IF NORMAL OR                   ! */
/* !                     NEXT RECORD IF A RESTART)                 ! */
/* +---------------------------------------------------------------+ */
/* ! DO WHILE (Input-FILE NOT EOF)                                 ! */
/* ! +-------------------------------------------------------------+ */
/* ! ! UPDATE EMPLOYEE TABLE (SQL)                                 ! */
/* ! +-------------------------------------------------------------+ */
/* ! ! EMPLOYEE FOUND?                                             ! */
/* ! ! YES       ! NO                                      !NEITHER! */
/* ! +-----------+-----------------------------------------+-------+ */
/* ! !    %      ! ERROR MESSAGE                           !  4)   ! */
/* ! +-----------+-----------------------------------------+-------+ */
/* ! ! IS NUMBER OF RECORDS READ > CHECKPOINT LIMIT?               ! */
/* ! ! YES                                    ! NO                 ! */
/* ! +----------------------------------------+--------------------+ */
/* ! ! **** 3) (CHECKPOINT_ROUTINE)           !        %           ! */
/* ! +----------------------------------------+--------------------+ */
/* ! ! READ NEXT RECORD FROM Input-FILE                            ! */
/* ! +-------------------------------------------------------------+ */
/* ! ! INCREMENT NUMBER OF RECORDS READ                            ! */
/* +-+-------------------------------------------------------------+ */
/*********************************************************************/
/*********************************************************************/
/* 3) SUBROUTINE  CHECKPOINT_ROUTINE ******************************* */
/* +---------------------------------------------------------------+ */
/* ! FILL UP RESTART STRUCTURE WITH DETAILS OF THE RECORD          ! */
/* +---------------------------------------------------------------+ */
/* ! INSERT/UPDATE TO RESTART TABLE (SQL)                          ! */
/* +---------------------------------------------------------------+ */
/* ! INSERT/UPDATE OK                                              ! */
/* ! YES                                                   ! NO    ! */
/* +-------------------------------------------------------+-------+ */
/* ! DB2 COMMIT                                            !       ! */
/* +-------------------------------------------------------+       ! */
/* ! COMMIT OK                                             !   4)  ! */
/* ! YES                                           ! NO    !       ! */
/* +-----------------------------------------------+-------+       ! */
/* ! END OF ROUTINE                                !   4)  !       ! */
/* +-----------------------------------------------+-------+-------+ */
/*********************************************************************/
/*--*/
/*********************************************************************/
/* 4) CALL SUBROUTINE DBERRORP ************************************* */
/* +---------------------------------------------------------------+ */
/* ! ERRORTEXT  = ??????????            ERROR MESSAGE              ! */
/* ! CALL DBERRORP                      ERROR-ROUTINE              ! */
/* ! CALL PLIRETC(12)                   SHOW RETURN-CODE           ! */
/* ! RETURN                             ABNORMAL PROGRAM END       ! */
/* +---------------------------------------------------------------+ */
/*********************************************************************/
/*********************************************************************/
/* TABELLEN / VIEWS THAT ARE USED                                    */
/*********************************************************************/
/*                                                                   */
/*   TABLE   /    MEMBER NAME    STRUCTURE NAME    FIELD NAMES       */
/*     VIEW                                                          */
/* ------------------------------------------------------------      */
/*    VRESTART      MRESTART       SRESTART        PGMID             */
/*                                                 TIMESTAMP         */
/*                                                 RTEXT             */
/*                                                                   */
/*    VPERS01       MPERS01        SPERS01         EMPNO             */
/*                                                 TAXCLASS          */
/*                                                 TAXFREEM          */
/*                                                 TAXFREEY          */
/*                                                                   */
/*********************************************************************/
/*--*/
/*********************************************************************/
/* *** PSEUDOCODE ***                                                */
/* READ RESTART TABLE (SQL)                                          */
/* SELECT                                                            */
/*  IF THERE IS A ROW IN THE RESTART TABLE                           */
/*   REPEAT UNTIL (END OF FILE (Input)) OR                           */
/*          (DATA FROM Input FILE = DATA FROM RESTART TABLE)         */
/*    READ Input FILE                                                */
/*     IF END OF FILE (Input)                                        */
/*      ERROR ROUTINE                                                */
/*      END PGM ABNORMALLY                                           */
/*   CALL RESTART_ROUTINE                                            */
/*  IF THERE IS NO ROW IN THE RESTART TABLE                          */
/*   CALL NORMAL_ROUTINE                                             */
/*  OTHERWISE CALL DBERRORP                                          */
/*  END PGM ABNORMALLY                                               */
/*  READ Input-FILE                                                  */
/* REPEAT UNTIL (END OF FILE (Input))                                */
/*  UPDATE VPERS01 TABLE (SQL)                                       */
/*  SELECT                                                           */
/*   IF NO ROWS FOUND IN VPERS01 TABLE                               */
/*    PUT OUT MESSAGE                                                */
/*   IF ROW(S) FOUND IN VPERS01 TABLE                                */
/*    NO ACTION                                                      */
/*   OTHERWISE CALL DBERRORP                                         */
/*   END PGM ABNORMALLY                                              */
/*  IF Input_COUNTER > CHECKPOINT-LIMIT                              */
/*   INSERT/UPDATE ROW IN RESTART TABLE (SQL)                        */
/*   IF INSERT/UPDATE NOT OK                                         */
/*    CALL DBERRORP                                                  */
/*    END PGM ABNORMALLY                                             */
/*   CALL CHECKPOINT_ROUTINE                                         */
/*  READ Input FILE                                                  */
/* DELETE ROW  IN RESTART TABLE (SQL)                                */
/* IF DELETE NOT OK                                                  */
/*  CALL DBERRORP                                                    */
/*   END PGM ABNORMALLY                                              */
/* END OF PGM                                                        */
/*********************************************************************/
/*--*/
/*********************************************************************/
/* Include C library definitions                                     */
/*********************************************************************/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
        
/**********************************************************************/
/* Input/Output files                                                 */
/*   cardin = input request records                                   */
/*   report = output phone report printed to terminal                 */
/**********************************************************************/
FILE *cardin;   
FILE *report; 
/**********************************************************************/
/* Input transaction request from text file MUPDATE                   */
/* DESCRIPTION OF DATA ELEMENTS                                       */
/*    TYPE         TYPE 'MUPDATE'                                     */
/*    in_empno     PERSONNEL NUMBER (EMPNO)                           */
/*    in_taxclass  TAX CLASS (TAX CLASS)                              */
/*    in_taxfreem  MONTHLY TAX EXEMPTION (TAXFREEM)                   */
/*    in_taxfreey  YEARLY TAX EXEMPTION (TAXFREEY)                    */
/*    REST         FILLER TO MAKE IT 80 BYTES                         */
/**********************************************************************/

/*
EXEC SQL BEGIN DECLARE SECTION;
*/

#line 183 "restart.sqc"
 

  char type[7];    
  char in_empno[10];  
  char in_taxclass[3];   
  char in_taxfreem[8];  
  char in_taxfreey[8]; 
  char rest[48];      

/*
EXEC SQL END DECLARE SECTION;
*/

#line 191 "restart.sqc"
     

  short restart_switch;
  short Input_counter;
  short inpz;
  char restext[81];
  short x;
  float slo;
  
  
  
  
  
  static char fmt1[] = "%7c%9c%2c%7c%7c%49c";
  static char fmt2[] = "%-4s%-26s%-80s%\n";
  
  
  static char msg01[] =   
   "CHECKPOINT : PGMID = ";  
  static char msg02[] =   
   "             TIMESTAMP = ";  
  static char msg03[] =   
   "             RTEXT = ";        
  static char msg04[] =  
   "MSG04I - ROLLING BACK, RETURN CODE IS:";
  static char msg05[] =  
   "MSG05I - EITHER INPUT OR OUTPUT FILE CANNOT BE OPENED";   
  static char msg06[] = 
   "MSG06I - ROLLBACK FAILED, RETURN CODE IS:";   
  static char msg07[] =    
   "MSG07I - NORMAL START";    
  static char msg08[] =       
   "MSG08I - NEGATIVE RETURN CODE FROM SQLAINTP "; 
  static char msg09[] =  
   "MSG09I - ERROR DELETING FROM VRESTART"; 
  static char msg10[] =  
   "MSG10I - RESTARTING"; 
  static char msg11[] = 
   "MSG11I - ERROR RESTARTING"; 
  static char msg12[] = 
   "MSG12I - PERS NUM NOT FOUND FOR UPDATE"; 
  static char msg13[] =   
   "MSG13I - ERROR FORCED - RESTART....";
  static char msg14[] =  
   "MSG14I - COMMIT SUCCESSFUL";
  static char msg15[] =  
   "MSG15I - END OF PROGRAM"; 
/******************Function prototypes*********************************/
void restart_routine(void); 
void normal_routine(void); 
void checkpoint_routine(void);  
void sql_err(void);
/**********************************************************************/
/*                                                                    */
/*   Include for SQLCA.                                               */
/*                                                                    */
/**********************************************************************/



/*
EXEC SQL INCLUDE SQLCA;
*/

/* SQL Communication Area - SQLCA - structures and constants */
#include "sqlca.h"
struct sqlca sqlca;


#line 250 "restart.sqc"
       

/*
EXEC SQL BEGIN DECLARE SECTION;
*/

#line 251 "restart.sqc"


/*********???????******************************************************/
/*                                                                    */
/* Variables that map to the VPERS01 and RESTART tables are declared  */
/* below.  Note the definitions.                                      */
/*                                                                    */
/**********************************************************************/
     
/* Variables for VPERS01 table    */  

   char empno[9];
   char taxclass[2];
   float taxfreem; /*TAXFREEM                       DECIMAL(7, 2),*/
   float taxfreey; /*TAXFREEY                       DECIMAL(7, 2) */
        
/* Variables for RESTART table    */ 

   char pgmid[4];
   char timestamp[26];
   char rtext[81]; 
   
/* Indicator Variables            */ 

   short pgmt_i; 
   short pgyr_i; 

/* Variables for connect statement */

  char userid[9];
  char password[9];
  char database[9];
   

/*
EXEC SQL END DECLARE SECTION;
*/

#line 284 "restart.sqc"
 

/*****************Error handling***************************************/
/*   SQL errors transfer control to DBERROR routine.                  */
/*   SQL warnings continue.                                           */
/**********************************************************************/
   
/******************************/     
/**** SQL error handling   ****/     
/**** SQL warning handling ****/        
/******************************/         
             

/*
EXEC SQL WHENEVER SQLWARNING CONTINUE;
*/

#line 296 "restart.sqc"
  

/*
EXEC SQL WHENEVER SQLERROR GO TO DBERROR;
*/

#line 297 "restart.sqc"


/*
EXEC SQL WHENEVER NOT FOUND CONTINUE;
*/

#line 298 "restart.sqc"


/**********************************************************************/
/* Main routine                                                       */
/*                                                                    */
/* Read one record at a time from the input file.                     */
/**********************************************************************/
int main()   
{    

report = sqrt(5);
  /* Open the input and output files */  
  cardin = fopen("MUPDATE", "r");  
  report = fopen("REPORT", "w"); 
  if (cardin == NULL || report == NULL) {
     fprintf(report, "%s\n", msg05); 
     exit(0);
  }

/***********************/
/* Connect to database */
/***********************/

/*********************************/
/**** SQL Connect to database ****/
/*********************************/

/*************************************/
/* Set up host variables for         */
/* userid, password, and database    */
/*************************************/

   strcpy(userid,"grega");
   strcpy(password,"password");
   strcpy(database,"EDDB");

/***********????????????????????????????***********/
/*           Code the connect statement           */
/*            using the host variables            */
/**************************************************/


/*
EXEC SQL CONNECT TO :database;
*/

{
#line 339 "restart.sqc"
  sqlastrt(sqla_program_id, &sqla_rtinfo, &sqlca);
#line 339 "restart.sqc"
  sqlaaloc(2,1,1,0L);
    {
      struct sqla_setdata_list sql_setdlist[1];
#line 339 "restart.sqc"
      sql_setdlist[0].sqltype = 460; sql_setdlist[0].sqllen = 9;
#line 339 "restart.sqc"
      sql_setdlist[0].sqldata = (void*)database;
#line 339 "restart.sqc"
      sql_setdlist[0].sqlind = 0L;
#line 339 "restart.sqc"
      sqlasetdata(2,0,1,sql_setdlist,0L,0L);
    }
#line 339 "restart.sqc"
  sqlacall((unsigned short)29,4,2,0,0L);
#line 339 "restart.sqc"
  if (sqlca.sqlcode < 0)
  {
    sqlastop(0L);
    goto DBERROR;
  }
#line 339 "restart.sqc"
  sqlastop(0L);
}

#line 339 "restart.sqc"
 /* USER :userid USING :password;*/

/*********************************************************************/
/* UPDATE VPERS01 DATA                                               */
/*********************************************************************/
   restart_switch = 0;
   x = 0;

/*???*****************************************************************/
/* SET UP WHERE STATEMENT FOR RESTART TABLE                          */
/* READ RESTART TABLE - DETERMINE IF THERE ARE ANY ROWS              */
/* FOR THE pgmid.                                                    */
/*********************************************************************/
   strcpy(pgmid,"TP01");

   
/*
EXEC SQL
     SELECT *
       INTO  :pgmid, :timestamp, :rtext
       FROM  VRESTART
       WHERE PGMID = :pgmid;
*/

{
#line 358 "restart.sqc"
  sqlastrt(sqla_program_id, &sqla_rtinfo, &sqlca);
#line 358 "restart.sqc"
  sqlaaloc(2,1,2,0L);
    {
      struct sqla_setdata_list sql_setdlist[1];
#line 358 "restart.sqc"
      sql_setdlist[0].sqltype = 460; sql_setdlist[0].sqllen = 4;
#line 358 "restart.sqc"
      sql_setdlist[0].sqldata = (void*)pgmid;
#line 358 "restart.sqc"
      sql_setdlist[0].sqlind = 0L;
#line 358 "restart.sqc"
      sqlasetdata(2,0,1,sql_setdlist,0L,0L);
    }
#line 358 "restart.sqc"
  sqlaaloc(3,3,3,0L);
    {
      struct sqla_setdata_list sql_setdlist[3];
#line 358 "restart.sqc"
      sql_setdlist[0].sqltype = 460; sql_setdlist[0].sqllen = 4;
#line 358 "restart.sqc"
      sql_setdlist[0].sqldata = (void*)pgmid;
#line 358 "restart.sqc"
      sql_setdlist[0].sqlind = 0L;
#line 358 "restart.sqc"
      sql_setdlist[1].sqltype = 460; sql_setdlist[1].sqllen = 26;
#line 358 "restart.sqc"
      sql_setdlist[1].sqldata = (void*)timestamp;
#line 358 "restart.sqc"
      sql_setdlist[1].sqlind = 0L;
#line 358 "restart.sqc"
      sql_setdlist[2].sqltype = 460; sql_setdlist[2].sqllen = 81;
#line 358 "restart.sqc"
      sql_setdlist[2].sqldata = (void*)rtext;
#line 358 "restart.sqc"
      sql_setdlist[2].sqlind = 0L;
#line 358 "restart.sqc"
      sqlasetdata(3,0,3,sql_setdlist,0L,0L);
    }
#line 358 "restart.sqc"
  sqlacall((unsigned short)24,1,2,3,0L);
#line 358 "restart.sqc"
  if (sqlca.sqlcode < 0)
  {
    sqlastop(0L);
    goto DBERROR;
  }
#line 358 "restart.sqc"
  sqlastop(0L);
}

#line 358 "restart.sqc"


/**???**************************************************************/
/* IF THERE IS A ROW IN RESTART                                    */
/*   DO THE RESTART PROCESSING                                     */
/*******************************************************************/
     if (sqlca.sqlcode == 0)   
       restart_routine();       

/*******************************************************************/
/* If no row in restart table                                      */
/*******************************************************************/
     if (sqlca.sqlcode == 100)         
       fprintf(report, "%s\n\n", msg07);   
 
/**???****************************************************************/
/* IF NO ROW IN RESTART                                              */
/*   DO NORMAL PROCESSING                                            */
/* NORMAL PROCESSING VIA SUBROUTINE                                  */
/*********************************************************************/

      normal_routine(); 

/**???****************************************************************/
/* DELETE ROW FROM RESTART TABLE AND CHECK FOR ERRORS                */
/*********************************************************************/
  
/*
EXEC SQL
     DELETE FROM VRESTART
       WHERE PGMID = :pgmid;
*/

{
#line 386 "restart.sqc"
  sqlastrt(sqla_program_id, &sqla_rtinfo, &sqlca);
#line 386 "restart.sqc"
  sqlaaloc(2,1,4,0L);
    {
      struct sqla_setdata_list sql_setdlist[1];
#line 386 "restart.sqc"
      sql_setdlist[0].sqltype = 460; sql_setdlist[0].sqllen = 4;
#line 386 "restart.sqc"
      sql_setdlist[0].sqldata = (void*)pgmid;
#line 386 "restart.sqc"
      sql_setdlist[0].sqlind = 0L;
#line 386 "restart.sqc"
      sqlasetdata(2,0,1,sql_setdlist,0L,0L);
    }
#line 386 "restart.sqc"
  sqlacall((unsigned short)24,2,2,0,0L);
#line 386 "restart.sqc"
  if (sqlca.sqlcode < 0)
  {
    sqlastop(0L);
    goto DBERROR;
  }
#line 386 "restart.sqc"
  sqlastop(0L);
}

#line 386 "restart.sqc"


      if (sqlca.sqlcode < 0)         
       fprintf(report, "%s\n\n", msg09);

/*********************************************************************/
/* END OF PROCESSING                                                 */
/*********************************************************************/
  pgmend();
  DBERROR: sql_err();
  return(0);
} /* end main */
/*********************************************************************/
/* END OF PROGRAM                                                    */
/*********************************************************************/
/*--*/
/*XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX*/
/* SUBROUTINE  RESTART_ROUTINE                                       */
/*XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX*/

void restart_routine()      
{              
 
/*********************************************************************/
/* READ Input FILE UNTIL                                             */
/*   DATA FROM Input-FILE = DATA FROM RESTART TABLE                  */
/*********************************************************************/
    fscanf(cardin, fmt1, type,                         
                              in_empno,         
                              in_taxclass,    
                              in_taxfreem,       
                              in_taxfreey,     
                              rest);
      strcpy(restext,"");  
      strcat(restext,type);
      strcat(restext,in_empno);
      strcat(restext,in_taxclass);
      strcat(restext,in_taxfreem);  
      strcat(restext,in_taxfreey);  
      strcat(restext,rest);

   while (!feof(cardin))   
   { 
       
       if (!strcmp(rtext,restext))
        {
/*********************************************************************/
/* RESTART PROCESSING - MESSAGE                                      */
/*********************************************************************/
           
          fprintf(report, "%s\n\n", msg10); 
          fprintf(report, fmt2, pgmid,      
                                timestamp,  
                                rtext);
          
          restart_switch = 1;
          return;            
       
         }      
         else
         { 

           fscanf(cardin, fmt1, type, 
                              in_empno, 
                              in_taxclass,  
                              in_taxfreem,  
                              in_taxfreey, 
                              rest);
         strcpy(restext,"");  
         strcat(restext,type);
         strcat(restext,in_empno);
         strcat(restext,in_taxclass);
         strcat(restext,in_taxfreem);  
         strcat(restext,in_taxfreey);  
         strcat(restext,rest);         
         }
     } /* end while */ 

     fprintf(report, "%s\n\n", msg11);
   
/*********************************************************************/
/* SET RESTART SWITCH TO '1' (-> UPDATE IN RESTART-TABLE)            */
/*********************************************************************/
restart_switch = 1; 
    
return;
 
 } /* END RESTART_ROUTINE */
/*********************************************************************/
/*--*/

/*XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX*/
/* SUBROUTINE NORMAL_ROUTINE                                         */
/*XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX*/
void normal_routine()   
{      

/*********************************************************************/
/* READ Input-FILE  (FIRST ROW IF NORMAL OR NEXT                     */
/*                       ROW IF RESTART)                             */
/*   INCREMENT Input_counter (COUNTER) BY 1                          */
/*********************************************************************/
fscanf(cardin, fmt1, type,  
                     in_empno, 
                     in_taxclass,  
                     in_taxfreem, 
                     in_taxfreey,   
                     rest);

Input_counter = 1;
/*********************************************************************/
/* READ Input-FILE WHILE (Input-FILE NOT EOF)                        */
/*********************************************************************/
while (!feof(cardin))    
  {                 
   
/*******************************************************************/
/* ASSIGN DATA FROM THE Input-FILE INTO THE SQL HOST VARIABLES     */
/*******************************************************************/
      sscanf(in_taxfreem," %f ",&taxfreem);
      sscanf(in_taxfreey," %f ",&taxfreey);

      if (!(strcmp(in_taxfreem,"")))
       pgmt_i = -1;
       else
         pgmt_i = 0;
        
      if (!(strcmp(in_taxfreey,"")))
       pgyr_i = -1;
       else
         pgyr_i =0;
        
/**???**************************************************************/
/* UPDATE VPERS01 TABLE                                            */
/* WITH NEW TAX CLASS, NEW TAX FREE MONTHLY VALUE, and             */
/* NEW TAX FREE YEARLY VALUE.                                      */
/*******************************************************************/
 
      
/*
EXEC SQL
       UPDATE VPERS01
         SET   TAXCLASS  = :in_taxclass,
               TAXFREEM  = :taxfreem :pgmt_i,
               TAXFREEY  = :taxfreey :pgyr_i
         WHERE EMPNO     = :in_empno;
*/

{
#line 529 "restart.sqc"
  sqlastrt(sqla_program_id, &sqla_rtinfo, &sqlca);
#line 529 "restart.sqc"
  sqlaaloc(2,4,5,0L);
    {
      struct sqla_setdata_list sql_setdlist[4];
#line 529 "restart.sqc"
      sql_setdlist[0].sqltype = 460; sql_setdlist[0].sqllen = 3;
#line 529 "restart.sqc"
      sql_setdlist[0].sqldata = (void*)in_taxclass;
#line 529 "restart.sqc"
      sql_setdlist[0].sqlind = 0L;
#line 529 "restart.sqc"
      sql_setdlist[1].sqltype = 481; sql_setdlist[1].sqllen = 4;
#line 529 "restart.sqc"
      sql_setdlist[1].sqldata = (void*)&taxfreem;
#line 529 "restart.sqc"
      sql_setdlist[1].sqlind = (short*)&pgmt_i;
#line 529 "restart.sqc"
      sql_setdlist[2].sqltype = 481; sql_setdlist[2].sqllen = 4;
#line 529 "restart.sqc"
      sql_setdlist[2].sqldata = (void*)&taxfreey;
#line 529 "restart.sqc"
      sql_setdlist[2].sqlind = (short*)&pgyr_i;
#line 529 "restart.sqc"
      sql_setdlist[3].sqltype = 460; sql_setdlist[3].sqllen = 10;
#line 529 "restart.sqc"
      sql_setdlist[3].sqldata = (void*)in_empno;
#line 529 "restart.sqc"
      sql_setdlist[3].sqlind = 0L;
#line 529 "restart.sqc"
      sqlasetdata(2,0,4,sql_setdlist,0L,0L);
    }
#line 529 "restart.sqc"
  sqlacall((unsigned short)24,3,2,0,0L);
#line 529 "restart.sqc"
  if (sqlca.sqlcode < 0)
  {
    sqlastop(0L);
    goto DBERROR;
  }
#line 529 "restart.sqc"
  sqlastop(0L);
}

#line 529 "restart.sqc"


/*****************************************************************/
/* IF ROW FOUND                                                  */
/*   NO ACTION                                                   */
/* IF ROW NOT FOUND                                              */
/*   SAY SO IN A MESSAGE                                         */
/*****************************************************************/
      if (sqlca.sqlcode == 100)    
        fprintf(report, "%s\n\n", msg12);
       
/*****************************************************************/
/* OTHERWISE CALL ERROR ROUTINE                                  */
/*****************************************************************/
/*--*/
/*%%%%%%%%%%%%%%%%%%%% USED FOR TESTING RESTARTABILITY %%%%%%%%%%%%%%*/
         inpz++; 
         if (inpz > 50)
           {
            fprintf(report, "%s\n\n", msg13);
            exit(12);     
           } 
/*%                                                                 %*/
/*%%%%%%%%%%%%%%%%%%%% USED FOR TESTING RESTARTABILITY %%%%%%%%%%%%%%*/

/**???**************************************************************/
/* PERFORM CHECKPOINT AFTER 20 ROWS VIA SUBROUTINE                 */
/*******************************************************************/
     if (Input_counter > 19)
        checkpoint_routine();

/*******************************************************************/
/* READ NEXT ROW FROM Input-FILE                                   */
/*   INCREMENT Input_counter BY 1                                  */
/*******************************************************************/

     fscanf(cardin, fmt1,   type,               
                       in_empno,                 
                       in_taxclass,  
                       in_taxfreem,   
                       in_taxfreey,    
                       rest);

     Input_counter++;
  
    }   /*  END WHILE  */

                                          
return;
DBERROR: sql_err(); 

  } /* END NORMAL_ROUTINE; */
/*********************************************************************/
/*--*/
/*XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX*/
/* SUBROUTINE CHECKPOINT_ROUTINE                                      */
/*XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX*/
void checkpoint_routine()                                                                
{      
  
/*********************************************************************/
/* INITIALIZE Input_counter TO 0                                     */
/* PUT RESTART INFO INTO RTEXT                                       */
/*********************************************************************/

   Input_counter = 0;

   strcpy(pgmid,"TP01");

   strcpy(rtext,"");  
   strcat(rtext,type);
   strcat(rtext,in_empno);
   strcat(rtext,in_taxclass);
   strcat(rtext,in_taxfreem); 
   strcat(rtext,in_taxfreey);
   strcat(rtext,rest);

   
/*
EXEC SQL
   VALUES (CURRENT TIMESTAMP)
   INTO :timestamp;
*/

{
#line 608 "restart.sqc"
  sqlastrt(sqla_program_id, &sqla_rtinfo, &sqlca);
#line 608 "restart.sqc"
  sqlaaloc(3,1,6,0L);
    {
      struct sqla_setdata_list sql_setdlist[1];
#line 608 "restart.sqc"
      sql_setdlist[0].sqltype = 460; sql_setdlist[0].sqllen = 26;
#line 608 "restart.sqc"
      sql_setdlist[0].sqldata = (void*)timestamp;
#line 608 "restart.sqc"
      sql_setdlist[0].sqlind = 0L;
#line 608 "restart.sqc"
      sqlasetdata(3,0,1,sql_setdlist,0L,0L);
    }
#line 608 "restart.sqc"
  sqlacall((unsigned short)24,4,0,3,0L);
#line 608 "restart.sqc"
  if (sqlca.sqlcode < 0)
  {
    sqlastop(0L);
    goto DBERROR;
  }
#line 608 "restart.sqc"
  sqlastop(0L);
}

#line 608 "restart.sqc"

  
    
/**???**************************************************************/
/* IF THERE WE HAVE ALREADY PUT A ROW INTO THE RESTART TABLE,      */
/*    UPDATE RESTART TABLE WITH THE MOST RECENT INFO               */
/*******************************************************************/
    if (restart_switch != 0)
    {
       
/*
EXEC SQL
         UPDATE VRESTART
           SET   TIMESTAMP = :timestamp,
                 RTEXT     = :rtext
           WHERE PGMID   = :pgmid;
*/

{
#line 621 "restart.sqc"
  sqlastrt(sqla_program_id, &sqla_rtinfo, &sqlca);
#line 621 "restart.sqc"
  sqlaaloc(2,3,7,0L);
    {
      struct sqla_setdata_list sql_setdlist[3];
#line 621 "restart.sqc"
      sql_setdlist[0].sqltype = 460; sql_setdlist[0].sqllen = 26;
#line 621 "restart.sqc"
      sql_setdlist[0].sqldata = (void*)timestamp;
#line 621 "restart.sqc"
      sql_setdlist[0].sqlind = 0L;
#line 621 "restart.sqc"
      sql_setdlist[1].sqltype = 460; sql_setdlist[1].sqllen = 81;
#line 621 "restart.sqc"
      sql_setdlist[1].sqldata = (void*)rtext;
#line 621 "restart.sqc"
      sql_setdlist[1].sqlind = 0L;
#line 621 "restart.sqc"
      sql_setdlist[2].sqltype = 460; sql_setdlist[2].sqllen = 4;
#line 621 "restart.sqc"
      sql_setdlist[2].sqldata = (void*)pgmid;
#line 621 "restart.sqc"
      sql_setdlist[2].sqlind = 0L;
#line 621 "restart.sqc"
      sqlasetdata(2,0,3,sql_setdlist,0L,0L);
    }
#line 621 "restart.sqc"
  sqlacall((unsigned short)24,5,2,0,0L);
#line 621 "restart.sqc"
  if (sqlca.sqlcode < 0)
  {
    sqlastop(0L);
    goto DBERROR;
  }
#line 621 "restart.sqc"
  sqlastop(0L);
}

#line 621 "restart.sqc"

   
    }
/**???**************************************************************/
/* IF NO ROWS IN RESTART TABLE                                     */
/*   SET RESTART_SWITCH TO '1'.                                    */
/*   INSERT INFO INTO RESTART TABLE                                */
/*******************************************************************/
    else
    {
       restart_switch = 1;
       
/*
EXEC SQL
         INSERT INTO VRESTART
           VALUES (:pgmid, :timestamp, :rtext);
*/

{
#line 634 "restart.sqc"
  sqlastrt(sqla_program_id, &sqla_rtinfo, &sqlca);
#line 634 "restart.sqc"
  sqlaaloc(2,3,8,0L);
    {
      struct sqla_setdata_list sql_setdlist[3];
#line 634 "restart.sqc"
      sql_setdlist[0].sqltype = 460; sql_setdlist[0].sqllen = 4;
#line 634 "restart.sqc"
      sql_setdlist[0].sqldata = (void*)pgmid;
#line 634 "restart.sqc"
      sql_setdlist[0].sqlind = 0L;
#line 634 "restart.sqc"
      sql_setdlist[1].sqltype = 460; sql_setdlist[1].sqllen = 26;
#line 634 "restart.sqc"
      sql_setdlist[1].sqldata = (void*)timestamp;
#line 634 "restart.sqc"
      sql_setdlist[1].sqlind = 0L;
#line 634 "restart.sqc"
      sql_setdlist[2].sqltype = 460; sql_setdlist[2].sqllen = 81;
#line 634 "restart.sqc"
      sql_setdlist[2].sqldata = (void*)rtext;
#line 634 "restart.sqc"
      sql_setdlist[2].sqlind = 0L;
#line 634 "restart.sqc"
      sqlasetdata(2,0,3,sql_setdlist,0L,0L);
    }
#line 634 "restart.sqc"
  sqlacall((unsigned short)24,6,2,0,0L);
#line 634 "restart.sqc"
  if (sqlca.sqlcode < 0)
  {
    sqlastop(0L);
    goto DBERROR;
  }
#line 634 "restart.sqc"
  sqlastop(0L);
}

#line 634 "restart.sqc"

    }                                          

/**???****************************************************************/
/* DB2 COMMIT WITH CHECKING                                          */
/*********************************************************************/
   
/*
EXEC SQL COMMIT;
*/

{
#line 640 "restart.sqc"
  sqlastrt(sqla_program_id, &sqla_rtinfo, &sqlca);
#line 640 "restart.sqc"
  sqlacall((unsigned short)21,0,0,0,0L);
#line 640 "restart.sqc"
  if (sqlca.sqlcode < 0)
  {
    sqlastop(0L);
    goto DBERROR;
  }
#line 640 "restart.sqc"
  sqlastop(0L);
}

#line 640 "restart.sqc"

   if (sqlca.sqlcode == 0)
       {         
       fprintf(report, "%s\n\n", msg14);  
/*********************************************************************/
/* MESSAGE FROM CHECKPOINT PROCESSING                                */
/*********************************************************************/
       fprintf(report, "%s %s\n", msg01, pgmid);  
       fprintf(report, "%s %s\n", msg02, timestamp); 
       fprintf(report, "%s %s\n\n", msg03, rtext); 
       }
    
                                         
return;
DBERROR: sql_err();  

 

}    /* end of CHECKPOINT_ROUTINE; */
/*********************************************************************/
/*--*/

/**********************************************************************/        
/* SQL error handler                                                  */        
/**********************************************************************/        
void sql_err() { 
     
#include <sqlenv.h>                                                        
#define DATA_LEN 80 
                                                          
char error_message_buffer[512];
short buffer_size = sizeof(error_message_buffer);
short int rc;                                                                   
int i;
                                                                          
                                                                              
  fprintf(report, "%s %i\n", msg04, sqlca.sqlcode);                             
 /* Format the sqlca  */   
  rc = sqlaintp(error_message_buffer, buffer_size, DATA_LEN, &sqlca); 
  if (rc == 0)                                  
     fprintf(report, "%s %hi\n", msg08, rc); 
  else                                                                          
    /* fprintf(report, error_message_buffer); */     /* Print formatted   */
       fprintf(report, "%s\n", error_message_buffer);                                                                           
  /* Attempt to rollback any work already done */                               
  
/*
EXEC SQL WHENEVER SQLERROR   CONTINUE;
*/

#line 685 "restart.sqc"
                                        
  
/*
EXEC SQL WHENEVER SQLWARNING CONTINUE;
*/

#line 686 "restart.sqc"
                                        
  
/*
EXEC SQL WHENEVER NOT FOUND  CONTINUE;
*/

#line 687 "restart.sqc"
                                        
  x = 1;                                                                            
  pgmend();  
  return;
} /* end of sql_err */                                                          
                                                                                
pgmend()                                                                        
{ 
  
  if (x == 1)
  {                                                                          
   
/*
EXEC SQL ROLLBACK;
*/

{
#line 698 "restart.sqc"
  sqlastrt(sqla_program_id, &sqla_rtinfo, &sqlca);
#line 698 "restart.sqc"
  sqlacall((unsigned short)28,0,0,0,0L);
#line 698 "restart.sqc"
  sqlastop(0L);
}

#line 698 "restart.sqc"
 
                                                           
   if (sqlca.sqlcode != 0)                    /* If rollback fails */
    fprintf(report, "%s %i\n", msg06, sqlca.sqlcode);    /* display error msg */
  }
  else 
   
/*
EXEC SQL COMMIT;
*/

{
#line 704 "restart.sqc"
  sqlastrt(sqla_program_id, &sqla_rtinfo, &sqlca);
#line 704 "restart.sqc"
  sqlacall((unsigned short)21,0,0,0,0L);
#line 704 "restart.sqc"
  sqlastop(0L);
}

#line 704 "restart.sqc"
 
  fprintf(report, "%s\n", msg15);
  fclose(cardin);                                                               
  fclose(report);                                                               
  exit(0); 
  return(0);                       
 }                                                                           

Fizikalko ::

Mislim, da zajebava pri delu s fajlom. Mislim, da moram pri kompajliranju dodat kakšen support za float ali kaj takega.

Tole je moja complink procedura:

cl -Ox -W2 -TC -D_X86_=1 -I"C:\SQLLIB\include" %1.c /link -out:%1.exe "C:\SQLLIB\lib\db2api.lib"

Fizikalko ::

Aja, uporabljam pa Microsoft Visual C++ 6.0 (in NE Borland, kot sem prej tvezil...:8) ).


Vredno ogleda ...

TemaSporočilaOglediZadnje sporočilo
TemaSporočilaOglediZadnje sporočilo
»

Postavitev mySQL

Oddelek: Programiranje
92152 (1730) M01O
»

Linux CentOS - block ip range

Oddelek: Omrežja in internet
6576 (464) Bakunin
»

SQL težava

Oddelek: Programiranje
364824 (4106) joseti
»

Hard disk popravilo / rešitev podatkov

Oddelek: Strojna oprema
81524 (1425) darkolord
»

sql-t stored procedure

Oddelek: Programiranje
101020 (887) detroit

Več podobnih tem