Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.server -> Re: Passing host arrays as args to subroutines: Pro*C
Denis M. Goddard wrote:
>
> Hello Oracle / Pro*C Gurus...
>
> /* --- function prototype, i.e., in a header file --- */
> /* function populates fetched_rows host array */
> /* and returns sqlca.sqlerrd[2] */
> int Fetch_Data ( char *arg1, ... /* modify selection logic, etc. */
> VARCHAR *fetched_rows /* ???? populate this */
> );
>
> ===================================
>
> specific_application_program.c:
>
> /* Declare Host Array */
> EXEC SQL BEGIN DECLARE SECTION;
> VARCHAR DB_Rows [ 50 ] [ 256 ]; /* at most 50 VARCHAR values */
> EXEC SQL END DECLARE SECTION;
Try declaring the fetched_rows parameter as
VARCHAR *fetched_rows[]
What you declared with 'VARCHAR *fetched_rows' was a pointer to ONE
VARCHAR. What you want is a pointer to an ARRAY of VARCHARS. This
way, fetched_rows[0] is the first VARCHAR in the array, and you can
use fetched_rows[0].arr and fetched_rows[0].len, etc.etc.etc.
Hope this works. I had to go back to long-term storage and dig that one up. But don't worry - even gurus get confused with pointers once in a while.
-- --- Allen Kirby AT&T ITS Production Services akirby_at_att.com Alpharetta, GA.Received on Wed Jan 08 1997 - 00:00:00 CST