Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Issue with DBMS_SQL - NOT returning value but sql developer does

Sh...Sep 1 2018 — edited Sep 3 2018

Hi All,

I am storing queries in the table and getting executed one by one.

My stored query,

SELECT count(DISTINCT 1) tst    FROM insurance_data v

WHERE ROWNUM < 2

AND v.coverage_type = '''BLDG_GREEN_UPGRADE'''

My code is like below

          vinnercur := dbms_sql.open_cursor;

         

dbms_sql.parse( vinnercur,vsqlquery,dbms_sql.native);

---vsql is my query from database

vexecute := dbms_sql.execute(vinnercur);
           
            dbms_sql.column_value(vinnercur,1,vcnt);
           
            
             vrtn:= dbms_sql.fetch_rows(vinnercur);        

           
            IF vrtn> 0 THEN
                dbms_sql.column_value(vinnercur,1,vcnt);
              
            END IF;

Getting value as 1 in vrtn

But vcnt is 0

when i am running the same query from sql developer as below like then

SELECT count(DISTINCT 1) tst    FROM insurance_data v

WHERE ROWNUM < 2

AND v.coverage_type = 'BLDG_GREEN_UPGRADE'

Getting value as "1"

Can you please suggest what i am doong wrong here.

If required i can post complete code.

Thanks a lot !!

Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Oct 1 2018
Added on Sep 1 2018
9 comments
887 views