Oracle 11g Express Edition 11.2.0
Table "RIGHT" data (contains only 1 row with name = Test):
Id | Name
1 Test
2 New2
3 New14
...
SELECT COUNT(*) FROM RIGHT WHERE name = 'Test';
Result = 1
I have procedure in package TEST:
create or replace
PACKAGE BODY TEST
AS
PROCEDURE FIND_RIGHT(rightName IN VARCHAR2)
IS
countrows NUMBER;
BEGIN
SELECT COUNT(*) INTO countrows FROM RIGHT WHERE name = rightName;
/* DEBUG POINT !!! in this point countrows = 212 !!!! */
...
END;
END TEST;
And run it from other procedure:
DECLARE
rightName VARCHAR2(200);
BEGIN
rightName := 'Test';
TEST.FIND_RIGHT(rightName);
END;
I run debugger (in Oracle SQL Developer) and debug point after select. I see countrows = 212.
Why countrows != 1 ???
UPDATED: All transaction is commited. Open only 1 session (from SQL Developer). Table Rights has 3 indexes (table is big, I don't write all colums in the post). Procedures have many input params (custom objects), but I drop extra information.
UPDATED #2: I change code to
create or replace
PACKAGE BODY TEST
AS
PROCEDURE FIND_RIGHT(rightName IN VARCHAR2)
IS
countrows NUMBER;
testVar VARCHAR2(200);
BEGIN
testVar := 'Test';
SELECT COUNT(*) INTO countrows FROM RIGHT WHERE name = testVar;
/* in this point countrows = 1 */
...
END;
END TEST;