Home » Developer & Programmer » Precompilers, OCI & OCCI » Varchar variable is truncated after calling C function
Varchar variable is truncated after calling C function [message #233251] Wed, 25 April 2007 06:49
manoj339
Messages: 9
Registered: April 2007
Junior Member
I have varchar variable declared .When I print this var it shows me correct value before a C function.
Inside a c function this variable value is getting truncated .
The c function does not pass this variable .It intializes structure memebers only.
I am using Pro*C/C++: Release 8.1.7.0.0 and OS details is :
Release: 5.8
Kernel architecture: sun4u
Application architecture: sparc
Hardware provider: Sun_Microsystems
Domain:
Kernel version: SunOS 5.8 Generic 117350-35 Mar 2006

Request your help in this matter.


EXEC SQL BEGIN DECLARE SECTION;
varchar ip_msg_type[5];
EXEC SQL END DECLARE SECTION;

/*Some of the Declarations are as below*/
struct op_msg_format
{
char message_type[5];
int section_position;
char section_name[5];
int section_length;
int min_occ;
int max_occ;
char write_to_file_flag;
char file_name[36];
};

struct sec_msg_rec_type
{
char section_name[5];
int start_position;
int section_length;
};

char g_prog_name[100];
struct op_msg_format g_op_msg_tab[MAX_OP_MSG_FORMAT];
struct sec_msg_rec_type g_sec_tab[MAX_SEC_MAG_REC_TYPE];
int g_op_msg_tab_cnt;
FILE *g_fhndl_tab[MAX_OP_MSG_FORMAT];



/* Part of Main Program is below */
printf("^^***ip_msg_type.arr = %s\n",ip_msg_type.arr);
/*value shows IMG */

if (init("SEC_MAG_REC_TYPE") != SUCCESS)
{
if (fn_log_errors( g_error_log_file,(char *)C_FATAL,"TRADE","E-INITFAILED",
"TRD_MQ_MSG_PROCESS","BARCLAYS","","STAGING",
"Initialisation of SEC_MAG_REC_TYPE Structure failed",
"","","") != SUCCESS)
{
fn_std_err("Error in call to fn_log_errors : MAIN.E-INITFAILED");
}
goto sqlerror;
}
g_sec_ind = 0;
g_bt_ind = 'N';

printf("^^****ip_msg_type.arr = %s\n",ip_msg_type.arr);
/*Value shows IM */


int init(char *struct_type)
{
int z;
if (strcmp(struct_type,"OP_MSG_FORMAT") == 0)
{
for (z = 0; z <= MAX_OP_MSG_FORMAT; z++)
{
g_op_msg_tab[z].message_type[0] = '\0';
g_op_msg_tab[z].section_position = 0;
g_op_msg_tab[z].section_name[0] = '\0';
g_op_msg_tab[z].section_length = 0;
g_op_msg_tab[z].min_occ = 0;
g_op_msg_tab[z].max_occ = 0;
g_op_msg_tab[z].write_to_file_flag = '\0';
g_op_msg_tab[z].file_name[0] = '\0';

/* This is of type pointer and you are assigning
a char constant to it */
g_fhndl_tab[z] = NULL;
}
}
if (strcmp(struct_type,"SEC_MAG_REC_TYPE") == 0)
{
printf("!!ip_msg_type = %s\n",ip_msg_type.arr);
/*Value shows IMG */

for (z = 0; z <= MAX_SEC_MAG_REC_TYPE; z++)
{
g_sec_tab[z].section_name[0] = '\0';
g_sec_tab[z].start_position = 0;
}
printf("!!!ip_msg_type = %s\n",ip_msg_type.arr);
/*Value shows IM */
}
return SUCCESS;
}
Previous Topic: AIX OCCI executeArrayUpdate ORA-32109 exception
Next Topic: What is indicator variable
Goto Forum:
  


Current Time: Fri Mar 29 01:00:11 CDT 2024