Home » Developer & Programmer » Precompilers, OCI & OCCI » ORA-01458 during runtime in Pro*C
ORA-01458 during runtime in Pro*C [message #94210] Sat, 15 May 2004 02:36 Go to next message
J.S.Rajkumar
Messages: 20
Registered: March 2004
Junior Member
Hi All
 
We have a problem in our Pro*C program.
 
While running we get the below error
 
ORA-01458: invalid length inside variable character string
 
We were able to identify the exact location where we get the error, but could not solve the issue since we are just beginners to pro*C. We expect some Por*C Experts to help us in resolve the problem.
 
Problem area :
 
Problem area is the usage of :machine in the query. If that area is commented out or hardcode like machine='3'  we don't get this error.
 
Seems some datatype mismatch, can any one help. The datatype of machine in barts_pr_accusort_data table is varchar2(1);
 
 
 
Platform
 

HP-UX B.11.11 U 9000/800 (ta)

Pro*C/C++: Release 9.0.1.4.0

SQL*Plus: Release 9.0.1.4.0

Our Program Looks like this
 
#include <stdio.h>
#include <stdlib.h>
#include <fcntl.h>
#include <aio.h>
#include <signal.h>
#include <time.h>
#include "accusort.h"
/* macro to automatically put terminators on strings */
#define term(x) x.arr[[x.len]]=''
#define varcopy(x,y) x.len=strlen(strcpy(x.arr,y))
 
EXEC SQL BEGIN DECLARE SECTION;
    varchar        uid[[80]];
    varchar        machine[[2]];
    varchar        roll_data[[30]];
    char    update_flag;
   
EXEC SQL END DECLARE SECTION;
 
EXEC SQL INCLUDE SQLCA.H;
 
FILE *fp;
main(argc,argv)
int argc;
char *argv[[]];
{
    int sig,len,fd,i,j,k,num;
    char accu_dev[[20]];
    char cx[[2]],c;
    struct sigaction my_act;
    int timer_increment = 2;
    int debug_level = 0;
    char logfile[[256]];
    char scannerid[[20]];
    char userid[[80]];
    char temp[[10]];
    char dummy[[30]];
    char *tempbuf;
    char *curr_time;
    long temp_time;
 
    void accu_read_handler(int signo,siginfo_t *siginfo,void *context);
   
    parseargs(argc,argv,&debug_level,accu_dev,logfile,scannerid,userid);
   
   
    if (strcmp(scannerid, "b3r") == 0)
    {
     varcopy(machine,"3");
    }
    else
    {
            if (strcmp(scannerid, "b6r") == 0)
     {
      varcopy(machine,"6");
     }
    }
   
  
    EXEC SQL WHENEVER SQLERROR CONTINUE;
    EXEC SQL CONNECT :uid;

    /* PROBLEM AREA - PROBLEM IS BECAUSE OF :machine                                     */

    EXEC SQL SELECT distinct status into :update_flag
                          from barts_pr_accusort_data
                        where machine = :machine;
}

Thanks,
Jeslie Simpson Rajkumar. J
-------------------------------------------------
( BARTS - Offshore Support)
Wipro Technologies,
Chennai.
Ph: +91-44-24500200 Extn: 2492.
-------------------------------------------------
Re: ORA-01458 during runtime in Pro*C [message #94215 is a reply to message #94210] Tue, 18 May 2004 03:35 Go to previous message
Nitin Malik
Messages: 1
Registered: May 2004
Junior Member
Please check if the value of scannerid is always one of "b3r" or "b6r". If value is somewhat different in different cases then, you may be facing the problem.

Also initialize your varchar variables using following declaration:

varchar        machine[[2]] ={0};

Please test after iniatilizing all the varchar variables this way.

In case of further problems, revert back.

HTH
Nitin
Previous Topic: After my oci app is done, how to install it in another PC
Next Topic: ORA-24374: define not done before fetch or execute and fetch
Goto Forum:
  


Current Time: Wed Apr 24 23:37:50 CDT 2024