Searching for a substring
after running through the forums i couldn't find anything that related to my question. so here it is.
to search for a substring, do i have to search for each individual character or is there an easier method...
for example:
String john,paul,mark,fabio,greg,park,rego
if i wanted to find all the strings with "ar" in them, would i have to search for a, and then r and check if the position of r is +1 a??
or is there an easier way??
thanks for your help!
The documentation is your friend.
http://java.sun.com/j2se/1.4.1/docs/api/index.html
Look up what the method indexOf(String) of the class java.lang.String does.
Similar Messages
-
How to search for perticular substring in given string.
Hi, Can any one tell me how to search for perticular substring in given string.
example:
I have to search for CA in given Order type it may be CA10 or CA15. Please Do the needful.Hi Aniruddha,
check this...
Data var string,
var = 'India'.
search var for 'Ind'.
if sy-subrc = 0. " var having ind
Message 'Ind found' type 'I'.
else . "var not having ind
Message 'Ind not Found' type 'I'.
endif.
thanx
bgan. -
Searching for a substring within a string
can someone reccomend a simple way to search for a substring within a string and count the number occurences of that substring.
The substring and the string will be provided as command line parameters.
Thanks
ggA simple way would be to use the indexOf methods in String:
http://java.sun.com/j2se/1.5.0/docs/api/java/lang/String.html
Not sure what this has to do with event handling though :-P -
How can I search for a substring of a email address or a subject
... without getting hits on other fields or content.
Mail 5.0 seems to have removed the ability to restrict your seach to particular fields. What you get instead is the ability to select 'people' which should be called 'addresses' or 'subjects'. There seems to be an assumption that the desired end point of a search is a single message. But I regularly (several times a week) need to search for messages with certain characteristic and then move, copy or delete them.
This makes mail completely unusable for me. Searching has always been a weak point in mail now it is *much* worse. Any before you ask yes I have submitted feedback to Apple (I have bitched about the searching in every release since OSX released). What I have suggested is that they have an "enable advanced search" in the preferences > advanced menu.
I can see where Apple is coming from but turning MacOS into a *purely* comsumer product aimed at the masses is not the way to go. They don't need to abandon the professional market in order to get the masses. Those of us who need advanced functionality are perfectly capable of digging into preference to enable it if we are given the ability.
I wholely support having a simple system that, out of the box, can be operated intuitively by anyone but that is not incompatible with allowing more sophisticated functionality which might confuse less exprienced users from being activated via preferences.
What I really want is much more complex searching that allow me to find (for example) all emails to a particular domain that mention 'xxxx' in the subject.
If this trend continues I can see me installing linux on my new MacBook pro for work stuff.
Russell, (who has been a Apple fan since well before Mas were invented )rful011 wrote:
What I really want is much more complex searching that allow me to find (for example) all emails to a particular domain that mention 'xxxx' in the subject.
You can make some relatively advanced searches through Spotlight and in turn, the Mailbox search field in the Mail toolbar.
Try this for your example, type the following into the search bar in Mail:
To:domain.com then hit return. This will give you a search token on the To field.
Type subject:xxxx and hit return, this will give you a search token on the subject field -
Searching for a substring using Regular Expression
I have a lengthy String similar to repetetion of the one below
String str="<option value='116813070'>Something1</option><option value='ABCDEF' selected>Something 2</option>"I need to search for the Sub string "<option value='ABCDEF' selected>" (need to get the starting index of sub string) and but the value ABCDEF can be anything numberic with varying length.
Is there any way i can do it using regular expressions(I have no other options than regular expression)?
thanks in advance.If you go through the tutorial then you will find this on the second page:
import java.io.Console;
import java.util.regex.Pattern;
import java.util.regex.Matcher;
public class RegexTestHarness {
public static void main(String[] args){
Console console = System.console();
if (console == null) {
System.err.println("No console.");
System.exit(1);
while (true) {
Pattern pattern =
Pattern.compile(console.readLine("%nEnter your regex: "));
Matcher matcher =
pattern.matcher(console.readLine("Enter input string to search: "));
boolean found = false;
while (matcher.find()) {
console.format("I found the text \"%s\" starting at " +
"index %d and ending at index %d.%n",
matcher.group(), matcher.start(), matcher.end());
found = true;
if(!found){
console.format("No match found.%n");
}It's does everything you need and a bit more. Adapt it to your needs then write a regular expression. Then if you have problems by all means come back and post them up here, but first at least attempt to solve it yourself. -
Help me about Searching for a Substring within a String
Hello everybody,
I have a problem like this:
Assume i type a sentence from keyboard: "I want to play football"
And computer will look for the word "football" to see if this word is in that sentence.
In this case, computer found it.
That is it ! Could anybody help me about this ?
Thank you very much in advance.
still_learnUse the String.indexOf() method:
String original = "I want to play football";
int result = original.indexOf("football");
if (result != -1)
System.out.println("computer found it");
If the word "football" is in the original String, the indexOf() method will return the index of the word. If it does not find the word "football", it will return a value of -1. The String API is full of useful methods.
fitz -
Searching for the nth occurrence of a substring in a string
I need to search for the 63rd occurrence of a substring <i4> and replace it with <string>. Is there an easy way to do this?
Edited by: sarcasteak on Jun 16, 2009 11:52 AMnevermind I got it, if anyone was curious
int z = 0;
while(z<63)
index = index2+3;
index2 = result.indexOf("<param>", index);
resultTest = result.substring(index2);
//System.out.println(index2 + " :" + resultTest );
z++;
String originalSubstring = (result.substring(index2);
String modifiedSubstring = "";
modifiedSubstring = originalSubstring.replaceFirst("<i4>","<string>" );
modifiedSubstring = modifiedSubstring.replaceFirst("</i4>","</string>" );
String fixedString= result.replace(originalSubstring, modifiedSubstring);
System.out.println(fixedString);Edited by: sarcasteak on Jun 16, 2009 12:32 PM -
How can I use SQL to search for a pattern within a field?
Hello, Frank, Solomon, ect
I am now faced with this particular scenario, I've got the SQL to search through a field to find text within the field, but I have to know what it is before it can look for it.
What I have to do is this:
Search through a field, for a pattern, and I won't know what the data is I am looking for. Can this be done in SQL?
For instance, Here is my SQL this far, I was helped allot in order to get to this point.
select table_name,
column_name,
:search_string search_string,
result
from (select column_name,
table_name,
'ora:view("' || table_name || '")/ROW/' || column_name || '[ora:contains(text(),"%' || :search_string || '%") > 0]' str
from cols
where table_name in ('TABLE1', 'TABLE2')),
xmltable (str columns result varchar2(10) path '.')
When you execute the above SQL, you have to pass in a value. What I really need is to alter the above SQL, to make it search for a pattern that exist's within the text of the field itself.
Like for instance, lets say the pattern I am looking for is this" xx-xxxxx-xxxx" and it's somewhere in a field.
I need to alter this SQL to take this pattern and search through all the schemas and tables to look for this pattern match.
Can be done?When you use something dynamically within a function or procedure, roles do not apply and privileges must be granted directly. So, you need to grant select on dba_tab_cols directly. If you want to do pattern matching then you should use regular expressions. The following example grants the proper privileges and uses regexp_instr to find all values containing the pattern xxx-xxxx-xxxx, where /S is used for any non-space character. I limited the tables in order to save time and output for the test, but you can eliminate that where clause.
SYS@orcl> CREATE USER test IDENTIFIED BY test
2 /
User created.
SYS@orcl> ALTER USER test QUOTA UNLIMITED ON USERS
2 /
User altered.
SYS@orcl> GRANT CREATE SESSION, CREATE TABLE TO test
2 /
Grant succeeded.
SYS@orcl> GRANT SELECT ON dba_tab_cols TO test
2 /
Grant succeeded.
SYS@orcl> CONNECT test/test
Connected.
TEST@orcl> SET LINESIZE 90
TEST@orcl> CREATE TABLE table1
2 (tab1_col1 VARCHAR2(60))
3 /
Table created.
TEST@orcl> INSERT ALL
2 INTO table1 (tab1_col1) VALUES ('xxx-xxxx-xxxx')
3 INTO table1 (tab1_col1) VALUES ('matching abc-defg-hijk data')
4 INTO table1 (tab1_col1) VALUES ('other data')
5 SELECT * FROM DUAL
6 /
3 rows created.
TEST@orcl> CREATE TABLE table2
2 (tab2_col2 VARCHAR2(30))
3 /
Table created.
TEST@orcl> INSERT ALL
2 INTO table2 (tab2_col2) VALUES ('this BCD-EFGH-IJKL too')
3 INTO table2 (tab2_col2) VALUES ('something else')
4 SELECT * FROM DUAL
5 /
2 rows created.
TEST@orcl> VAR search_string VARCHAR2(24)
TEST@orcl> EXEC :search_string := '\S\S\S-\S\S\S\S-\S\S\S\S'
PL/SQL procedure successfully completed.
TEST@orcl> COLUMN "Searchword" FORMAT A24
TEST@orcl> COLUMN "Table" FORMAT A6
TEST@orcl> COLUMN "Column/Value" FORMAT A50
TEST@orcl> SELECT DISTINCT SUBSTR (:search_string, 1, 24) "Searchword",
2 SUBSTR (table_name, 1, 14) "Table",
3 SUBSTR (t.column_value.getstringval (), 1, 50) "Column/Value"
4 FROM dba_tab_cols,
5 TABLE
6 (XMLSEQUENCE
7 (DBMS_XMLGEN.GETXMLTYPE
8 ( 'SELECT ' || column_name ||
9 ' FROM ' || table_name ||
10 ' WHERE REGEXP_INSTR
11 (UPPER (' || column_name || '),''' ||
12 UPPER (:search_string) || ''') > 0'
13 ).extract ('ROWSET/ROW/*'))) t
14 WHERE table_name IN ('TABLE1', 'TABLE2')
15 ORDER BY "Table"
16 /
Searchword Table Column/Value
\S\S\S-\S\S\S\S-\S\S\S\S TABLE1 <TAB1_COL1>matching abc-defg-hijk data</TAB1_COL1>
\S\S\S-\S\S\S\S-\S\S\S\S TABLE1 <TAB1_COL1>xxx-xxxx-xxxx</TAB1_COL1>
\S\S\S-\S\S\S\S-\S\S\S\S TABLE2 <TAB2_COL2>this BCD-EFGH-IJKL too</TAB2_COL2>
3 rows selected. -
How to search for particular string in array?
I am struggling to figure out how to search array contents for a string and then delete the entry from the array if it is found.
The code for a program that allows the user to enter up to 20 inventory items (tools) is posted below; I apologize in advance for it as I am also not having much success grasping the concept of OOP and I am certain it is does not conform although it all compiles.
Anyway, if you can provide some assistance as to how to go about searching the array I would be most grateful. Many thanks in advance..
// ==========================================================
// Tool class
// Reads user input from keyboard and writes to text file a list of entered
// inventory items (tools)
// ==========================================================
import java.io.*;
import java.text.DecimalFormat;
public class Tool
private String name;
private double totalCost;
int units;
// int record;
double price;
// Constructor for Tool
public Tool(String toolName, int unitQty, double costPrice)
name = toolName;
units = unitQty;
price = costPrice;
public static void main( String args[] ) throws Exception
String file = "test.txt";
String input;
String item;
String addItem;
int choice = 0;
int recordNum = 1;
int qty;
double price;
boolean valid;
String toolName = "";
String itemQty = "";
String itemCost = "";
DecimalFormat fmt = new DecimalFormat("##0.00");
// Display menu options
System.out.println();
System.out.println(" 1. ENTER item(s) into inventory");
System.out.println(" 2. DELETE item(s) from inventory");
System.out.println(" 3. DISPLAY item(s) in inventory");
System.out.println();
System.out.println(" 9. QUIT program");
System.out.println();
System.out.println("==================================================");
System.out.println();
// Declare and initialize keyboard input stream
BufferedReader stdin = new BufferedReader(new InputStreamReader(System.in));
do
valid = false;
try
System.out.print(" Enter an option > ");
input = stdin.readLine();
choice = Integer.parseInt(input);
System.out.println();
valid = true;
catch(NumberFormatException exception)
System.out.println();
System.out.println(" Only numbers accepted. Try again.");
while (!valid);
while (choice != 1 && choice != 2 && choice != 9)
System.out.println(" Not a valid option. Try again.");
System.out.print(" Enter an option > ");
input = stdin.readLine();
choice = Integer.parseInt(input);
System.out.println();
if (choice == 1)
// Declare and initialize input file
FileWriter fileName = new FileWriter(file);
BufferedWriter bufferedWriter = new BufferedWriter(fileName);
PrintWriter dataFile = new PrintWriter(bufferedWriter);
do
addItem="Y";
System.out.print(" Enter item #" + recordNum + " name > ");
toolName = stdin.readLine();
if (toolName.length() > 15)
toolName = toolName.substring(0,15); // Convert to uppercase
toolName = toolName.toUpperCase();
dataFile.print (toolName + "\t");
do
valid = false;
try
// Prompt for item quantity
System.out.print(" Enter item #" + recordNum + " quantity > ");
itemQty = stdin.readLine();
// Parse integer as string
qty = Integer.parseInt (itemQty);
// Write item quantity to data file
dataFile.print(itemQty + "\t");
valid=true;
catch(NumberFormatException exception)
// Throw error for all non-integer input
System.out.println();
System.out.println(" Only whole numbers please. Try again.");
while (!valid);
do
valid = false;
try
// Prompt for item cost
System.out.print(" Enter item #" + recordNum + " cost (A$) > ");
itemCost = stdin.readLine();
// Parse float as string
price = Double.parseDouble(itemCost);
// Write item cost to data file
dataFile.println(fmt.format(price));
valid = true;
catch(NumberFormatException exception)
// Throw error for all non-number input (integers
// allowed)
System.out.println();
System.out.println(" Only numbers please. Try again.");
while (!valid);
// Prompt to add another item
System.out.println();
System.out.print(" Add another item? Y/N > ");
addItem = stdin.readLine();
while ((!addItem.equalsIgnoreCase("Y")) && (!addItem.equalsIgnoreCase("N")))
// Prompt for valid input if not Y or N
System.out.println();
System.out.println(" Not a valid option. Try again.");
System.out.print(" Add another item? Y/N > ");
addItem = stdin.readLine();
System.out.println();
// Increment record number by 1
recordNum++;
if (addItem.equalsIgnoreCase("N"))
System.out.println();
System.out.println(" The output file \"" + file + "\" has been saved.");
System.out.println();
System.out.println(" Quitting program.");
while (addItem.equalsIgnoreCase("Y"));
// Close input file
dataFile.close();
if (choice == 2)
try {
Read user input (array search string)
Search array
If match found, remove entry from array
Confirm "deletion" and display new array contents
catch block {
} // class
// ==========================================================
// ListToolDetails class
// Reads a text file into an array and displays contents as an inventory list
// ==========================================================
import java.io.*;
import java.util.StringTokenizer;
import java.text.DecimalFormat;
public class ListToolDetails {
// Declare variable
private Tool[] toolArray; // Reference to an array of objects of type Tool
private int toolCount;
public static void main(String args[]) throws Exception {
String line, name, file = "test.txt";
int units, count = 0, record = 1;
double price, total = 0;
DecimalFormat fmt = new DecimalFormat("##0.00");
final int MAX = 20;
Tool[] items = new Tool[MAX];
System.out.println("Inventory List");
System.out.println();
System.out.println("REC.#" + "\t" + "ITEM" + "\t" + "QTY" + "\t"
+ "PRICE" + "\t" + "TOTAL");
System.out.println("\t" + "\t" + "\t" + "\t" + "PRICE");
System.out.println();
try {
// Read a tab-delimited text file of inventory items
FileReader fr = new FileReader(file);
BufferedReader inFile = new BufferedReader(fr);
StringTokenizer tokenizer;
while ((line = inFile.readLine()) != null) {
tokenizer = new StringTokenizer(line, "\t");
name = tokenizer.nextToken();
try {
units = Integer.parseInt(tokenizer.nextToken());
price = Double.parseDouble(tokenizer.nextToken());
items[count++] = new Tool(name, units, price);
total = units * price;
} catch (NumberFormatException exception) {
System.out.println("Error in input. Line ignored:");
System.out.println(line);
System.out.print(" " + count + "\t");
System.out.print(line + "\t");
System.out.print(fmt.format(total));
System.out.println();
inFile.close();
} catch (FileNotFoundException exception) {
System.out.println("The file " + file + " was not found.");
} catch (IOException exception) {
System.out.println(exception);
System.out.println();
// Unfinished functionality for displaying "error" message if user tries to
// add more than 20 tools to inventory
public void addTool(Tool maxtools) {
if (toolCount < toolArray.length) {
toolArray[toolCount] = maxtools;
toolCount += 1;
} else {
System.out.print("Inventory is full. Cannot add new tools.");
// This should search inventory by string and remove/overwrite matching
// entry with null
public Tool getTool(int index) {
if (index < toolCount) {
return toolArray[index];
} else {
System.out
.println("That tool does not exist at this index location.");
return null;
} // classData file contents:
TOOL 1 1 1.21
TOOL 2 8 3.85
TOOL 3 35 6.92Ok, so you have an array of Strings. And if the string you are searching for is in the array, you need to remove it from the array.
Is that right?
Can you use an ArrayList<String> instead of a String[ ]?
To find it, you would just do:
for (String item : myArray){
if (item.equals(searchString){
// remove the element. Not trivial for arrays, very easy for ArrayList
}Heck, with an arraylist you might be able to do the following:
arrayList.remove(arrayList.indexOf(searchString));[edit]
the above assumes you are using 1.5
uses generics and for each loop
[edit2]
and kinda won't work it you have to use an array since you will need the array index to be able to remove it. See the previous post for that, then set the value in that array index to null.
Message was edited by:
BaltimoreJohn -
Search for records in a table on the basis of a function
Hi,
How is it possible to use a function as search criteria in a sql query ?
For example, I have the following query :
select a.job_name JOB_NAME, substr(a.job_name,instr(a.job_name,'.',-1)+1) as AUTNAME
FROM autosys.job a
where a.job_name like %PRD%' and a.command like '%dsjob%'
and a.command not like 'substr(a.job_name,instr(a.job_name,'.',-1)+1)';
This is now working because of the use of function "substr" on the right side of the query.
How can I write the query so as to find the same result as using this function ?
Can someone help me out on this ?
ThanksAmong other things, you have the quotes in the wrong place in the NOT LIKE predicate. As posted, you are searching for records where command does not contain the literal string substr(a.job_name,instr(a.job_name,'.',-1)+1). I don't think that is really what you are after. You need to concatenate the operators to the results of the SUBSTR function. Something more like:
SELECT a.job_name job_name,
SUBSTR(a.job_name, INSTR(a.job_name, '.', -1)+1) as autname
FROM autosys.job a
WHERE a.job_name LIKE 'HP.TM.%PRD.%' and
a.command LIKE '%dsjob.sh%' and
a.command NOT LIKE '%'||SUBSTR(a.job_name, INSTR(a.job_name, '.', -1)+1)||'%'; John -
Searching for an entry in a file that contains 2 words or more...
Hey :)
I created a Binary Search Tree that would hold a list of words located in a .txt file. So, basically, the objective of the program is to search through a typed up document for the words in the search tree, and if the word is found, return it to the user to see.
I have that part working, but what I'm having trouble with is one of the entries in the file. The entry is "data structure." All the other entries are 1 word, like queue, depth-first, etc...but this one is 2 words. I'm having trouble making it so that the search will detect the 2-word entry, "data structure." How do I go about searching for entries that are 2 or more words in length?
I have been struggling with this for some time, and I don't know if it's just me, but I'd really like to get this done since this is the only thing I'm having trouble with right now. I thought I could figure this out, but I'm just putting too much time into it, and I need to submit this tomorrow.
Any help would really be appreciated! :)
Take care,
AlexYea, I was thinking of doing that myself. Turning the two words into one word, so it'll end up like, "datastructure," but how do I do that? Would I use the substring method? Or is there something else that I can use to get rid of whitespace. I'll look that up now on google or something, but in the meantime, if anyone can help me out with this, it would be great.
Just for a reminder, this is my problem :: I need to be able to locate an entry in my document that has 2 words in it. In this case, the entry is, "data structure." How can I go about searching for this 2 word entry? It seems to be a bit more complex than merely searching for one word. Any help you can provide me would be great! :)
Here's the code for the Binary Search Tree:
import java.io.*;
import java.util.*;
public class KeywordBinarySearchTree
BinaryNode root;
//static String[] docWords; // captures each of the words into an array while ignoring punctuation
public KeywordBinarySearchTree()
root = null;
public void preOrderTraversal()
preOrderTraversal(root);
public void inOrderTraversal()
inOrderTraversal(root);
public Comparable findNode(Comparable node)
return dataOfNode(findNode(node, root));
public Comparable dataOfNode(BinaryNode node)
if (node == null)
return null;
else
return node.nodeData;
public BinaryNode insertInOrder(Comparable iNodeData)
BinaryNode nodeWalker; // used to walk through each of the nodes until the appropriate spot
// is found to insert the node of data
BinaryNode parentNode = new BinaryNode(iNodeData); // represents the new root node after each pass through the tree
if (root == null) // if it's a brand new tree with no nodes, then insert the new root of the tree
root = new BinaryNode(iNodeData);
else
nodeWalker = root; // sets current root of tree to nodeWalker
while (nodeWalker != null) // will start its first iteration of the loop at the top of the tree
parentNode = nodeWalker;
if (iNodeData.compareTo(nodeWalker.nodeData) < 0) // if the data to be inserted is less than the current
// node in the tree
nodeWalker = nodeWalker.leftChild; // set nodeWalker to the left child of that node
System.out.println("INSERT NODE: LEFT CHILD");
else
nodeWalker = nodeWalker.rightChild; // otherwise, set nodeWalker to the right child of that node
System.out.println("INSERT NODE: RIGHT CHILD");
} // this loop will determine where the node has to travel to get to the appropriate destination. once the nodeWalker
// has reached its final stop, the while loop exits into the statements below to insert the new node of data
if (iNodeData.compareTo(parentNode.nodeData) < 0)
parentNode.leftChild = new BinaryNode(iNodeData);
System.out.println("INSERT NODE: PARENT NODE LEFT CHILD");
else
parentNode.rightChild = new BinaryNode(iNodeData);
System.out.println("INSERT NODE: PARENT NODE RIGHT CHILD");
return parentNode;
public BinaryNode findNode(Comparable searchNode, BinaryNode bn)
if (bn == null)
return null;
else
while (bn != null)
if (searchNode.compareTo(bn.nodeData) < 0)
bn = bn.leftChild;
//System.out.println("FIND NODE: LEFT CHILD DETECTED");
else if (searchNode.compareTo(bn.nodeData) > 0)
bn = bn.rightChild;
//System.out.println("FIND NODE: RIGHT CHILD DETECTED");
else // word has been spotted in the tree!
System.out.println(bn.nodeData);
return bn;
return null;
public void preOrderTraversal(BinaryNode bn)
if (bn == null)
return;
System.out.println(bn.nodeData);
preOrderTraversal(bn.leftChild);
preOrderTraversal(bn.rightChild);
public void inOrderTraversal(BinaryNode bn)
if (bn == null)
return;
inOrderTraversal(bn.leftChild);
System.out.println(bn.nodeData);
inOrderTraversal(bn.rightChild);
// and then the code after this is the public static void main code, which I posted snippets of above. -
I want to Search for a file within a directory
how can i access a directory and search for a folder name in that directory
Hi,
SQL> set serveroutput on
SQL>
SQL> Declare
2 l_conn UTL_TCP.connection;
3 l_list ftp.t_string_table;
4 Begin
5 DBMS_OUTPUT.disable;
6
7 l_conn := ftp.login( '172.21.15.15'
8 , '21'
9 , 'test'
10 , 'test123' );
11
12 ftp.list( p_conn => l_conn
13 , p_dir => ''
14 , p_list => l_list );
15
16 ftp.logout(l_conn);
17
18 utl_tcp.close_all_connections;
19
20 DBMS_OUTPUT.Enable;
21
22 If l_list.Count > 0 Then
23 For i IN 3 .. l_list.Last Loop
24 DBMS_OUTPUT.put_line(Trim(substr(l_list(i),instr(l_list(i),' ',-1))));
25 End Loop;
26 End If;
27 End;
28 /
files1
files10
files11
files2
files3
files4
files5
files6
files7
files8
files9
PL/SQL procedure successfully completedhttp://www.oracle-base.com/articles/misc/FTPFromPLSQL.php
http://www.oracle-base.com/dba/miscellaneous/ftp.pks
http://www.oracle-base.com/dba/miscellaneous/ftp.pkb
Or Chris Poole's XUTL_FTP package:
http://www.chrispoole.co.uk/apps/xutlftp.htm
or with DBMS_BACKUP_RESTORE
SQL> -- How to Install
SQL> -- .../RDBMS/ADMIN/dbmsbkrs.sql
SQL> -- .../RDBMS/ADMIN/prvtbkrs.plb
SQL> -- .../RDBMS/ADMIN/catproc.sql
SQL>
SQL> Set Serveroutput on;
SQL> Create or replace directory DIR_TEMP as 'c:\temp';
Directory created
SQL> Create OR Replace Procedure list_directory(directory Varchar2) Is
2 ns Varchar2(1024);
3 v_directory Varchar2(1024);
4 Begin
5 v_directory := directory;
6 DBMS_BACKUP_RESTORE.SEARCHFILES( v_directory
7 , ns );
8 For each_file IN (SELECT fname_krbmsft As Name
9 FROM x$krbmsft) Loop
10 DBMS_OUTPUT.PUT_LINE(each_file.Name);
11 End Loop;
12 End;
13 /
Procedure created
SQL> begin
2 list_directory('c:\temp');
3 end;
4 /
C:\Temp\prvtbcnf.plb
C:\Temp\something.txt
PL/SQL procedure successfully completedRegards,
Christian Balz -
Searching for numeric values in a text field / SQL Server
Hi all,
here's a problem that I've been trying to solve for several days: I try to select rows from an MS SQL Server via JDBC that contain a certain numeric value at a certain position in a long varchar field.
I'm using queries like
select * from table where substring(field_1, 37, 7) like '1011234';Those queries always return an empty ResultSet. If I use the same queries in WinSQL, I get correct results (several rows).
The application code is working in principle; if I search for a text instead of a numeric value, for example select * from table where substring(field_1, 4, 5) like 'Paper'; , I get a complete ResultSet.
I've tried many variations (= instead of like, search in the entire field (without substring but with like '%1011234%'), with or without ', and more), but that didn't change anything.
It's also most probably not caused by the JDBC driver; I have tried JTDS first, and then the MS driver (newest versions) - no difference.
One idea was that the sort order is not correct, tried some COLLATE settings, but that didn't help so far. In this context I'd like to know how to determine the collation sequence of a certain column.
Another thing I tried was using CAST, for example SELECT * FROM table WHERE CAST(SUBSTRING(field_1, 37, 7) as bigint) = CAST('1011234' as bigint); or SELECT * FROM table WHERE CAST(SUBSTRING(field_1, 37, 7) as bigint) = CAST(1011234 as bigint);, but that didn't help either.
Some facts:
Server: Microsoft SQL Server, version 09.00.2047
Driver in WinSQL: SQLSRV32.DLL, version 03.85.1117
JDBC-Driver:
- JTDS, version 1.2
- Microsoft SQL Server 2005 JDBC Driver, Version 1.2
JVM: jre1.5.0_11
I didn't find anything on Google, or in this forum, or other forums. I really hope someone here can help me. Thanks in advance!
Best regards,
UicaYour note suggests to me that this is a coding problem, not a JDBC or SQL problem unless you are hitting a bug in the SQL Server JDBC driver. Others may have ideas from what you have written, but I think it would be helpful to see the actual code that you are executing that does not bring back the results that you are expecting (don't forgot to use code tags to format your code correctly).
It might also be helpful to execute a query (from within your Java code) to ensure that you are connecting to the right database, accessing the correct table and that your substring is using the correct offset. The query would look something like this (and then of course display the list of results):
SELECT substring(field_1, 37, 7) from table -
I have a sentence... and a word array..
sentence[0] = "The Sun is the star at the center of the Solar System"
words_array[] = { "center"};
i am searching the sentence for the word center....
if it founds return that word "center"...
I attahced sample code ...
here I used count becoz sometimes i may search for more than one word... so that it can store both the words...
finally i need to search the sentence for an array of words and if any one of the word is found in that sentece return that word...found...
static String words[]=new String [10000];
String found = null;
id=0;
StringTokenizer st=new StringTokenizer(base);
tokenCount= st.countTokens();
while (st.hasMoreTokens())
words[id]=st.nextToken();
if(words[id].contentEquals(words_array0]))
count++;
found =words[id].substring(0, words[id].length());
feature[count]=found ;
I don't see that code producing any output.
You'd probably get a lot better help if you:
1) wrote like an adult. "Because" not "becoz". Use capital letters where appropriate.
2) Expressed more clearly exactly what your code is supposed to do.
3) Expressed more clearly what it's doing instead.
4) Created a small, self-contained, compilable example that expresses the issue. Your example code has lots of references to things that aren't present.
In any event, I'll note that you never increment id. So you create this big words array but only ever use the first element.
Also, you're using .substring() to copy a string, which is entirely pointless as Strings are immutable. -
Searching for the number in the bigint value...
HI!
Could anybody help me with the searching for the number in the bigint value. ex:
9567423742840 i need to get only the 2nd and 3rd number (56) from this value...
^^
and the same thing with symbols in the strings..
is there any special function in jsp available for that?
thankstry looking into the String class. There should be a substring or similar function that lets u get only a part of another string. You can convert the int into a string by doing something like new Integer(yourIntValue).toString() and then using that string for your substring function. There may be other ways to do it too, but this is the one I remember off the top of my head.
Hope it helps
package com.DJ_Java;
Maybe you are looking for
-
IPhone 4S Has No Sound Recording Videos
This just started happening 2 days ago. When making a video/vine, you can't hear any audio playback. All I get is a hissing noise. But if I hold the phone up really close to my hear, I can kind of hear my voice/music/whatever I was recording. Also, i
-
Help my iMessage isn't working because my email is only showing as my thing to where people can contact me instead of my number. I'm new to the whole iphone team and I really need help. I tried the whole going into settings and selected my phone numb
-
Despite checking the "Do not import suspected duplicates"box, Lr4 still did re-import hundreds of photos from the same exact card they were imported from originally. Anyone know what I should do differently next time?
-
WMV File is not opening on MacBook
I bought a movie online yesterday for $19.99 and it downloaded in WMV format. I though it would work in WMV format since I have Flip4Mac, but it doesn't open. Every time I try to open it it says "The Application attempted to use an unsupported featur
-
Disp+work.exe = j2ee status info unavailable
Dear all, i have a problem during installing the ECC6. the box has 2 instances which the development is working fine, now the problem occour during installing the test instance. it stop at "start java enginee". i have compared the sid\dvebmgs00\j2ee