How to search a value in a string
Greate oracle programmers
how are u all doing. i am facing a problem in query. actually i wanna search a value in string using query. just read the piece of code below
DECLARE
LC_VALUE VARCHAR2(100) := '51,52,53,54';
CHK NUMBER;
BEGIN
SELECT 1 INTO CHK
FROM DUAL
WHERE TO_CHAR(51) IN (LC_VALUE);
MESSAGE(CHK);PAUSE;
EXCEPTION WHEN OTHERS THEN
MESSAGE(SQLERRM);PAUSE;
END;
I am unable to find my value in string using query. i have tried the instr function also but the problem with this function is that suppose if i wanna search '1' in '51,52,53' then the value is found in string although there is not as such value as but 51. also i dont want to use the dynamic SQL for this pupose
i m waiting for repsonse please help me out.
Regards
Kamran Ahmed
[email protected]
you can do something like
select * from emp
where
'1000,2000,3000,4000,5000,6000,7000,8000,9950' like to_char(sal,'FM999999999990')||',%' or
'1000,2000,3000,4000,5000,6000,7000,8000,9950' like '%,'||to_char(sal,'FM999999999990')||',%' or
'1000,2000,3000,4000,5000,6000,7000,8000,9950' like '%,'||to_char(sal,'FM999999999990') or
'1000,2000,3000,4000,5000,6000,7000,8000,9950' = to_char(sal,'FM999999999990');
EMPNO ENAME JOB MGR HIREDATE SAL COMM DEPTNO
7788 SCOTT ANALYST 7566 19-APR-87 3000 20
7839 KING PRESIDENT 17-NOV-81 5000 10
7902 FORD ANALYST 7566 03-DEC-81 3000 20
Similar Messages
-
How to search this value in oracle database to find out the table
Hi expert,
I know there is a value in oracle database, please show me how to search this value in oracle database to find out the table holding this value.
Many Thanks,918440 wrote:
Hi friends,
this question is really practical, I already know there is value from application saved in database, I want to search the whole database to figure out which table the value is contained.write SQL that writes SQL to query every table.
Handle: 918440
Status Level: Newbie
Registered: Mar 2, 2012
Total Posts: 20
Total Questions: 10 (10 unresolved)
why do you waste time here when you NEVER get any answer to any question you post? -
Can u tell me how to convert int value in to string
hi to all, can u tell me how to convert int value in to string.
hi to all, can u tell me how to convert int value in
to string.Even this way:
int number = 155;
String mystring = ""+155;
[\code] -
How can i store values from my String into Array
Hi guys
i wants to store all the values from my string into an array,,,, after converting them into intergers,,,, how i can do this becs i have a peice of code which just give me a value of a character at time,,,,charat(2)...BUT i want to the values from String to store in an Array
here is my peice of code which i m using for 1 char at time
int[] ExampleArray2 = new int[24];
String tempci = "Battle of Midway";
for(int i=0;i>=tempci.length();i++)
int ascii = tempci.charAt(i); //Get ascii value for the first character.public class d1
public static final void main( String args[] )
int[] ExampleArray2 = new int[24];
String tempci = "Battle of Midway";
for(int i=0;i<tempci.length();i++)
int ascii = tempci.charAt(i);
ExampleArray2=ascii;
for(int i=0;i<ExampleArray2.length;i++)
System.out.println(ExampleArray2[i]); -
How to trim decimal values in a string?
Hi
How do i trim decimal value in a string..
suppose i have 1.00, i want it to be displayed as 1
Is there any Round off functionality in WD ABAP?
Regards,
Puneethi,
Try using the mathematical function abs().
ABS( VAR1 ). Which will return the numeric value only.
Thanks
Yogesh -
How to search special characters in a string
Hi all,
I want to search special characters in all string columns and all rows in the table.
The table has about 5 string columns and about 5.000.000 rows. For each row and column, I have to search entries, which included special characters like ", !, ? or something else (f.ex. "Mama?Mia" or "!!!Hotel out of order!!!"). The problem, the character could stand at each position in the string.
What's the best and most performance possibility to search such entries?? Is it possibility only by SQL; is there a special function for this?? Or must I use PL/SQL.
Thanks for helping
DanaHTH
Laurent Schneider
OCM DBA
SQL> select * from z;
S
Mama?Mia
a b c
123
SQL> select * from z where translate(s,'~ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz1234567890','~') is not null;
S
Mama?Mia
SQL> select * from z where regexp_like(s, '[^[:alnum:][:space:]]');
S
Mama?Mia -
How can i convert values in my string to ascii characters
Hi guy.
I am wrinting a code but i m stuck, I have a string with (Battle of Midway) in it, Now i want to convert each character in this string with the asci character,,,
String temp = {"Battle of Midway"};
so the ascii will be:
B=66 a=97 t=116 l=108 e=101 o=111 f=102 M=77 i=105 d=100 w=119 y=121
i found all these number for all the charachers, but i donno how to covert this string into ascii characerts... ofcurse i can do it one by one...but is there any class or method i can use for this,,,,, Once i convert all the character (from string) to ascii character THEN i have to convert it back from ascii to character,,
Is anybody has any idea
Thanks alot in AdvanceYou get get the ascii code for those characters by doing something like:
int ascii = str.charAt(0); //Get ascii value for the first character.
Kaj -
How to Copy a value of a String to the RAM memory?
Hi there,
I was wondering how to copy a String into the ram memory (consider you're doing right click on THIS word and choose 'Copy'; the String's Value will be to the ram memory for a later Paste).
In my application, a user has a table and he right click on it and choose Copy. I get the value of the item (Obj) but face dificulties to add it to RAM.
my code looks like this:
if (obj!=null) //inside I have the value (say: 12345 --< Obj.toString)
Action copyAction = TransferHandler.getCopyAction();
int id = ActionEvent.ACTION_PERFORMED;
String name = (String) copyAction.getValue(Action.NAME);
long l = EventQueue.getMostRecentEventTime();
copyAction.actionPerformed(new ActionEvent(XXXXXXX, id, name, l ,0));
///what comes in the XXXXXXX
}I tried, instead of the XXXXXXX, to put Obj or Obj.toString but...nothing.
Anyone?Thanks,
should implement ClipboardOwner
and do this:
StringSelection stringSelection = new StringSelection( obj.toString() );
Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
clipboard.setContents( stringSelection, this );
@Override
public void lostOwnership(Clipboard clipboard, Transferable contents)
//do nothing!
} -
How to search for value records for a specific period of time?
Hi,
I am building an application where I need to use BDB to store tons of call records.
In the call records, I have the following fields:
1. from-caller
2. to-caller
3. begin-time
4. end-time
5. account-code
6. user-code
I want to use end-time's microsecond representation to serve as the Key.
So, how can I do the following data lookup?
1. Search for all Value records between 2009-10-11 to now()
2. Search for all Value records between 2009-10-11 to now() with account-code = 100
3. Search for all Value records between 2009-10-11 to now() with account-code = 100 and user-code=10
Is there any similar examples out there that I can refer to?
Thanks,
JBHi,
Btw, my operation is mostly:
1. Append call records
2. Search call records
3. Remove ending records that are older than XX days
Please kindly advise on how I should best structure the data to meet this purpose.
Thanks,
JB -
How to search attribute values
How to find the attribute values ("0_0_0_1" ) in the following xml example.
Example:
var xml:XML=
<root>
<country id="0">
<states id="0_0">
<city id="0_0_0">
<village id="0_0_0_0"></village>
<village id="0_0_0_1"></village>
<village id="0_0_0_2"></village>
</city>
</states>
<states id="0_1">
</states>
</country>
<country id="1"></country>
</root>Do you mean like a depth first search?
package
import flash.display.Sprite;
public class XmlAttributes extends Sprite
protected var xml:XML = <root>
<country id="0">
<states id="0_0">
<city id="0_0_0">
<village id="0_0_0_0"></village>
<village id="0_0_0_1"></village>
<village id="0_0_0_2"></village>
</city>
</states>
<states id="0_1">
</states>
</country>
<country id="1"></country>
</root>;
public function XmlAttributes()
super();
var result:XML = depthFirstSearch(xml);
trace(result.localName());
public function depthFirstSearch(node:XML):XML
for each (var child:XML in node.children())
if (("@id" in child) && (child.@id == "0_0_0_1"))
return child;
else
var result:XML = depthFirstSearch(child);
if(result)
return result;
return null;
The XML tags in the code example above are being stripped - not sure why they cannot be encoded / escaped. It is the XML from your example. -
How to take the values from a String ( CSV values).
Hi All,
I am passing csv String to a procedure as in parameter,but I have to take the values from a csv String one by one.Please let me know Is there any StringTokenizer function in oracle to take values like in java. Here is my javacode.
import java.util.StringTokenizer;
public class Sample {
public static void main(String[] args) {
String s="one,two,three,four,five";
StringTokenizer stringTokenizer=new StringTokenizer(s,",");
System.out.println( stringTokenizer.countTokens());
System.out.println(stringTokenizer.hasMoreTokens());
while(stringTokenizer.hasMoreTokens()){
System.out.print(stringTokenizer.nextToken());
o/p: one two three four fiveSomething based around one of these two methods should assist...
select substr( the_string
, decode( level, 1, 1, instr(the_string,',',1,level-1)+1)
, decode( instr(the_string,',',1,level), 0, length(the_string), instr(the_string,',',1,level) - decode( level, 1, 0, instr(the_string,',',1,level-1))-1)
) the_value
from ( select '10,12,20,30,30,3,12,12,56' the_string
from dual
connect by level < length(replace(translate(the_string,'01234567890','00000000000'),'0')) + 2
or
SQL> select REGEXP_SUBSTR ('a,b,c,d,e', '[^,]+', 1, level) from dual connect by level<=5
2 /
REGEXP_SU
a
b
c
d
e
SQL> -
How to change the value of subtitution string in a page at runtime
Hi,
I need to change the value of a substitution string which is mentioned in application attributes at runtime.
The value will be fetched from a field in database on load of each screen.
Can anybody help.......
Help will be appriciated........thanx in advance
SunilSubstitution strings are meant to be static, like global constants.
If you need some variable stuff, use application level items and set them using Application level computations/processes -
How to search for a set of string in a column
Dear all,
From a client application I have a Text field where the user can enter a text or a sentence for instance like :
"Home for rent"
How to make an efficient search in my table for records containing the search patter ?
Knowing that it could be a set of words like "HOME RENT POOL"
Idea is to make a kind of semantic search based on the words and return records that match.
Any advise is welcome
regardsYou should definitely look into full-text search. The idea that Kalman floated is doable, but it require a lot more work on your part. Full-text does a lot work for you, for instance handling inflections, so that a search on "goose" will get a
hit on "geese".
If you have never worked with full-text search before, I recommend to get your hands on this book:
http://www.sqlservermvpdeepdives.com/
http://www.amazon.com/SQL-Server-MVP-Deep-Dives/dp/1935182048/ref=sr_1_1?ie=UTF8&qid=1400851023&sr=8-1&keywords=sql+server+mvp+deep+dives
This book is a collection of chapters written by a number of SQL Server MVPs, and all our royalties goes to War Child International, so you are supporting a good aim if you buy this book.
Chapter 13 by Robert Cain is an excellent introduction to full-text search, although it does not handle Semantic Search added in SQL 2012.
As it happens, my chapter, describes a solution of what Kalman had in mind, although it aimed for the case where you want to permit users to search arbitrary character sequence, and that is not want you want.
Erland Sommarskog, SQL Server MVP, [email protected] -
How to search for words in a string?
I have a list of strings that I need to search for instances
of a certain word (or part of that word) is there a way of doing
this in flash please?Quickest and easiest way to do it is to search through an
array of manually entered words. -
How to Search for "(" error in a string?
I am trying to search for "(" in a string, however the compiler thinks that I searching for a regular expression, and fails.
Exception in thread "main" java.util.regex.PatternSyntaxException: Unclosed group near index 1
Please help me find a way to search for "(" in a string.
Example:
String test="This is a test.";
if (test.matches("(")){
System.out.println("There is a match")
I also tried:
test.matches("\050")
and test.matches("\(")
Thank you!I also tried:
test.matches("\050")
and test.matches("\(")For this particular problem, I think indexOf is a more appropriate solution. However, for future reference, I think what you want to do for parentheses is escape the backslash, not the bracket.
i.e.
test.matches("\\(");
Maybe you are looking for
-
After 2 weeks of jerky videos, unexpected shutdowns, multiplex and buring errors i yesterday finally had something. Than i noticed, that the chapters didn't work. Allright, i thought, those 5-min chapter-marks are a mess anyway. I got myself iMovie06
-
How do you get your ipod touch unlocked ? i have forgot the passcode.
I have forgot my passcode to my ipod touch and its showing DISABLED now where i have the wrong passcode. How can i reset it or unlock it? I don't have the pc i first used when i bought my ipod touch.
-
How do I erase the hard drive on my mac mini with OS X lion
How do I erase the hard drive on my mac mini with os x lion
-
Configure latest ocfs2 built: unable to find com_err library
SLES9 on AMD64 I get this error but libcom_err.so is in /lib and /lib64 Do I habe to set any variable?
-
I have installed iPhoto for iPad and its taking a lot of time to sync the photos from the library
I have been waiting for like 3 hours and iPhoto App can't sync all my albums. I don't have a lot of photos and its weird because the App hangs many times. I have the new iPad.