If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > ANSI SQL > problem about Pro*C

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 11-28-02, 06:14
xf2002 xf2002 is offline
Registered User
 
Join Date: Sep 2002
Posts: 9
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 21:48.
Reply With Quote
  #2 (permalink)  
Old 11-28-02, 08:16
andrewst andrewst is offline
Moderator.
 
Join Date: Sep 2002
Location: UK
Posts: 5,171
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
__________________
Tony Andrews
http://tinyurl.com/tonyandrews
Reply With Quote
  #3 (permalink)  
Old 11-28-02, 20:16
xf2002 xf2002 is offline
Registered User
 
Join Date: Sep 2002
Posts: 9
Re: problem about Pro*C

Quote:
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.

Quote:
>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.

Quote:
>- 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 20:48.
Reply With Quote
  #4 (permalink)  
Old 11-29-02, 06:01
andrewst andrewst is offline
Moderator.
 
Join Date: Sep 2002
Location: UK
Posts: 5,171
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.
__________________
Tony Andrews
http://tinyurl.com/tonyandrews
Reply With Quote
  #5 (permalink)  
Old 11-29-02, 09:16
xf2002 xf2002 is offline
Registered User
 
Join Date: Sep 2002
Posts: 9
Re: problem about Pro*C

Quote:
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!
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On