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 June 13th, 2005, 04:56 AM
a_lex24 a_lex24 is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2004
Posts: 19 a_lex24 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 45 m 46 sec
Reputation Power: 0
PL/SQL Search Procedure

Hello,

I have created a search procedure that given a string, searches a large text file for that word. The procedure outputs the location and a section of the text around each found occurance. Now my problem is that I want the user to be able to use a wildcard with this procedure e.g. exec txtSearch('p%') will find all occurances of any words that start with 'p'.

Is there a way to do this with instr or do i have to use LIKE?
any ideas?

Reply With Quote
  #2  
Old June 13th, 2005, 10:55 AM
hedge hedge is offline
Contributing User
Dev Shed Novice (500 - 999 posts)
 
Join Date: Apr 2002
Posts: 692 hedge User rank is Sergeant (500 - 2000 Reputation Level)hedge User rank is Sergeant (500 - 2000 Reputation Level)hedge User rank is Sergeant (500 - 2000 Reputation Level)hedge User rank is Sergeant (500 - 2000 Reputation Level)hedge User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 4 Days 23 h 15 m 53 sec
Reputation Power: 19
well I'd be curious as to how you're doing it now. I'd be inclined to use the like keyword in all cases for doing the search. I would think it'd be much faster than querying the data and then doing instr tests on it.

edit: I just re-read and see that you're reading a text file... using file_util package I assume? I still think I'd use the like keyword if it will allow you in a pl/sql statement.

Last edited by hedge : June 13th, 2005 at 10:57 AM.

Reply With Quote
  #3  
Old June 13th, 2005, 04:27 PM
a_lex24 a_lex24 is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2004
Posts: 19 a_lex24 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 45 m 46 sec
Reputation Power: 0
open diag_list;
loop
fetch diag_list into diag_rec;
EXIT when diag_list%NOTFOUND;
loop
strPos := instr(diag_rec.DIAG_DESC,search_String,strPos + 1,1);
EXIT when strPos = 0;
strCount := strCount + 1;
insert into searchDetails values(seq_search.nextval, diag_rec.DIAG_ID, search_String,SUBSTR(diag_rec.DIAG_DESC, strPos, 30));
end loop;
end loop;

do you think i would be able to perform this with the like statement, because i actually need to find the position of the given word so I can grab a section of the text around it. And right now it's only searching a "free text" column. i.e. varchar2(200).

Reply With Quote
  #4  
Old June 13th, 2005, 11:12 PM
hedge hedge is offline
Contributing User
Dev Shed Novice (500 - 999 posts)
 
Join Date: Apr 2002
Posts: 692 hedge User rank is Sergeant (500 - 2000 Reputation Level)hedge User rank is Sergeant (500 - 2000 Reputation Level)hedge User rank is Sergeant (500 - 2000 Reputation Level)hedge User rank is Sergeant (500 - 2000 Reputation Level)hedge User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 4 Days 23 h 15 m 53 sec
Reputation Power: 19
something that might work is to combine approaches. I can't see the definition of your cursor but maybe you could use the like statement in your cursor query to limit the data to the rows that match (you may need to use dynamic sql here) and then once you have the result set use instr to determine the position.

Reply With Quote
  #5  
Old June 14th, 2005, 03:40 PM
a_lex24 a_lex24 is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2004
Posts: 19 a_lex24 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 45 m 46 sec
Reputation Power: 0
If I used the LIKE command, would I still be able to find the position of the word in the text. Or would I have to use INSTR as well.

Reply With Quote
Reply

Viewing: Dev Shed ForumsDatabasesOracle Development > PL/SQL Search Procedure


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