Results 1 to 5 of 5
  1. #1
    Join Date
    Sep 2002
    Posts
    9

    Unanswered: problem about Pro*C

    problem is :The output of a query in Pro*C program is different from in Sql plus!!?? It made me crazy because i can't find where i made wrong.

    The following are the main part of the Pro*C code:

    ....
    EXEC SQL BEGIN DECLARE SECTION;
    int rowcount;
    EXEC SQL END DECLARE SECTION;
    ....
    EXEC SQL SELECT COUNT(*)
    INTO :rowcount
    FROM BENCH
    WHERE KSEQ = 2;
    printf("rowcount=%d",rowcount);
    ...

    the query in Sql plus:
    sqlplus>SELECT COUNT(*)
    2 FROM BENCH
    3 WHERE KSEQ = 2;

    the platorm is oracle8i+RedHat 7.2.

    and I try it on another platform(alpha true64 unix5.0+oracle8i) and it seems everything is OK so far.
    I don't know why,since the configurations on two platforms are identical.

    Do you have any idea?
    Thanks in advance!
    Last edited by xf2002; 12-01-02 at 22:48.

  2. #2
    Join Date
    Sep 2002
    Location
    UK
    Posts
    5,171
    Provided Answers: 1

    Re: problem about Pro*C

    You don't say what the difference is exactly - are they giving different non-zero values for the COUNT(*), or is one returning zero?

    Some possibilities:
    - you are logged on as a different user and counting rows from a different table with the same name.
    - you are logged on as a different user and BENCH is a view that returns different results for different users (e.g. has WHERE created_by = USER)
    - Row Level Security is being used on this table, and you have a different CONTEXT set

  3. #3
    Join Date
    Sep 2002
    Posts
    9

    Re: problem about Pro*C

    Originally posted by andrewst
    >You don't say what the difference is exactly - are they giving different >non-zero values for the COUNT(*), or is one returning zero?
    yes,they return different values:the first one is 244,which is wrong:the second 1,right,because kseq has unique value.

    >Some possibilities:
    >- you are logged on as a different user and counting rows from a >different table with the same name.
    >- you are logged on as a different user and BENCH is a view that >returns different results for different users (e.g. has WHERE >created_by = USER)
    exactly the same user and it was he who created table bench.

    >- Row Level Security is being used on this table, and you have a >different CONTEXT set
    it should not be used,however I am not very sure about this.
    244 was returned again when running some other similiar query,for example,

    EXEC SQL SELECT COUNT(*)
    INTO :rowcount
    FROM BENCH
    WHERE K10K = 2;
    printf("rowcount=%d",rowcount);

    but not all.The most of results are correct.
    Last edited by xf2002; 11-28-02 at 21:48.

  4. #4
    Join Date
    Sep 2002
    Location
    UK
    Posts
    5,171
    Provided Answers: 1

    Re: problem about Pro*C

    Sorry, Pro*C is not really my strong point. But I can only imagine that either the Pro*C is not running quite the SELECT you think it is, or that the SELECT is not happening at all and the variable still contains an old value it had before the SELECT. I don't know what to suggest to find out, though.

  5. #5
    Join Date
    Sep 2002
    Posts
    9

    Re: problem about Pro*C

    Originally posted by andrewst
    Sorry, Pro*C is not really my strong point. But I can only imagine that either the Pro*C is not running quite the SELECT you think it is, or that the SELECT is not happening at all and the variable still contains an old value it had before the SELECT. I don't know what to suggest to find out, though.
    yes,I think so beacause I got the elapsed time of its running ,which is incredible short.However,I restart the oracle and even the machine and
    it still exists. I can't believe it!! Maybe I should calm down first and think it over again.
    Anyway,Thank you very much!

Posting Permissions

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