Re: Pro*C problem

From: Marc Lodico <mlodico_at_NOSPAMbigfoot.com>
Date: 1997/12/18
Message-ID: <3499C723.CE3EF0F4_at_NOSPAMbigfoot.com>#1/1


Yes, Just look up dynamic sql, method 3 or 4 in the Oracle Pro*C reference book.

I've included an example that I created:

/*======================================*

*

DECLARES
*
*======================================*/
EXEC SQL BEGIN DECLARE SECTION;
  varchar sqlstmt[1024], sqlstmt1[1024], user_po_no[30], product[30];   int status, rno, receipt_no, qty_recv, qty_exp; EXEC SQL END DECLARE SECTION;
/*======================================*
  • ASSIGN SQL STATEMENT TO sqlstmt.arr *
    *======================================*/
    sprintf(sqlstmt.arr, "select rd.receipt_no, user_po_no, user_prod_key, qty_recv, qty_exp "); strcat(sqlstmt.arr, "from receipt_detl rd, po_detl_ref pdr "); sprintf(where_cond,"where receipt_no = %d and rd.atc_po_no = pdr.atc_po_no", 1561); strcat(sqlstmt.arr, where_cond); sqlstmt.len = strlen(sqlstmt.arr); printf("sqlstmt=\n%s\n", sqlstmt.arr);
/*=====================================*

* EXAMPLE : DYNAMIC SQL METHOD 3 *
*=====================================*/
EXEC SQL DECLARE prep_get_invoice STATEMENT; EXEC SQL DECLARE get_inv_1 CURSOR FOR prep_get_invoice; EXEC SQL PREPARE prep_get_invoice FROM :sqlstmt;

EXEC SQL OPEN get_inv_1;
EXEC SQL fetch get_inv_1 into :receipt_no, :user_po_no, :product,

                                                    :qty_recv, :qty_exp;

EXEC SQL CLOSE get_inv_1;

Any questions you can email me, just remove the NOSPAM in my address.

Marc L.

Michael Hsiao wrote:

> Hi :
>        Can table name be a variable by Oracle Pro*C .
>    Example :  insert into variable values ..........
>      I don't want using embeded SQL DBMS_SQL package
> --
>
>         Michael Hsiao
Received on Thu Dec 18 1997 - 00:00:00 CET

Original text of this message