ESQL/C - Retreiving Char(1)
Posted in 1997
Topics: Stored Procedures & SPL, Connectivity: ESQL/C, 4GL & Embedded SQL, Server Administration, Platform-Specific Issues
Hi
I have a very strange problem. I have an application which which retreives
data from a table and displays on the screen. All data is being retreived
except the data on fields which has a datatype as char(1). The application
is in ESQL/C and INFORMIX ver 4.1. This is running on AIX 4.x.
Table is like this;
Table truckmaster
.....
tl_truck_type char(1) not null
....
I am attatching a portion of the program and header file
Thanks and Regards
Amita
Program
/*
*
* traildno.ec
*/
/* Description
*
* This is a report module. This gives the trailer detailes that have arrived
* in the Yard and their position in the Yard.
*
* $Log$
*/
/* Feature Test Switches */
/* System Headers */
#include <curses.h>
#include <time.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <string.h>
#include <ctype.h>
#include <term.h>
EXEC SQL include sqlca;
EXEC SQL include sqltypes;
/* Macros */
#define NO_OF_OPTIONS 13
/* Local Headers */
#include "../incl/global.h"
#include "../incl/menu.h"
#include "../incl/help.h"
#include "../incl/error.h"
EXEC SQL BEGIN DECLARE SECTION;
EXEC SQL include "../incl/trailerd.h";
TRAILERD trailo;
char from_date[9]; /* To store from-date entered by the user */
char to_date[9]; /* To store to-date entered by the user */
int d_no; /* To store door number entered by the user */
char dbasename[30]; /* To store the database name */
char cursorname[20]; /* To store the cursor name */
EXEC SQL END DECLARE SECTION;
,.......
This is the function which does the query
* Date : 01/23/1997
* Modification History:
*
* MM/DD/YY NAME DESCRIPTION
*
*
*/
int trailer_inventory_locrep ( )
{
chtype ch; /* To store Function key return value */
int ret_val = 0; /* To store function return value */
strcpy ( from_date, tl_from_date );
strcpy ( to_date, tl_to_date );
d_no = tl_dno;
/*Declare cursor to get trailer details*/
EXEC SQL
DECLARE trailer_location CURSOR FOR
SELECT tl_carrier, tl_trailer_no, tl_dflag, tl_truck_type,
tl_date_emptied, tl_time_emptied, tl_arrival_date,
tl_arrival_time
INTO :trailo.carrier, :trailo.trailer_no, :trailo.dflag,
:trailo.truck_type, :trailo.date_empt, :trailo.time_empt,
:trailo.arr_date, :trailo.arr_time
FROM
truckmaster
WHERE
date ( tl_arrival_date )
BETWEEN date ( :from_date ) AND date ( :to_date )
AND tl_door =:d_no;
/* Check for SQL error */
status = sqlerr("Error : Delcare cursor trailer_location ");
if ( status == FAILURE )
{
......
....
Using the debugger I have noticed that trailo.truck_type does not have any value
Similar query retreives value if carried out through isql.
"trailerd.h" 22 lines, 616 characters
/*#ifndef TRILERD_H
#define TRILERD_H
*/
/* Headers */
/*static char TRILERD_H_ID = "$ID$";*/
/* structure variables for trailer delivery */
typedef struct
{
/* 001*/ int tlkey; /* trucklog key */
/* 002*/ char carrier [35]; /* carrier */
/* 003*/ char trailer_no [15]; /* trailer number */
/* 004*/ char dflag; /* delivered flag */
/* 005*/ char truck_type; /* truck type */
/* 006*/ char date_empt [9]; /* date empt */
/* 007*/ char time_empt [7]; /* time empt */
/* 008*/ char arr_date [9]; /* arrival date */
/* 009*/ char arr_time [7]; /* arrival time */
} TRAILERD;
/* #endif */
~
This is the header file used
trailerd.h
/*#ifndef TRILERD_H
#define TRILERD_H
*/
/* Headers */
/*static char TRILERD_H_ID = "$ID$";*/
/* structure variables for trailer delivery */
typedef struct
{
/* 001*/ int tlkey; /* trucklog key */
/* 002*/ char carrier [35]; /* carrier */
/* 003*/ char trailer_no [15]; /* trailer number */
/* 004*/ char dflag; /* delivered flag */
/* 005*/ char truck_type; /* truck type */
/* 006*/ char date_empt [9]; /* date empt */
/* 007*/ char time_empt [7]; /* time empt */
/* 008*/ char arr_date [9]; /* arrival date */
/* 009*/ char arr_time [7]; /* arrival time */
} TRAILERD;
/* #endif */
~