Results 1 to 5 of 5
  1. #1
    Join Date
    Apr 2004
    Posts
    6

    Unhappy Unanswered: Pro*C Cursor problem (Urgent)

    Hi All,

    i'm trying to embedd a very simple cuursor in C code. But when ever i complie it i get syntatic error.

    I have tried it in two different ways , but none works.......

    Code snippets are

    /**********************Code 1*******************************************/
    int myFunction()
    {
    int i,limit;

    EXEC SQL BEGIN DECLARE SECTION;

    char id[64]="";
    char pass[64]="";
    char path[246]="";

    EXEC SQL END DECLARE SECTION;

    EXEC SQL CONNECT :dbid;

    EXEC SQL SELECT COUNT(*) INTO :limit FROM tbl_customermaster;

    EXEC SQL DECLARE customer_cursor CURSOR FOR
    SELECT CUSTOMERID, CUSTOMERPASSWD, CUSTOMERDIRPATH FROM TBL_CUSTOMERMASTER;

    EXEC SQL FOR :limit OPEN customer_cursor;

    while(1)
    {
    EXEC SQL whenever not found do break;
    EXEC SQL FOR :limit FETCH customer_cursor INTO :id, :pass, :path;

    printf("\n CUSTOMERID %s CUSTOMERPASSWD %s CUSTOMERDIRPATH %s\n",id,pass,path);
    }
    return(0);
    }


    /****************************Code 2********************************************/

    int myFunction2()
    {
    int i;

    struct customer
    {
    varchar id[64];
    varchar pass[64];
    varchar path[246];
    };

    struct customer *custrec ;

    if ((custrec = (struct customer *) malloc(sizeof(struct customer))) == 0)
    {
    fprintf(stderr, "Memory allocation error.\n");
    exit(1);
    }

    EXEC SQL CONNECT :dbid;

    EXEC SQL DECLARE cust_cur CURSOR FOR
    SELECT CUSTOMERID, CUSTOMERPASSWD, CUSTOMERDIRPATH FROM TBL_CUSTOMERMASTER;
    EXEC SQL OPEN cust_cur;

    EXEC SQL WHENEVER NOT FOUND DO break;

    for (;;)
    {
    EXEC SQL FETCH cust_cur INTO :emp_rec_ptr;
    printf("%-11s%9.2f%13.2f\n", custrec->id,
    custrec->pass, custrec->path);
    }

    EXEC SQL CLOSE cust_cur;
    return(0);
    }


    /************************************************** *************/

    any help will be appriciated.......

    regards
    Kuldeep
    Last edited by CoolDeep; 04-13-04 at 06:46.

  2. #2
    Join Date
    Aug 2003
    Location
    Guwahati, India
    Posts
    33

    Re: Pro*C Cursor problem (Urgent)

    Please a bit more specific. If you get errors, plase give the output file of error. I am having a legacy system, where I am running form30 , but there declaration syntax is like

    char id[64]="\0" ;

    That is you are making it NULL .

    I may help you but please enclose a error outpur and your environment also.
    G J Shankar Nath
    IT Consultant, Vedswasti Services Pvt. Ltd
    Guwahati-781007
    India

  3. #3
    Join Date
    Apr 2004
    Posts
    6

    Re: Pro*C Cursor problem (Urgent)

    Thanks for replying.....


    The error dump for Cosde one is

    --------------------------------------------------------------------------

    Pro*C/C++: Release 8.1.7.0.0 - Production on Tue Apr 13 17:54:55 2004

    (c) Copyright 2000 Oracle Corporation. All rights reserved.

    System default option values taken from: /u01/oracle/product/8.1.7/precomp/admin/pcscfg.cfg

    Semantic error at line 61, column 33, file customerdata2.pc:
    EXEC SQL SELECT COUNT(*) INTO :limit FROM TBL_CUSTOMERMASTER;
    ................................1
    PCC-S-02322, found undefined identifier
    SELECT CUSTOMERID, CUSTOMERPASSWD, CUSTOMERDIRPATH FROM TBL_CUST
    OMERMASTER ;
    ..1
    PLS-S-00201, identifier 'TBL_CUSTOMERMASTER' must be declared
    SELECT CUSTOMERID, CUSTOMERPASSWD, CUSTOMERDIRPATH FROM TBL_CUST
    OMERMASTER ;
    ..1
    PLS-S-00000, SQL Statement ignored
    Semantic error at line 64, column 3, file customerdata2.pc:
    SELECT CUSTOMERID, CUSTOMERPASSWD, CUSTOMERDIRPATH FROM TBL_CUST
    OMERMASTER ;
    ..1
    PCC-S-02346, PL/SQL found semantic errors
    Semantic error at line 66, column 19, file customerdata2.pc:
    EXEC SQL FOR :limit OPEN customer_cursor;
    ..................1
    PCC-S-02322, found undefined identifier
    Semantic error at line 66, column 19, file customerdata2.pc:
    EXEC SQL FOR :limit OPEN customer_cursor;
    ..................1
    PCC-S-02330, expecting an expression of integer type
    Semantic error at line 71, column 17, file customerdata2.pc:
    EXEC SQL FOR :limit FETCH customer_cursor INTO :id, :pass, :path
    ;
    ................1
    PCC-S-02322, found undefined identifier
    Semantic error at line 71, column 17, file customerdata2.pc:
    EXEC SQL FOR :limit FETCH customer_cursor INTO :id, :pass, :path
    ;
    ................1
    PCC-S-02330, expecting an expression of integer type

    -------------------------------------------------------------------------------

    hope to hear from u soon.........

    regards
    Kuldeep

  4. #4
    Join Date
    Apr 2004
    Location
    Lima-Peru
    Posts
    7
    you must declare limit like this:

    EXEC SQL BEGIN DECLARE SECTION;

    char id[64]="";
    char pass[64]="";
    char path[246]="";

    int limit;
    EXEC SQL END DECLARE SECTION;

  5. #5
    Join Date
    Aug 2003
    Location
    Where the Surf Meets the Turf @Del Mar, CA
    Posts
    7,776
    Provided Answers: 1
    Look in $ORACLE_HOME/precomp/demo/proc, there are examples.
    You can lead some folks to knowledge, but you can not make them think.
    The average person thinks he's above average!
    For most folks, they don't know, what they don't know.
    Good judgement comes from experience. Experience comes from bad judgement.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •