Need help in handling string of characters

Hi,
I am trying to scan string and separate different text based on business logic. For example:
String = 'My bus comes at 999 F Street at 8 am'
Now I need to scan the string and break the sentence into multiple words like:
- First occurrence of number which is 999 goes into var1 variable.
- Last occurrence of number which is 8 goes into var2 variable.
I am wondering if this can be achieve with regular expression of any oracle internal function.
Thanks,
Edited by: skas on Jun 6, 2013 10:34 PM

nkvkashyap wrote:
or you can even try like this...
with data(str) as
(select 'My bus comes at 999 F Street at 8 am' from dual),
data1 as
(select regexp_replace(str, '[^[:digit:]]+', ' ') a from data)
select regexp_substr(a,'[^ ]+',1,1) var1,regexp_substr(a,'[^ ]+',1,2) var2 from data1;
Output:
var1         var2
999     8
No need to make this complicated ;)
SQL> with data(str) as
  2  (
  3   select 'My bus comes at 999 F Street at 8 am'
  4   from dual
  5  )
  6  select     regexp_sUBsTR(str, '\d+') VAR1,
  7     regexp_sUBSTR(str, '\d+',1,2) VAR2
  8  from data;
VAR V
999 8Edited by: jeneesh on Jun 7, 2013 11:11 AM
Missed David's post.. This is the same as his post..

Similar Messages

  • Need help in the String Format method

    really need help in string.Format method. I would like to show the s in two digit numbers.
    for example:
    if s is below 10 then display *0s*
    the expecting result is 01,02,03.. 09,10,11....
    I tried this method, somehow i got the errors msg. pls advise. thx.
    public void setDisplay(String s) {
    String tmpSS=String.format("%02d",s);
    this.ss.setText(tmpSS);
    Edited by: bluesailormoon on May 19, 2008 10:30 AM

    Apparently, you expect the string to consist of one or two digits. If that's true, you could do this:String tmpSS = (s.length() == 1) ? ("0" + s) : s; or this: String tmpSS = String.format("%02d", Integer.parseInt(s));

  • Need help in removing non printable characters

    hi
    I am having an issue with non printable characters in webservice. This webservice dishes out xml in B2B communication to my clients programs. Due to data corruption in oracle (dont know who is creating bad data ) I am having non printable characters in the xml file which is generated from database. I am dishing out this to our customers. since the data in updated every day it is imposible to fix the data every time. I need to write a very very effficient method to strip non printable characters from strings from the xml. Can some one Please help on this one. I want to make sure this method is very efficient because this method could be potentially be called lots of times. I am using JDK 1.3.1 and oracle 8i
    Any help will be appreciated
    Thanks
    Ashok Pappu

    At some point you existing program is probably converting from String data to the XML bytes through a CharsetEncoder, probably inside a java.io.Writer.
    Perhaps your best approach might be to write your own java.nio.charset.CharsetEncoder which deals with the bad characters as you see fit.
    You can register a new java.nio.charset.CharSet as a private character set type. Because this should result in simply replacing a standard CharsetEncoder with a non-standard one hopefully the overheads would be low.

  • Need Help with a String Binary Tree

    Hi, I need the code to build a binary tree with string values as the nodes....i also need the code to insert, find, delete, print the nodes in the binarry tree
    plssss... someone pls help me on this
    here is my code now:
    // TreeApp.java
    // demonstrates binary tree
    // to run this program: C>java TreeApp
    import java.io.*; // for I/O
    import java.util.*; // for Stack class
    import java.lang.Integer; // for parseInt()
    class Node
         //public int iData; // data item (key)
         public String iData;
         public double dData; // data item
         public Node leftChild; // this node's left child
         public Node rightChild; // this node's right child
         public void displayNode() // display ourself
              System.out.print('{');
              System.out.print(iData);
              System.out.print(", ");
              System.out.print(dData);
              System.out.print("} ");
    } // end class Node
    class Tree
         private Node root; // first node of tree
         public Tree() // constructor
         { root = null; } // no nodes in tree yet
         public Node find(int key) // find node with given key
         {                           // (assumes non-empty tree)
              Node current = root; // start at root
              while(current.iData != key) // while no match,
                   if(key < current.iData) // go left?
                        current = current.leftChild;
                   else // or go right?
                        current = current.rightChild;
                   if(current == null) // if no child,
                        return null; // didn't find it
              return current; // found it
         } // end find()
         public Node recfind(int key, Node cur)
              if (cur == null) return null;
              else if (key < cur.iData) return(recfind(key, cur.leftChild));
              else if (key > cur.iData) return (recfind(key, cur.rightChild));
              else return(cur);
         public Node find2(int key)
              return recfind(key, root);
    public void insert(int id, double dd)
    Node newNode = new Node(); // make new node
    newNode.iData = id; // insert data
    newNode.dData = dd;
    if(root==null) // no node in root
    root = newNode;
    else // root occupied
    Node current = root; // start at root
    Node parent;
    while(true) // (exits internally)
    parent = current;
    if(id < current.iData) // go left?
    current = current.leftChild;
    if(current == null) // if end of the line,
    {                 // insert on left
    parent.leftChild = newNode;
    return;
    } // end if go left
    else // or go right?
    current = current.rightChild;
    if(current == null) // if end of the line
    {                 // insert on right
    parent.rightChild = newNode;
    return;
    } // end else go right
    } // end while
    } // end else not root
    } // end insert()
    public void insert(String id, double dd)
         Node newNode = new Node(); // make new node
         newNode.iData = id; // insert data
         newNode.dData = dd;
         if(root==null) // no node in root
              root = newNode;
         else // root occupied
              Node current = root; // start at root
              Node parent;
              while(true) // (exits internally)
                   parent = current;
                   //if(id < current.iData) // go left?
                   if(id.compareTo(current.iData)>0)
                        current = current.leftChild;
                        if(current == null) // if end of the line,
                        {                 // insert on left
                             parent.leftChild = newNode;
                             return;
                   } // end if go left
                   else // or go right?
                        current = current.rightChild;
                        if(current == null) // if end of the line
                        {                 // insert on right
                             parent.rightChild = newNode;
                             return;
                   } // end else go right
              } // end while
         } // end else not root
    } // end insert()
         public Node betterinsert(int id, double dd)
              // No duplicates allowed
              Node return_val = null;
              if(root==null) {       // no node in root
                   Node newNode = new Node(); // make new node
                   newNode.iData = id; // insert data
                   newNode.dData = dd;
                   root = newNode;
                   return_val = root;
              else // root occupied
                   Node current = root; // start at root
                   Node parent;
                   while(current != null)
                        parent = current;
                        if(id < current.iData) // go left?
                             current = current.leftChild;
                             if(current == null) // if end of the line,
                             {                 // insert on left
                                  Node newNode = new Node(); // make new node
                                  newNode.iData = id; // insert data
                                  newNode.dData = dd;
                                  return_val = newNode;
                                  parent.leftChild = newNode;
                        } // end if go left
                        else if (id > current.iData) // or go right?
                             current = current.rightChild;
                             if(current == null) // if end of the line
                             {                 // insert on right
                                  Node newNode = new Node(); // make new node
                                  newNode.iData = id; // insert data
                                  newNode.dData = dd;
                                  return_val = newNode;
                                  parent.rightChild = newNode;
                        } // end else go right
                        else current = null; // duplicate found
                   } // end while
              } // end else not root
              return return_val;
         } // end insert()
         public boolean delete(int key) // delete node with given key
              if (root == null) return false;
              Node current = root;
              Node parent = root;
              boolean isLeftChild = true;
              while(current.iData != key) // search for node
                   parent = current;
                   if(key < current.iData) // go left?
                        isLeftChild = true;
                        current = current.leftChild;
                   else // or go right?
                        isLeftChild = false;
                        current = current.rightChild;
                   if(current == null)
                        return false; // didn't find it
              } // end while
              // found node to delete
              // if no children, simply delete it
              if(current.leftChild==null &&
                   current.rightChild==null)
                   if(current == root) // if root,
                        root = null; // tree is empty
                   else if(isLeftChild)
                        parent.leftChild = null; // disconnect
                   else // from parent
                        parent.rightChild = null;
              // if no right child, replace with left subtree
              else if(current.rightChild==null)
                   if(current == root)
                        root = current.leftChild;
                   else if(isLeftChild)
                        parent.leftChild = current.leftChild;
                   else
                        parent.rightChild = current.leftChild;
              // if no left child, replace with right subtree
              else if(current.leftChild==null)
                   if(current == root)
                        root = current.rightChild;
                   else if(isLeftChild)
                        parent.leftChild = current.rightChild;
                   else
                        parent.rightChild = current.rightChild;
                   else // two children, so replace with inorder successor
                        // get successor of node to delete (current)
                        Node successor = getSuccessor(current);
                        // connect parent of current to successor instead
                        if(current == root)
                             root = successor;
                        else if(isLeftChild)
                             parent.leftChild = successor;
                        else
                             parent.rightChild = successor;
                        // connect successor to current's left child
                        successor.leftChild = current.leftChild;
                        // successor.rightChild = current.rightChild; done in getSucessor
                   } // end else two children
              return true;
         } // end delete()
         // returns node with next-highest value after delNode
         // goes to right child, then right child's left descendents
         private Node getSuccessor(Node delNode)
              Node successorParent = delNode;
              Node successor = delNode;
              Node current = delNode.rightChild; // go to right child
              while(current != null) // until no more
              {                                 // left children,
                   successorParent = successor;
                   successor = current;
                   current = current.leftChild; // go to left child
              // if successor not
              if(successor != delNode.rightChild) // right child,
              {                                 // make connections
                   successorParent.leftChild = successor.rightChild;
                   successor.rightChild = delNode.rightChild;
              return successor;
         public void traverse(int traverseType)
              switch(traverseType)
              case 1: System.out.print("\nPreorder traversal: ");
                   preOrder(root);
                   break;
              case 2: System.out.print("\nInorder traversal: ");
                   inOrder(root);
                   break;
              case 3: System.out.print("\nPostorder traversal: ");
                   postOrder(root);
                   break;
              System.out.println();
         private void preOrder(Node localRoot)
              if(localRoot != null)
                   localRoot.displayNode();
                   preOrder(localRoot.leftChild);
                   preOrder(localRoot.rightChild);
         private void inOrder(Node localRoot)
              if(localRoot != null)
                   inOrder(localRoot.leftChild);
                   localRoot.displayNode();
                   inOrder(localRoot.rightChild);
         private void postOrder(Node localRoot)
              if(localRoot != null)
                   postOrder(localRoot.leftChild);
                   postOrder(localRoot.rightChild);
                   localRoot.displayNode();
         public void displayTree()
              Stack globalStack = new Stack();
              globalStack.push(root);
              int nBlanks = 32;
              boolean isRowEmpty = false;
              System.out.println(
              while(isRowEmpty==false)
                   Stack localStack = new Stack();
                   isRowEmpty = true;
                   for(int j=0; j<nBlanks; j++)
                        System.out.print(' ');
                   while(globalStack.isEmpty()==false)
                        Node temp = (Node)globalStack.pop();
                        if(temp != null)
                             System.out.print(temp.iData);
                             localStack.push(temp.leftChild);
                             localStack.push(temp.rightChild);
                             if(temp.leftChild != null ||
                                  temp.rightChild != null)
                                  isRowEmpty = false;
                        else
                             System.out.print("--");
                             localStack.push(null);
                             localStack.push(null);
                        for(int j=0; j<nBlanks*2-2; j++)
                             System.out.print(' ');
                   } // end while globalStack not empty
                   System.out.println();
                   nBlanks /= 2;
                   while(localStack.isEmpty()==false)
                        globalStack.push( localStack.pop() );
              } // end while isRowEmpty is false
              System.out.println(
         } // end displayTree()
    } // end class Tree
    class TreeApp
         public static void main(String[] args) throws IOException
              int value;
              double val1;
              String Line,Term;
              BufferedReader input;
              input = new BufferedReader (new FileReader ("one.txt"));
              Tree theTree = new Tree();
         val1=0.1;
         while ((Line = input.readLine()) != null)
              Term=Line;
              //val1=Integer.parseInt{Term};
              val1=val1+1;
              //theTree.insert(Line, val1+0.1);
              val1++;
              System.out.println(Line);
              System.out.println(val1);          
    theTree.insert(50, 1.5);
    theTree.insert(25, 1.2);
    theTree.insert(75, 1.7);
    theTree.insert(12, 1.5);
    theTree.insert(37, 1.2);
    theTree.insert(43, 1.7);
    theTree.insert(30, 1.5);
    theTree.insert(33, 1.2);
    theTree.insert(87, 1.7);
    theTree.insert(93, 1.5);
    theTree.insert(97, 1.5);
              theTree.insert(50, 1.5);
              theTree.insert(25, 1.2);
              theTree.insert(75, 1.7);
              theTree.insert(12, 1.5);
              theTree.insert(37, 1.2);
              theTree.insert(43, 1.7);
              theTree.insert(30, 1.5);
              theTree.insert(33, 1.2);
              theTree.insert(87, 1.7);
              theTree.insert(93, 1.5);
              theTree.insert(97, 1.5);
              while(true)
                   putText("Enter first letter of ");
                   putText("show, insert, find, delete, or traverse: ");
                   int choice = getChar();
                   switch(choice)
                   case 's':
                        theTree.displayTree();
                        break;
                   case 'i':
                        putText("Enter value to insert: ");
                        value = getInt();
                        theTree.insert(value, value + 0.9);
                        break;
                   case 'f':
                        putText("Enter value to find: ");
                        value = getInt();
                        Node found = theTree.find(value);
                        if(found != null)
                             putText("Found: ");
                             found.displayNode();
                             putText("\n");
                        else
                             putText("Could not find " + value + '\n');
                        break;
                   case 'd':
                        putText("Enter value to delete: ");
                        value = getInt();
                        boolean didDelete = theTree.delete(value);
                        if(didDelete)
                             putText("Deleted " + value + '\n');
                        else
                             putText("Could not delete " + value + '\n');
                        break;
                   case 't':
                        putText("Enter type 1, 2 or 3: ");
                        value = getInt();
                        theTree.traverse(value);
                        break;
                   default:
                        putText("Invalid entry\n");
                   } // end switch
              } // end while
         } // end main()
         public static void putText(String s)
              System.out.print(s);
              System.out.flush();
         public static String getString() throws IOException
              InputStreamReader isr = new InputStreamReader(System.in);
              BufferedReader br = new BufferedReader(isr);
              String s = br.readLine();
              return s;
         public static char getChar() throws IOException
              String s = getString();
              return s.charAt(0);
         public static int getInt() throws IOException
              String s = getString();
              return Integer.parseInt(s);
    } // end class TreeApp

    String str = "Hello";
              int index = 0, len = 0;
              len = str.length();
              while(index < len) {
                   System.out.println(str.charAt(index));
                   index++;
              }

  • Still Need Help with this String Problem

    basically, i need to create a program where I input 5 words and then the program outputs the number of unique words and the words themselves. for example, if i input the word hello 5 times, then the output is 1 unique word and the word "hello". i have been agonizing over this dumb problem for days, i know how to do it using hashmap, but this is an introductory course and we cannot use more complex java functions, does ANYONE know how to do this just using arrays, strings, for loops, if clauses, etc. really basic java stuff. i want the code to be able to do what the following program does:
    import java.io.*; import java.util.ArrayList;
        public class MoreUnique {
           public static void main(String[] args) throws IOException{ BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); String str[] = new String[5]; int uniqueEntries = 0; ArrayList<String> ue = new ArrayList<String>();
             for (int i = 0; i < 5; i++) { System.out.print((i +1) + ": "); str[i] = br.readLine(); }
             for (int j = 0; j < 5; j++) {
                if (!ue.contains(str[j].toLowerCase())) { ue.add(str[j].toLowerCase()); } } uniqueEntries = ue.size(); System.out.print("Number of unique entries: " + uniqueEntries + " { ");
             for (int q = 0; q < ue.size(); q++ ) { System.out.print(ue.get(q) + " "); } System.out.println("}"); } } but i need to find how to do it so all 5 words are put in at once on one line, and without all the advanced java functions that are in here, can anyone help out?

    you have to compare string 0 to strings 1-4, then
    string 1 with strings 2-4, then string 2 with strings
    3 and 4 then string 3 with string 4....right???Here's a way to do it:
    public class MoreUnique {
        public static void main(String[] args) throws IOException {
            BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
            final int NUM_WORDS = 5;
            String[] words = new String[NUM_WORDS];
            int uniqueEntries = 0;
            for(int i = 0; i < NUM_WORDS; i++) {
                System.out.print((i+1)+": ");
                String temp = br.readLine();
                if(!contains(temp, words)) {
                    words[uniqueEntries++] = temp;
            System.out.print("Number of unique entries: "+uniqueEntries+" { ");   
            for (int i = 0; i < uniqueEntries; i++ ) {   
                System.out.print(words[i]+" ");
            System.out.println("}");
        private static boolean contains(String word, String[] array) {
                 Your code here: just a simple for-statement to
                 loop through your array and to see if 'word'
                 is in your 'array'.
    }Try to fill in the blanks.
    Good luck.

  • Need help for Java Strings

    Hi ppl,
    i hav a code which has to do some actions on the strings retrieved from the database. The code is in java swings
    I need to know, how do i check if there is a space between strings.
    For eg Kevin Dcosta. (There is a space between Kevin Dcosta)
    Please can someone provide me with the Java code for the same so tat i can append to my code. Or is there any readymade method in Java for the same??
    Thanks
    Divya..

    Hi,
    Go thr StringTokenizer Class it will help u out!........place whatever string u r reading in pu those in stringtokenizer like
    StringTokenizer str=new StringTokenizer(tmpmessage, " ");
    while(readTokenizer.hasMoreTokens())
    String name=readTokenizer.nextToken();
    /****** do whatever the action u want to do*************8
    }

  • Need help to handle java FX stuffs...........??

    i am very much new to Java FX i want to do a login acceptance and rejection operation.like ::
    client will click on the button it will open up the window of created by java FX which will give the login screen*(in this case i would like to mention one thing i all ready have a page like usercheck.jsp which is checking if the user is already loged in or not so need to call this JAVA FX window from that page.)*.This java FX window should have a text field and a password field to match with database.it will show a progressber while it is matching the user name password with database.If the login is correct it will give the user the session stuff and allow him to access**(ie.it will be forworded to the page say,cart.jsp)** otherwise it will give a alert message "login faild".any idea about it..............what should i do now???my database is in access and it connected to my program by DA.java.please guide me what should i do,step by step?and consulting with [http://jfx.wikia.com/wiki/SwingComponents]
    now guide me.............
    i have just created a swing button say "click me to login" on a UNDECORATED window............so what next.........
    Edited by: coolsayan.2009 on May 7, 2009 3:35 PM

    my DA.java is like::
    package shop;
    import java.sql.*;
    public class DAClass {
         private static Connection conn;
         private static ResultSet rs;
         private static PreparedStatement ps;
         public static void connect(String dsn, String un, String pwd) {
              try {
                   //access
                   Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
                   conn=DriverManager.getConnection("jdbc:odbc:"+dsn,un,pwd);
              catch(Exception e) {
         public static boolean chkPwd(String un, String pwd) {
              try {
                   boolean b=false;
                   ps=conn.prepareStatement("select * from cust_info where cust_name=? and cust_pwd=?");               
                   ps.setString(1,un);
                   ps.setString(2,pwd);
                   rs=ps.executeQuery();
                   while(rs.next()) {
                        b=true;
                   return b;
              catch(Exception e) {
                   return false;
         public static ResultSet getCat(){
              try {
                   ps=conn.prepareStatement("select * from item_category where cat_parent=0 order by cat_name");               
                   rs=ps.executeQuery();
                   return rs;
              catch(Exception e) {
                   return null;
         public static ResultSet getSubCat(int cat_id){
              try {
                   ps=conn.prepareStatement("select * from item_category where cat_parent=? order by cat_name");               
                   ps.setInt(1,cat_id);
                   rs=ps.executeQuery();
                   return rs;
              catch(Exception e) {
                   return null;
         public static ResultSet getItems(int cat_id){
              try {
                   ps=conn.prepareStatement("select * from item_info where cat_id=? order by title");               
                   ps.setInt(1,cat_id);
                   rs=ps.executeQuery();
                   return rs;
              catch(Exception e) {
                   return null;
         public static boolean insertOd(int order_id,String cust_id, String dt, String st, double amt,String pro)
              try{
                   ps=conn.prepareStatement("insert into cust_order values (?,?,?,?,?,?)");
                   ps.setInt(1,order_id);
                   ps.setString(2,cust_id);
                   ps.setString(3,dt);
                   ps.setString(4,st);
                   ps.setDouble(5,amt);
                   ps.setString(6,pro);
                   ps.executeUpdate();
                   return true;
                   catch(Exception e)
                        return false;
         public static boolean draft_det(int order_id,String bank_name,String draft_no,String draft_date,String branch,double amount)
              try{
                   ps=conn.prepareStatement("insert into draft_det values (?,?,?,?,?,?)");
                   ps.setInt(1,order_id);
                   ps.setString(2,bank_name);
                   ps.setString(3,draft_no);
                   ps.setString(4,draft_date);
                   ps.setString(5,branch);
                  ps.setDouble(6,amount);
                   ps.executeUpdate();
                   return true;
                   catch(Exception e)
                        return false;
         public static int getOrderId()
              try{
                   int id=0;
                   ps=conn.prepareStatement("select Max(order_id) from cust_order");
                   rs=ps.executeQuery();
                   while(rs.next()){
                        id= rs.getInt(1);
                   return id;
              catch(Exception e)
                   return 0;
    public static boolean credit_det(int order_id,String credit_no,String credit_type,String pin_no)
              try{
                   ps=conn.prepareStatement("insert into credit_det values (?,?,?,?)");
                   ps.setInt(1,order_id);
                   ps.setString(2,credit_no);
                   ps.setString(3,credit_type);
                   ps.setString(4,pin_no);
                   ps.executeUpdate();
                   return true;
                   catch(Exception e)
                        return false;
         public static boolean detailOrder(int order_id,int item_id,int item_number,double item_price)
              try{
                   ps=conn.prepareStatement("insert into order_det values (?,?,?,?)");
                   ps.setInt(1,order_id);
                   ps.setInt(2,item_id);
                   ps.setInt(3,item_number);
                   ps.setDouble(4,item_price);
                   ps.executeUpdate();
                   return true;
                   catch(Exception e)
                        return false;
         public static UserInfo getUserDet(String un) {
              try {
                   ps=conn.prepareStatement("select * from cust_info where cust_name=?");
                   ps.setString(1,un);
                   rs=ps.executeQuery();
                   UserInfo user=null;
                   while(rs.next()) {
                        String uname=rs.getString(1);
                        String pass=rs.getString(2);
                        String fname=rs.getString(3);
                        String lname=rs.getString(4);
                        String addr=rs.getString(5);
                        String city=rs.getString(6);
                        String state=rs.getString(7);
                        String country=rs.getString(8);
                        String contact=rs.getString(9);
                        String question=rs.getString(10);
                        String answer=rs.getString(11);
                        String email=rs.getString(12);
                        String mobile=rs.getString(13);
                        user=new UserInfo(0,fname,lname,addr,city,state,country,contact,question,answer,email,mobile,uname,pass);
                        return user;
              catch(Exception e) {
                   return null;
         public static boolean userInsert(String fname,String lname,String addr,String city,String state,String country,String contact,String question,String answer,String email,String mobile,String uname,String pass ){
              try{
                   ps=conn.prepareStatement("insert into cust_info  values (?,?,?,?,?,?,?,?,?,?,?,?,?)");
                   ps.setString(1,uname);
                   ps.setString(2,pass);
                   ps.setString(3,fname);
                   ps.setString(4,lname);
                   ps.setString(5,addr);
                   ps.setString(6,city);
                   ps.setString(7,state);
                   ps.setString(8,country);
                   ps.setString(9,contact);
                   ps.setString(10,question);
                   ps.setString(11,answer);
                   ps.setString(12,email);     
                   ps.setString(13,mobile);
                   ps.executeUpdate();     
                   return true;               
              catch(Exception e)
                   return false;
         public static boolean chackuname(String un) {
              try {
                   boolean b=false;
                   ps=conn.prepareStatement("select * from cust_info where cust_name=?");
                   ps.setString(1,un);
                   rs=ps.executeQuery();
                   while(rs.next()) {
                        b=true;
                   return b;               
              catch(Exception e) {
                   return false;
         public static boolean adminChk(String un,String pass){
         try{
              boolean b=false;
              ps=conn.prepareStatement("select * from admin where username=? and password=?");
                   ps.setString(1,un);
                   ps.setString(2,pass);
                   rs=ps.executeQuery();
                   while(rs.next())
                        b=true;
                   return b;
         catch(Exception e){
              return false;
         public static String getStatus(int cust_id)
              try{
                   String status=null;
                   ps=conn.prepareStatement("select order_status from cust_order where cust_id=?");
                   ps.setInt(1,cust_id);
                   rs=ps.executeQuery();
                   while(rs.next()){
                        status= rs.getString(1);
                   return status;
              catch(Exception e)
                   return null;
         public static boolean chkCatagory(String cat)
              boolean b=false;
              try{
                   ps=conn.prepareStatement("select * from item_category where cat_name=? ");
                   ps.setString(1,cat);
                   rs=ps.executeQuery();
                   while(rs.next())
                        b=true;
                   return b;     
              catch(Exception e)
                   return false;
         public static int getMaxCatId(){
              try{
                   int id=0;
                   ps=conn.prepareStatement("select MAX(cat_id) from item_category");
                   rs=ps.executeQuery();
                   while(rs.next())
                        id=rs.getInt(1);
                   return id;     
              catch(Exception e)
                   return -1;
         public static boolean catInsert(int catId, String cat, int par)
              boolean flag=false;
              try{
                        ps=conn.prepareStatement("insert into item_category values(?,?,?)");
                        ps.setInt(1,catId);
                        ps.setString(2,cat);
                        ps.setInt(3,par);
                        ps.executeUpdate();
                        flag=true;
                        return flag;
              catch(Exception e)
                   return false;

  • Need help in SQL strings

    Team,
    I have a requirement in my project where I need to take out a sub string from the main string and store in other column.
    for example,
    I have a table with 2 columns and table has more then 500 records.
    1st column has the values like follows
    'High Pressure  0.5 in'
    'Wafer  0.3 in'
    'Sanitary  3.0 in'
    '8721 Hygienic  1.0 in'
    My requirement is, I need to takeout inches part and store in 2nd column.
    my 2nd column should contain values like 0.5, 0.3, 0.3, 1.0
    Thanks in advance,
    Rak

    If you always have a decimal point and a fixed length for the inches:
    SQL>
    SQL> with t as (
      2  select 'High Pressure  0.5 in' str from dual union
      3  select 'Wafer  0.3 in' from dual union
      4  select 'Sanitary  3.0 in' from dual union
      5  select '8721 Hygienic  1.0 in' from dual
      6  )
      7  --
      8  --
      9  --
    10  select str
    11  ,      substr( str
    12               , instr(str, '.' ,1 )-1
    13               , instr(str, '.' ,1 )-instr(str, '.' ,1 )+3
    14               ) inch
    15  from   t;
    STR                   INCH
    8721 Hygienic  1.0 in 1.0
    High Pressure  0.5 in 0.5
    Sanitary  3.0 in      3.0
    Wafer  0.3 in         0.3
    4 rows selected.

  • Need help in converting string to numeric array

    I am trying to convert a string to a numeric array ... the first # in the string gets cut off, the last three seem to come through. 
    This may be fairly simple, but I really haven't worked with the string functions all that much.
    Help would be appreciated.
    Thanks,
    Attachments:
    String to Array Example.vi ‏10 KB

    Steve Chandler wrote:
    If you remove the first and last byte from the string using string subset then the read spreadsheet string would probably have worked.
    Yup.
    LabVIEW Champion . Do more with less code and in less time .
    Attachments:
    String to Array ExampleMOD2.vi ‏10 KB

  • Need help on search string in EBS

    Hi,
    We have a situation where multiple BAI transactions comes with same code, ex: 451 and based on the text in the note to payee they need to be posted to different clearing accounts.
    I did config taking advantage of search string and posting rule in tareget field (EBVGINT)
    For some reason getting an error message saying " Account symbol in account assignment not replaceable"
    For example of CITI in the note to payee, my config is like this :
    Created Account symbol CITI, Assigned GL account to account symbol CITI and account modifier as CITI too
    Created posting key as CITI and posting rules are posting rule CITI , 40 (debit) post to bank accounting (option 1) for account symbol CITI and 50 (credit) post to bank as account symbol with posting to bank accounting (option 1) document type SA.
    In the search string section, created a search string CITI with source (text from note to payee) and target as CITI (posting rule key)
    then this searchs tring has been assigned to the company code, house bank, no algorithm, target field as posting rule and no prefix.
    Can anybody explain me why i am getting the above error message based on this config ??
    Thanks in advance
    uma

    Hi Uma,
    The search string works this way:
    Step 1: You define a search string.  The search string should be a unique word or number or a combination which appears in the 88 record of the BAI statement. In the definition:
    a. you give a name for the search string
    b. a definition or long text
    c. the search string - the unique word you want the system to search for in the 88 record. Please note that the search string you enter here should appear exactly in the same way in your bank statement.
    d. you map this search string to a Posting rule or cost center or whatever you want to replace in the next step.
    Step 2. Here you tell the system how this mapped information (in (d) above) is to be used. The mapped information could be used as a posting rule, as cost center, as profit center or in any way you want if you define your own logic.
    The usage could be specific to a House bank, Account ID, Company code, BAI code combination or you can leave it as generic so that it will be used for all House Bank and Account ID in all company code.
    But I would advise you to keep it very specific otherwise the results would not be what you want to be.
    To answer your question: Also, do i need to add the entries in transaction type and assign them to the external transaction and posting rule ?
    It is not required. But if you have assigned a posting rule under the Transaction type, the configuration in search string will override it. So you really don't need the assignment of posting rule under transaction type,  but I would advise you to do it because if the system does not find your search string, then it will take this assignment as default.
    Hope I made myself clear.
    Kalyan

  • Need help with attributed string in NSMenuItem

    I'm trying to implement a contextual menu for a view in one of my applications. I want it to be dynamic, based on where you click in the view. It works fine if I don't try to mess with the font size of the menu. If I try to make the menu font smaller, the menu will appear blank, and its action won't get triggered, but only if there's only one menu item. If there are two or more, they'll all show up.
    I've done a bunch of searching, and found some code examples where they put in a dummy item, then remove it later, but so far, that hasn't helped me, either. I've posted an example project (~44KB) on my web site that illustrates this, if you'd like to see it in action (the example doesn't include the "dummy fix", by the way, but it's easy enough to add).
    Here's the code where I customize the menu:
    <pre class="command">-(NSMenu *)menuForEvent:(NSEvent *)theEvent
    NSPoint mouseLoc = [self convertPoint:[theEvent locationInWindow] fromView:nil];
    NSLog(@"Raw Mouse Location: %2.1f, %2.1f", mouseLoc.x, mouseLoc.y);
    // Get my blank menu:
    NSMenu *tzMenu = [self defaultMenu];
    // Set up my string attributes:
    NSMutableDictionary *menuAttributes = [[NSMutableDictionary alloc] init];
    [menuAttributes setObject:[NSFont fontWithName:@"Lucida Grande" size:11] forKey:NSFontAttributeName];
    if (mouseLoc.x < 220) // Make just one menu item.
    int i;
    for (i=0; i<1; i++)
    [tzMenu addItemWithTitle:@"Item" action:@selector(changeMapDot:) keyEquivalent:@""];
    NSMenuItem *lastItem = [tzMenu itemAtIndex:[tzMenu numberOfItems] - 1];
    NSAttributedString *attrString = [[NSAttributedString alloc] initWithString:@"Item" attributes:menuAttributes];
    // Comment out this next line and the menu item appears in the default font:
    [lastItem setAttributedTitle:attrString];
    [attrString release];
    else
    int i;
    for (i=0; i<3; i++) //Make three items. These always appear.
    [tzMenu addItemWithTitle:@"Item" action:@selector(changeMapDot:) keyEquivalent:@""];
    NSMenuItem *lastItem = [tzMenu itemAtIndex:[tzMenu numberOfItems] - 1];
    NSAttributedString *attrString = [[NSAttributedString alloc] initWithString:@"Item" attributes:menuAttributes];
    [lastItem setAttributedTitle:attrString];
    [attrString release];
    [menuAttributes release];
    return tzMenu;
    }</pre>Any tips that anyone has would be most apprecitated.
    I'm not unalterably opposed to the regular system menu font if there's no way around this (the menus are pretty short: usually less then a dozen items), but aesthetically it looks nicer with a smaller font.
    charlie

    Hi,
    You can use SUBSTR and INSTR
    This should work in Oracle 9:
    WITH     cntr     AS
         SELECT     LEVEL     AS n
         FROM     dual
         CONNECT BY     LEVEL <= 3
    ,     got_pos          AS
         SELECT     x.txt
         ,     c.n
         ,     INSTR (x.txt, '[', 1, c.n)     AS l_pos
         ,     INSTR (x.txt, ']', 1, c.n)     AS r_pos
         FROM           table_x  x
         CROSS JOIN    cntr     c
    SELECT        txt
    ,        n
    ,        SUBSTR ( txt
                   , l_pos + 1
                , r_pos - (l_pos + 1)
                   )     AS sub_txt
    FROM        got_pos
    ORDER BY   txt
    ,             n
    ;Sorry, I don't have an Oracle 9 database available now; I had to test this in Oracle 10.
    jimmy437 wrote:
    ... I have tried the "REGEXP_SUBSTR" but my database version is 9i, and it is available only from 10g.That's true. Regular expressions are very useful, but they're not available in Oracle 9 (or earlier).
    Oracle 9 does have an Oracle-supplied package, OWA_PATTERN, that provides some regular expression functionality:
    http://docs.oracle.com/cd/B12037_01/appdev.101/b10802/w_patt.htm
    I know that's the Oracle 10, documentation, but it exists in Oracle 9, too.
    Oracle 9 is very old. You should consider upgrading.

  • Need Help Parsing JSON String using PLJSON

    Hello,
    I have JSON stored in a database field:
    --Query
    select data1 from table1 where id= 339207152427;
    --Results:
    [{"name":"Home"},{"code":"JPNWC74ZKW9"},{"start date":"01\/02\/2014"},{"person name":"hhh, RamS"}]
    I need to parse the above results into 3 fields in a separate table. For now, i'm just trying to parse the results using PLJSON, but am getting the ORA-20101: JSON Parser exception - no { start found error when running the following pl/sql block:
    declare
    VIN_JSON varchar2(4000);
    jsonObj json;
    listOfValues json_list;
    listElement json_value;
    begin
    select data1 into VIN_JSON from table1 where id= 339207152427;
    jsonObj := new json(VIN_JSON);
    listOfValues := jsonObj.get_values();
    for i in 1..listOfValues.count loop
    listElement := listOfValues.get(i);
    end loop;
    end;
    I believe my syntax is close, but was hoping for some further instruction.
    Thanks in advance!
    John

    I have no idea what you are trying to do or in what version so help, at this point, is not possible.
    Let's start with this:
    I need to parse the above results into 3 fields in a separate tableAnd the parsing rules?
    And what the result should be?
    You apparently want us to guess. Which is something most of us do not like to do. (and don't forget your full version number if you want help).
    PS: This forum has a FAQ: I recommend you read it as you didn't even put your listing into tags.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

  • Need help in clearing string buffer during dynamic VO where clause in oaf

    Hi All,
    I am dynamically setting where clause in OAF using string buffer, but the issue is when i am executing the vo multiple times so the old data in the string buffer it is not clearing .so every time my where clause adding to the query and it is erroring out, please help me how to clear string buffer class in oaf.
    Thnaks

    Hi,
    Could you please share the code segment for reference. Then we can tell the solution.
    Regards,
    Tarun

  • Needed help regarding converting  string to java.sql.Date format

    I have a a function which returns a calendar object. The date must be inserted to Oracle DB using java.sql.Date format.
    So i have converted the Calendar object to java.sql.Date format using the following code
    java.sql.Date publicationDate = new java.sql.Date(book.getPublicationDate().getTime().getTime());But while getting inserted into the DB it was in mm/dd/yyyy format whereas i wanted dd/mm/yyyy format
    Can any body please help out how to store the date in dd/mm/yyyy format ?

    Can u please explain this a bit
    This is my code
    public int addBook(List<Book> BookList) throws SQLException, ParseException{
              System.out.println("Hi there");
              Book book = new Book();
              BookDB bookDb = new BookDB();
              //listLength =      BookList.length;
              String bookId = null;
                   try{
                        DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
                        con  = DriverManager.getConnection("jdbc:oracle:thin:@10.123.79.195:1521:findb01","e115314", "e115314");
                        addBook = con.prepareStatement("insert into ABC_Book values(?,?,?,?,?,?,?)");
                        Iterator<Book> iterator = BookList.iterator();
                        while(iterator.hasNext()){
                             book = (Book)iterator.next();
                             System.out.println(book.getBookId());
                             addBook.setString(1,book.getBookId());
                             addBook.setString(2,book.getTitle());
                             addBook.setString(3,book.getAuthor());
                             addBook.setString(4,book.getPublisher());
                             System.out.println(book.getPublicationDate());
                             System.out.println("Before Date");
                             System.out.println("book.getPublicationDate().getTime()"+book.getPublicationDate().getTime());
                             java.sql.Date publicationDate = new java.sql.Date(book.getPublicationDate().getTime().getTime());
                             SimpleDateFormat formatter = new SimpleDateFormat("dd/mm/yyyy");
                             dateString = formatter.format(publicationDate);
                             System.out.println("Today is"+dateString);
                             java.sql.Date date = (java.sql.Date)formatter.parse(dateString);
                             System.out.println("date"+date);
                             //java.sql.Date publicationDate = (Date)book.getPublicationDate().getTime();
                             //System.out.println("Value of date is"+publicationDate);
                             System.out.println("After Date");
                             addBook.setDate(5,publicationDate);
                             addBook.setString(6,book.getCountry());
                             addBook.setString(7,book.getLanguage());
                             rs = addBook.executeQuery();
                             //con.commit();
                             rowCount = rowCount + rs.getRow();
                        return rowCount;
                   catch(SQLException se){
                        se.printStackTrace();
                   finally{
                        con.close();
                        System.out.println("After adding ");
              return 0;
         }

  • Need help! Printer printing garbage characters and non stop until out of paper

    Hi,
    I have a computer lab that has 25 workstations. The workstations are installed with Adobe CS5 suite. Sometimes when trying to print Indesign files, the printer started to go haywire. It will print out garbage character and printing non stop until ran out of paper.
    Any help will be great. Thanks in advance.
    Network printer: HP colorjet CP4525
    OS: Win XP SP3
    Software: Indesign CS5

    There is no such thing as a Generic Adobe PostScript driver. What is posted on the adobe.com website is a driver installer that simply associates PPD files with the standards Windows PostScript driver that comes with Windows itself. That installer only works with versions of Windows up to and an including Windows XP 32-bit. It does not work with Windows Vista, Windows 7, Windows Server, or any 64-bit version of Windows.
    Also note that although the HP CP4525 “supports PostScript” it is not a printer with Adobe PostScript 3, but rather, CloneScript from a third party.
    Having said that and understanding that you are currently using a PCL6 driver, I would recommend the following:
    (1)     Try using the PCL5C driver for the printer. PCL6 and its drivers was always dodgy anyway.
    (2)     Turn off the printer's automatic page description language sensing. That feature attempts to guess as to whether PCL or PostScript is currently being sent to the device and switch language processors. It really isn't necessary because HP's drivers prepend the print job with information as to which page description language is being used.
    Given the unreliable nature of HP's emulation of PostScript, I would not recommend using any HP LaserJet's PostScript mode for any model of LaserJet in recent memory.
              - Dov

Maybe you are looking for

  • Unable to load Oracle XML SQL utility

    The following error appears for each java class, when we attempt to load Oracle XML sql utility into Oracle using the oraclexmlsqlload script: E.g. Error while resolving class OracleXMLStore ORA-00904: invalid column name Does anyone know why we woul

  • I can't open iTunes message says" can't read itunes library.itl because it was created with a newer version"

    I can't open iTunes message says" can't read itunes library.itl because it was created with a newer version"  thank you for any help!

  • Vista won't start after fresh install of LabVIEW & 4G RAM

    Since Vista is such a memory glutton I decided to upgrade my AMD64 box to 4 Gig RAM.  Good idea, no?  Turns out not.  Now Vista won't start.  It locks up at the (lack of) progress bar before the log-in screen.  After much hollerin' and hair pullin' I

  • 3rd party sat nav for e51

    i am looking for a 3rd party sat nav that is compatible with my e51, i understand that i need an external receiver but am not sure which one would be the best for my phone? ideally the mapping of the sat nav would be topographical as well as street m

  • Sorting xml document with xsl

    How can I sort below xml on empNo using xsl, I want an output to be in xml format. <employeeList> <employee empNo=1000> <Info > <fname></fname> <lname></lname> </Info> </employee> <employee empNo=1001> <Info > <fname></fname> <lname></lname> </Info>