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 November 2nd, 2004, 06:52 AM
locus87 locus87 is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2004
Posts: 1 locus87 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
'Execute immediate' sql error

Can anyone tell what is the error in this statement:


execute immediate 'Update '||tabs.table_name||' set ID_CTLGRP = REPLACE(ID_CTLGRP,'''','_') WHERE ID_CTLGRP LIKE '%''%'';

I am replacing all apostrophes with underscores in the field ID_CTLGRP for a number of tables.


Thanks

Reply With Quote
  #2  
Old November 2nd, 2004, 11:34 AM
jim mcnamara jim mcnamara is offline
......@.........
Dev Shed Beginner (1000 - 1499 posts)
 
Join Date: Jun 2004
Posts: 1,308 jim mcnamara User rank is Sergeant Major (2000 - 5000 Reputation Level)jim mcnamara User rank is Sergeant Major (2000 - 5000 Reputation Level)jim mcnamara User rank is Sergeant Major (2000 - 5000 Reputation Level)jim mcnamara User rank is Sergeant Major (2000 - 5000 Reputation Level)jim mcnamara User rank is Sergeant Major (2000 - 5000 Reputation Level)jim mcnamara User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 1 Week 3 Days 5 h 20 m 49 sec
Reputation Power: 48
Code:

Update Real_Table set ID_CTLGRP = REPLACE(ID_CTLGRP,CHR(39),'_') WHERE ID_CTLGRP LIKE '%';


Lose the execute immediate. Then do a select (from all_tables using the owner) to create a list of table names you need to update, edit the list (put a table name in place of real_table) -> create a sql script.

Or you can mess around with three or four ' characters - I find it easier NOT to do that. It's too prone to error.

Code:
execute immediate 
'Update ' ||tabs.table_name|| 
'set ID_CTLGRP = REPLACE(ID_CTLGRP,CHR(39),'_') WHERE ID_CTLGRP LIKE ''''%'''' ';

Reply With Quote
  #3  
Old November 2nd, 2004, 12:56 PM
shammat shammat is offline
Contributing User
Dev Shed Beginner (1000 - 1499 posts)
 
Join Date: Oct 2003
Location: Munich, Bavaria
Posts: 1,007 shammat User rank is Second Lieutenant (5000 - 10000 Reputation Level)shammat User rank is Second Lieutenant (5000 - 10000 Reputation Level)shammat User rank is Second Lieutenant (5000 - 10000 Reputation Level)shammat User rank is Second Lieutenant (5000 - 10000 Reputation Level)shammat User rank is Second Lieutenant (5000 - 10000 Reputation Level)shammat User rank is Second Lieutenant (5000 - 10000 Reputation Level)shammat User rank is Second Lieutenant (5000 - 10000 Reputation Level) 
Time spent in forums: 1 Week 3 Days 13 h 19 m 21 sec
Reputation Power: 67
Quote:
WHERE ID_CTLGRP LIKE '%';
This effectively updates all rows. If you really want to do that, you can simply leave out the WHERE part.

But if you want to search for entries that start with a % you need to escape it:
Code:
WHERE CTLGRP LIKE '\%%' ESCAPE '\';

Reply With Quote
Reply

Viewing: Dev Shed ForumsDatabasesOracle Development > 'Execute immediate' sql error


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 4 hosted by Hostway
Stay green...Green IT