Oracle Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsDatabasesOracle Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old December 14th, 2004, 04:24 PM
shaily shaily is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2004
Posts: 3 shaily User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
cursor query not working

Hi,

I had created a stored procedure with the cursor and was working correctly before but know it does not give me any execution error but neither gives the desired output.

Only thing that has changed is more tables are added to the schema. The Cursor query is to retrieve all the tables from schema. I have kept dbms_output statement before and after the cursor for loop to determine where it stops. The last statement it executes is the statement before the cursor for loop.

It would be great if anybody can help me solve this issue.

Thanks.

Reply With Quote
  #2  
Old December 15th, 2004, 02:53 PM
beunique beunique is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2004
Posts: 50 beunique User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 5
Could you post your code - from your description I can't think of anything.

Reply With Quote
  #3  
Old December 16th, 2004, 11:21 PM
shaily shaily is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2004
Posts: 3 shaily User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
CREATE OR REPLACE Procedure UpdateServiceID is

cur BINARY_INTEGER := DBMS_SQL.OPEN_CURSOR;

rows_processed INTEGER;
strSql VARCHAR2(256);

cursor c_tableName is select table_name from all_tables where owner = 'SysOperator' ;

BEGIN

for vc in c_tablename
LOOP

strSql := 'update ' || vc.TABLE_NAME || ' set ( serviceoperatorID ) = ( select opertorID from Services where serviceID = ServiceNo ) where ServiceNo is not null ' ;

-- dbms_output.put_line(strSql);
cur := dbms_sql.open_cursor;
dbms_sql.PARSE( cur , strSql , dbms_sql.v7);

rows_processed := dbms_sql.execute(cur);

dbms_sql.close_cursor(cur);

end loop;
commit;
EXCEPTION

WHEN OTHERS THEN
DBMS_OUTPUT.PUT_LINE(SQLERRM || ' at pos ' || DBMS_SQL.LAST_ERROR_POSITION);

END;

Reply With Quote
  #4  
Old December 18th, 2004, 11:20 AM
beunique beunique is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2004
Posts: 50 beunique User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 5
MMmm - have not see this style of Dynamic SQL for some time.

I would advise you to look at EXECUTE IMMEDIATE this should do as you want.

let me know if this fails and I will dig out my old dynamic examples.

Reply With Quote
  #5  
Old December 19th, 2004, 08:10 PM
shaily shaily is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2004
Posts: 3 shaily User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Thanks for the suggestion, I had already tried 'execute immediate' and still it does not load the cursor.

One more interesting thing I noticed, the query executes when logged in as 'sys'.

Or copying into another schema and making the necessary changes.

Feel free to give any suggestions/guess, as it may help me to narrow down on my issue.

Reply With Quote
  #6  
Old December 27th, 2004, 10:45 AM
ssenthilkumaran ssenthilkumaran is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2004
Posts: 6 ssenthilkumaran User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Please tell me the version of oracle.
you have put a loop and endloop between the loop and endloop you are opening a cursor and closing it.
when you execute it is very fast and internally it is not getting closed immediatly. for that u can use immediate execute in oracle 8 and above and in oracle 9i you can use sys_refcursors.
thanks,
Quote:
Originally Posted by shaily
Thanks for the suggestion, I had already tried 'execute immediate' and still it does not load the cursor.

One more interesting thing I noticed, the query executes when logged in as 'sys'.

Or copying into another schema and making the necessary changes.

Feel free to give any suggestions/guess, as it may help me to narrow down on my issue.

Reply With Quote
Reply

Viewing: Dev Shed ForumsDatabasesOracle Development > cursor query not working


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway
Stay green...Green IT