niXforums Forum Index
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   PreferencesPreferences   Log in to check your private messagesLog in to check your private messages   Log inLog in 
·  nixdoc.net ·  man pages ·  Linux HOWTOs ·  FreeBSD Tips ·  Forums
navigation Forum index » Databases » Oracle
Different result running sql in procedure and in SQL mode
Post new topic   Reply to topic Page 1 of 1 [3 Posts] View previous topic :: View next topic
Author Message
cschang
*nix forums beginner


Joined: 05 Feb 2005
Posts: 20

PostPosted: Wed Feb 23, 2005 2:57 am    Post subject: Re: Different result running sql in procedure and in SQL mode Reply with quote

Sybrand Bakker wrote:
Quote:
On Mon, 21 Feb 2005 21:17:20 -0500, cschang <cschang@maxinter.net
wrote:


My system id 9.2.0.5 on Windows 2000 with sp 4
One of my old table have columns build with char, one is order_id as
char(11) and other one order_lineID as char(6). The table was built in
8.0.5. I recent built a sql like
Select count(*)
From orders
Where order_id = ‘TEST0040800’ and order_lineID = ‘0001’;

When I run this under the SQL> mode, I got count(*) = 1, however when I
put this inside a procedure as
Procedure getCount(v_order_id IN mytable.order_id%TYPE,
V_lineID IN
mytable.order_lineID%TYPE,
V_count OUT number);

BEGIN
Select count(*)
INTO v_count
From orders
Where order_id = v_order_id and order_lineID = V_lineID;

END;

I got v_count = 0 with the same set of input as those of standalone sql.
Unless I included the Trim(order_lineID) = Trim(v_lineID) in where
condition, then I got v_count = 1. Does anyone hear about any bug of
such issue with 9.2? I was definitely sure that the input values were
exact those in SQl mode becasue I wrote out the input.

C Chang


I see a mismatch between the parameter definition
(mytable.order_id%type) and the actual statement (orders.order_id)
are you sure the definition of mytable is exactly the same as the
definition of orders?


--
Sybrand Bakker, Senior Oracle DBA
Sorry, it was my typo in the post. The mytable should be the Orders.

Actually I found the cause when I typed this post. Apparently in 9.2 I
can not use the VARCHAR2 to replace the orders.order_id%TYPE in the
definition of the procedure because of the CHAR type of original column.
If I use v_order_id IN VARCHAR2, then the SQL in the procedure won't
find anything. Thanks.

C Chang
Back to top
Sybrand Bakker
*nix forums Guru


Joined: 03 Apr 2005
Posts: 1766

PostPosted: Tue Feb 22, 2005 5:03 am    Post subject: Re: Different result running sql in procedure and in SQL mode Reply with quote

On Mon, 21 Feb 2005 21:17:20 -0500, cschang <cschang@maxinter.net>
wrote:

Quote:
My system id 9.2.0.5 on Windows 2000 with sp 4
One of my old table have columns build with char, one is order_id as
char(11) and other one order_lineID as char(6). The table was built in
8.0.5. I recent built a sql like
Select count(*)
From orders
Where order_id = ‘TEST0040800’ and order_lineID = ‘0001’;

When I run this under the SQL> mode, I got count(*) = 1, however when I
put this inside a procedure as
Procedure getCount(v_order_id IN mytable.order_id%TYPE,
V_lineID IN
mytable.order_lineID%TYPE,
V_count OUT number);

BEGIN
Select count(*)
INTO v_count
From orders
Where order_id = v_order_id and order_lineID = V_lineID;

END;

I got v_count = 0 with the same set of input as those of standalone sql.
Unless I included the Trim(order_lineID) = Trim(v_lineID) in where
condition, then I got v_count = 1. Does anyone hear about any bug of
such issue with 9.2? I was definitely sure that the input values were
exact those in SQl mode becasue I wrote out the input.

C Chang

I see a mismatch between the parameter definition
(mytable.order_id%type) and the actual statement (orders.order_id)
are you sure the definition of mytable is exactly the same as the
definition of orders?


--
Sybrand Bakker, Senior Oracle DBA
Back to top
cschang
*nix forums beginner


Joined: 05 Feb 2005
Posts: 20

PostPosted: Tue Feb 22, 2005 1:17 am    Post subject: Different result running sql in procedure and in SQL mode Reply with quote

My system id 9.2.0.5 on Windows 2000 with sp 4
One of my old table have columns build with char, one is order_id as
char(11) and other one order_lineID as char(6). The table was built in
8.0.5. I recent built a sql like
Select count(*)
From orders
Where order_id = ‘TEST0040800’ and order_lineID = ‘0001’;

When I run this under the SQL> mode, I got count(*) = 1, however when I
put this inside a procedure as
Procedure getCount(v_order_id IN mytable.order_id%TYPE,
V_lineID IN
mytable.order_lineID%TYPE,
V_count OUT number);

BEGIN
Select count(*)
INTO v_count
From orders
Where order_id = v_order_id and order_lineID = V_lineID;

END;

I got v_count = 0 with the same set of input as those of standalone sql.
Unless I included the Trim(order_lineID) = Trim(v_lineID) in where
condition, then I got v_count = 1. Does anyone hear about any bug of
such issue with 9.2? I was definitely sure that the input values were
exact those in SQl mode becasue I wrote out the input.

C Chang
Back to top
Google

Back to top
Display posts from previous:   
Post new topic   Reply to topic Page 1 of 1 [3 Posts] View previous topic :: View next topic
The time now is Thu Jan 08, 2009 5:57 am | All times are GMT
navigation Forum index » Databases » Oracle
Jump to:  

Similar Topics
Topic Author Forum Replies Last Post
No new posts How to ALTER a table using the ALTOBJ procedure Serge Rielau IBM DB2 1 Fri Jul 21, 2006 1:06 pm
No new posts Running php file everyday on scheduled time sachin PHP 1 Fri Jul 21, 2006 12:49 pm
No new posts Creating relational view for an ODBC result set? antilog@gmail.com Server 0 Fri Jul 21, 2006 5:56 am
No new posts need wget binary transfer mode victorfeng1973@yahoo.com Solaris 7 Thu Jul 20, 2006 9:03 pm
No new posts calling stored procedure using ECPG Jasbinder Bali PostgreSQL 1 Thu Jul 20, 2006 7:53 pm

Loans | Dirty Dozen Brass Band | Credit Card | Watch Anime Online | Bankruptcy
Copyright © 2004-2005 DeniX Solutions SRL
 
Other DeniX Solutions sites: Unix/Linux blog |  electronics forum |  medicine forum |  science forum | 
Privacy Policy


Powered by phpBB © 2001, 2005 phpBB Group
[ Time: 0.1514s ][ Queries: 20 (0.0731s) ][ GZIP on - Debug on ]