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!

string contains function

SniipeDec 12 2006 — edited Apr 16 2010
Hello I have possible strings that come into a stored procedure like the following:

jag1969
jag*
*1969

The first one above contains no * (wild card) so I'm gonna use IS
The next one contains a wildcard at the end so search for all strings that start with 'jag'
the last one searches for all strings that end in 1969


This code does not work at all, but its the idea I'm looking for :) (I guess I'm looking for a substitute syntax to CHARINDEX) Any help would be greatly appreciated. Cheers
if p_QuoteID is not null then
   if (CHARINDEX('*', p_QuoteID) = 1) then
      --The wildcard * is at the start of the quote number--
      thissql := thissql || 'and quo.QUOTEID LIKE '|| p_QuoteID ||'%'' ';			
   elsif (CHARINDEX('*', p_QuoteID) = len(p_QuoteID)-1) then
      --The wildcard is at the end of the quote number
      thissql := thissql || 'and quo.QUOTEID LIKE ''%'|| p_QuoteID ||' ';
   else
      --There is no wild card
      thissql := thissql || 'and quo.QUOTEID IS '|| p_QuoteID ||' ';
   end if;		
end if;
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jan 12 2007
Added on Dec 12 2006
11 comments
2,465 views