Re: Pro*C Assistance

From: Carl Fogelin <fogelinc_at_nmr1.Cyanamid.COM>
Date: 18 Jun 1993 01:09:15 GMT
Message-ID: <1vr4jr$9rd_at_c3po.jvnc.net>


In article 8ch_at_gaia.ucs.orst.edu, mickel_at_OES.ORST.EDU (Paul Mickel) writes:
>I am attempting to retrieve date fields from a table using Pro*C
>(Oracle version 6). The code looks like the following:
>
>
>EXEC SQL BEGIN DECLARE SECTION;
> VARCHAR date_time[20];
>EXEC SQL END DECLARE SECTION;
>
>main()
>{
>
> /* Log on to ORACLE here */
> :
> :
>
> EXEC SQL SELECT TO_CHAR(SYSDATE,'DD-MON-YYYY HH24:MI')
> INTO :date_time
> FROM dual;
>
> fprintf(stdout,"Date_time = %s\n",date_time);
> :
>}

Paul,

One problem you're having is VARCHAR's are structures. Also, the returned value is not NULL terminated. After your EXEC SQL command, I would do:

	date_time.arr[date_time.len] = 0;	/* Nul terminate string */
	fprintf(stdout,"Date_time = %s\n,date_time.arr);

The rest looks ok, although I haven't checked it yet.



 Carl Fogelin (fogelinc_at_pt.cyanamid.com) "All opinions are strictly mine"

   Up the long ladder and down the short rope,    To Hell with King Billy and God bless the Pope. -- traditional Received on Fri Jun 18 1993 - 03:09:15 CEST

Original text of this message