Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> Re: Embedded SQL and C appl

Re: Embedded SQL and C appl

From: Thomas Kyte <tkyte_at_us.oracle.com>
Date: Wed, 08 Jul 1998 14:49:50 GMT
Message-ID: <35a586fa.7223546@192.86.155.100>


A copy of this was sent to achristi_at_my-dejanews.com (if that email address didn't require changing) On Wed, 08 Jul 1998 13:26:39 GMT, you wrote:

>I'm not sure if this is the correct message base, but here goes.
>
>Does anyone know how or can provide me with the information and how to create
>an Embedded SQL C application that say allows users to type in TABLE NAMES
>and the program counts all the records in that table. It's a very simple
>proof of concept that has me stumped. I am using Oracle 7.3.x and Pro*C.
>
>Please send reponses to mwong_at_wei.org. Thanks very much.
>
>-----== Posted via Deja News, The Leader in Internet Discussion ==-----
>http://www.dejanews.com/rg_mkgrp.xp Create Your Own Free Member Forum

It would look something like:

static void process( char * tname )
{
EXEC SQL BEGIN DECLARE SECTION;

    int         cnt;
    varchar     sqlstmt[512];

EXEC SQL END DECLARE SECTION;     EXEC SQL WHENEVER SQLERROR DO sqlerror_hard();

    sprintf( sqlstmt.arr, "select count(*) from %s", tname );     sqlstmt.len = strlen(sqlstmt.arr);

    EXEC SQL PREPARE S FROM :sqlstmt;
    EXEC SQL DECLARE C CURSOR FOR S;
    EXEC SQL OPEN C;
    EXEC SQL FETCH C INTO :cnt;
    EXEC SQL CLOSE C;     printf( "There are %d rows in %s\n", cnt, tname ); }  

Thomas Kyte
tkyte_at_us.oracle.com
Oracle Government
Herndon VA  

http://govt.us.oracle.com/ -- downloadable utilities  



Opinions are mine and do not necessarily reflect those of Oracle Corporation  

Anti-Anti Spam Msg: if you want an answer emailed to you, you have to make it easy to get email to you. Any bounced email will be treated the same way i treat SPAM-- I delete it. Received on Wed Jul 08 1998 - 09:49:50 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US