Home » Infrastructure » Unix » warnings and core dump with proc program in hp unix environment
warnings and core dump with proc program in hp unix environment [message #15306] |
Wed, 29 September 2004 12:16 |
Naga Raja Sekhar
Messages: 1 Registered: September 2004
|
Junior Member |
|
|
Hello sir,
I Got a code from asktom site in pro*c that unloads the data from oracle to flat file. while running the program i am getting some warings and 1 error.anyhow exe is getting formed.when i execute the exe it is giving core dump. can you please look into the coad let me know the problem.
Advance thanks for solution.
Here i am pasting the code
#include <stdio.h>
#include <string.h>
#include <ctype.h>
#define MAX_VNAME_LEN 30
#define MAX_INAME_LEN 30
#define vstrcpy( a, b )
(strcpy( a.arr, b ), a.len = strlen( a.arr ), a.arr)
EXEC SQL BEGIN DECLARE SECTION;
char *USERID = NULL;
char *SQLSTMT = NULL;
char *ARRAY_SIZE = "10";
EXEC SQL END DECLARE SECTION;
EXEC SQL INCLUDE sqlca;
EXEC SQL INCLUDE sqlda;
EXEC SQL BEGIN DECLARE SECTION;
extern SQLDA *sqlald();
extern void sqlclu();
EXEC SQL END DECLARE SECTION;
static void die( char *msg )
{
fprintf( stderr, "%sn", msg );
EXIT(1);
}
/*
this array contains a default mapping
I am using to constrain the
lengths of returned columns. It is mapping,
for example, the Oracle
NUMBER type (type code = 2) to be 45 characters
long in a string.
*/
static int lengths[[]] =
{ -1, 0, 45, 0, 0, 0, 0, 0, 2000, 0, 0,
18, 25, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 512, 2000 };
static void process_parms( argc, argv )
int argc;
char *argv[[]];
{
int i;
for ( i = 1; i < argc; i++ )
{
if ( !strncmp( argv[[i]], "userid=", 7 ) )
USERID = argv[[i]]+7;
else
if ( !strncmp( argv[[i]], "sqlstmt=", 8 ) )
SQLSTMT = argv[[i]]+8;
else
if ( !strncmp( argv[[i]], "arraysize=", 10 ) )
ARRAY_SIZE = argv[[i]]+10;
else
{
fprintf( stderr,
"usage: %s %s %sn",
argv[[0]],
"userid=xxx/xxx sqlstmt=query ",
"arraysize=<NN>n" );
EXIT(1);
}
}
if ( USERID == NULL || SQLSTMT == NULL )
{
fprintf( stderr,
"usage: %s %s %sn",
argv[[0]],
"userid=xxx/xxx sqlstmt=query ",
"arraysize=<NN>n" );
EXIT(1);
}
}
static void sqlerror_hard()
{
EXEC SQL WHENEVER SQLERROR CONTINUE;
fprintf(stderr,"nORACLE error detected:");
fprintf(stderr,"n% .70s n", sqlca.SQLERRM.sqlerrmc);
EXEC SQL ROLLBACK WORK RELEASE;
EXIT(1);
}
static SQLDA *process_1(char *sqlstmt, int array_size )
{
SQLDA *select_dp;
int i;
int j;
int null_ok;
int PRECISION;
int scale;
int SIZE = 10;
fprintf( stderr, "Unloading '%s'n", sqlstmt );
fprintf( stderr, "Array size = %dn", array_size );
EXEC SQL WHENEVER SQLERROR DO sqlerror_hard();
EXEC SQL PREPARE S FROM :sqlstmt;
EXEC SQL DECLARE C CURSOR FOR S;
if ((select_dp = sqlald(SIZE,MAX_VNAME_LEN,MAX_INAME_LEN))== NULL )
die( "Cannot allocate memory for select descriptor." );
select_dp->N = SIZE;
EXEC SQL DESCRIBE SELECT LIST FOR S INTO select_dp;
if ( !select_dp->F ) return NULL;
if (select_dp->F < 0)
{
SIZE = -select_dp->F;
sqlclu( select_dp );
if ((select_dp =
sqlald (SIZE, MAX_VNAME_LEN, MAX_INAME_LEN)) == NULL )
die( "Cannot allocate memory for descriptor." );
EXEC SQL DESCRIBE SELECT LIST FOR S INTO select_dp;
}
select_dp->N = select_dp->F;
for (i = 0; i < select_dp->N; i++)
select_dp->I[[i]] = (short *) malloc(sizeof(short) *array_size );
for (i = 0; i < select_dp->F; i++)
{
sqlnul (&(select_dp->T[[i]]),&(select_dp->T[[i]]), &null_ok);
if ( select_dp->T[[i]] <sizeof(lengths)/sizeof(lengths[[0]]) )
{
if ( lengths[[select_dp->T[[i]]]] )
select_dp->L[[i]] = lengths[[select_dp->T[[i]]]];
else select_dp->L[[i]] += 5;
}
else select_dp->L[[i]] += 5;
select_dp->T[[i]] = 5;
select_dp->V[[i]] = (char *)malloc( select_dp->L[[i]] *array_size );
for ( j = MAX_VNAME_LEN-1;
j > 0 && select_dp->S[[i]][[j]] == ' ';j--);
fprintf (stderr,
"%s%.*s", i?",":"", j+1, select_dp->S[[i]]);
}
fprintf( stderr, "n" );
EXEC SQL OPEN C;
return select_dp;
}
static void process_2( SQLDA *select_dp, int array_size )
{
int last_fetch_count;
int row_count = 0;
short ind_value;
char *char_ptr;
int i,j;
for ( last_fetch_count = 0;;last_fetch_count = sqlca.sqlerrd[[2]] )
{
EXEC SQL FOR :array_size FETCH C USING DESCRIPTOR select_dp;
for ( j=0; j < sqlca.sqlerrd[[2]]-last_fetch_count; j++ )
{
for (i = 0; i < select_dp->F; i++)
{
ind_value = *(select_dp->I[[i]]+j);
char_ptr = select_dp->V[[i]] +
(j*select_dp->L[[i]]);
printf( "%s%s", i?",":"",ind_value?"(null)":char_ptr );
}
row_count++;
printf( "n" );
}
if ( sqlca.SQLCODE > 0 ) break;
}
sqlclu(select_dp);
EXEC SQL CLOSE C;
EXEC SQL COMMIT WORK;
fprintf( stderr, "%d rows extractedn", row_count );
}
main( argc, argv )
int argc;
char *argv[[]];
{
EXEC SQL BEGIN DECLARE SECTION;
varchar oracleid[[50]];
EXEC SQL END DECLARE SECTION;
SQLDA *select_dp;
process_parms( argc, argv );
/* Connect to ORACLE. */
vstrcpy( oracleid, USERID );
EXEC SQL WHENEVER SQLERROR DO sqlerror_hard();
EXEC SQL CONNECT :oracleid;
fprintf(stderr, "nConnected to ORACLE as user: %snn",oracleid.arr);
EXEC SQL ALTER SESSION
SET NLS_DATE_FORMAT = 'DD-MON-YYYY HH24:MI:SS';
select_dp = process_1( SQLSTMT, atoi(ARRAY_SIZE) );
process_2( select_dp , atoi(ARRAY_SIZE));
/* Disconnect from ORACLE. */
EXEC SQL COMMIT WORK RELEASE;
EXIT(0);
}
I run the file as
make -f demo_proc.mk build INAME=flat1.pc EXE=flat1.exe OBJS=flat1.o
Here demo proc i copied from oracle_home and flat1.pc is the code i pasted above.
The errors i am getting are
/usr/ccs/bin/make -f /kn11/arbor/oracle/product/9.2.0.4/precomp/demo/proc/demo_proc.mk PROCFLAGS="" PCCSRC=flat1 I_SYM=include= pc1
proc iname=flat1 include=. include=/kn11/arbor/oracle/product/9.2.0.4/precomp/public include=/kn11/arbor/oracle/product/9.2.0.4/rdbms/public include=/kn11/arbor/oracle/product/9.2.0.4/rdbms/demo include=/kn11/arbor/oracle/product/9.2.0.4/plsql/public include=/kn11/arbor/oracle/product/9.2.0.4/network/public
Pro*C/C++: Release 9.2.0.1.0 - Production on Wed Sep 29 14:47:17 2004
Copyright (c) 1982, 2002, Oracle Corporation. All rights reserved.
System default option values taken from: /kn11/arbor/oracle/product/9.2.0.4/precomp/admin/pcscfg.cfg
cc +DA2.0W +DS2.0 -DSS_64BIT_SERVER -I. -I/kn11/arbor/oracle/product/9.2.0.4/precomp/public -I/kn11/arbor/oracle/product/9.2.0.4/rdbms/public -I/kn11/arbor/oracle/product/9.2.0.4/rdbms/demo -I/kn11/arbor/oracle/product/9.2.0.4/plsql/public -I/kn11/arbor/oracle/product/9.2.0.4/network/public -c flat1.c
cc: "flat1.c", line 601: warning 724: Cast converts default int return type to pointer.
cc: "flat1.c", line 781: warning 604: Pointers are not assignment-compatible.
cc: "flat1.c", line 781: warning 563: Argument #1 is not the correct type.
cc: "flat1.c", line 781: warning 604: Pointers are not assignment-compatible.
cc: "flat1.c", line 781: warning 563: Argument #1 is not the correct type.
cc +DA2.0W -o flat1.exe flat1.o -L/kn11/arbor/oracle/product/9.2.0.4/lib/ -lclntsh `cat /kn11/arbor/oracle/product/9.2.0.4/lib/ldflags` `cat /kn11/arbor/oracle/product/9.2.0.4/lib/sysliblist` -lm -lpthread -lpthread
ld: Unsatisfied symbol "EXIT" in file flat1.o
1 errors.
*** Error exit code 1
and Still i executed the exe which is formed as flat1.exe userid=arbor/arbor123@knpr_ad sqlstmt="select * from ADJ_TRANS_DESCR" >ADJ_TRANS_DESCR.dat
the bellow error is came
Connected to ORACLE as user: arbor/arbor123@knpr_ad
Unloading 'select * from ADJ_TRANS_DESCR'
Array size = 1000
ADJ_TRANS_CODE,TRANS_TARGET_TYPE,TRANS_TARGET_ID,ADJ_TRANS_CATEGORY,TRANS_SIGN,BILLING_CATEGORY,BILLING_LEVEL,DESCRIPTION_CODE,TAX_CLASS,IS_VIEWABLE,IS_MODIFIABLE,IS_ADJUSTABLE,IS_JOURNALABLE,IS_DISPLAYED_ONBILL,IS_DISCONNECT_CREDIT,IS_REFINANCE,ANNOTATION_TYPE,TAX_ON_INVOICE,IS_LATE_FEE_EXEMPT,ALLOW_INTERIM_BILL,IS_NEGATIVE_BILL_ADJ
Memory fault(coredump)
Please help in this regards i am very very thankful to you
WIth Best Regards
Raja Sekhar
|
|
|
Goto Forum:
Current Time: Mon Nov 25 21:39:15 CST 2024
|