Dynamic SQL with PROC/C++ problem

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Fredrik Lindstrom

    Dynamic SQL with PROC/C++ problem

    Hi folks,

    First I would like to know if there is a better forum regarding Oracle
    issues. I have heard that this forum is obsolete so if that is true please
    redirect me.

    I also want to admit that I am very new to PROC and oracle.

    I want to count the rows in a table using the following:

    unsigned int db_count(char *table_name, char *server_id)
    {
    EXEC SQL BEGIN DECLARE SECTION;
    unsigned int cnt = 0;
    char sqlstmt[MAX_SQLSTMT_LEN GTH];
    EXEC SQL END DECLARE SECTION;

    sprintf(sqlstmt , "SELECT COUNT(*) INTO :cnt FROM %s", table_name);

    printf("sqlstmt = %s\n", sqlstmt);
    EXEC SQL WHENEVER SQLERROR DO return(sql_erro r(server_id, "Error counting
    rows in table %s.", table_name));
    EXEC SQL AT :server_id EXECUTE IMMEDIATE :sqlstmt;

    return(cnt);
    }

    Well this does not work cause I will always get 0 as an answer.

    Any hints?

    Regards
    Fredrik Lindstrom




    ----== Posted via Usenet.Com - Unlimited-Uncensored-Secure Usenet News==----
    http://www.Usenet.com The #1 Newsgroup Service in the World! >100,000 Newsgroups
    ---= 19 East/West-Coast Specialized Servers - Total Privacy via Encryption =---
Working...