Help with search within pl/sql code

Hi All,
Can you please help me to find all the objects with a database link.
I have some procedures,function and packages which uses database link. I need to fetch all the objects that uses a database link. Is there any way to get the list of object names using any database link?
Thanks in advance
Apppreciate your help!
Thanks
Bob

hi there,
the problem with dba_source is that the code might be wrapped.
another possibility is to query dba_dependencies, column referenced_link
Also you can have pl/sql routines that create dynamically code and might use dblinks in their dynamic code.
So you might not be able to be 100 percent complete.
HTH Mathias

Similar Messages

  • Please help with search function

    Heya, im currently working on code that will allow me to add, view, search and remove prisoners and wardens from a prison system. So far i have managed to allow the user to add and view. Im a bit stuck on the search part of the code, its a bit temperamental :S, sometimes it will find and display the data, but other times it will not and comes up with the error
    Exception in thread "main" java.lang.NullPointerException
    at Prison.getNum(Prison.java:128)
    at TestPrison.main(TestPrison.java:101)
    Below i have put my Prison and TestPrison Class files and highlighted the lines the compiler said had the error, any help would be really appreciated because i really cant work out wats going on.
    Prison
    public class Prison
    private Prisoner [] thePrisoner;
    private Warden [] theWarden;
    private HighPrisoner [] theHighPrisoner;
    private int maxP;
    private int maxPrisoners;
    private int maxW;
    private int maxWardens;
    private int maxH;
    private int maxHighPrisoners;
    public String prisonName;
    public Prison (String prison, int maxP, int maxW, int maxH)
    prisonName = prison;
    maxPrisoners = maxP;
    maxP = 0;
    thePrisoner = new Prisoner [maxPrisoners];
    maxWardens = maxW;
    maxW = 0;
    theWarden = new Warden [maxWardens];
    maxHighPrisoners = maxH;
    maxH = 0;
    theHighPrisoner = new HighPrisoner [maxHighPrisoners];
    public boolean addPrisoner( Prisoner newPrisoner )
    if ( maxP == maxPrisoners )
    System.out.println("Prisons full");
    return false;
    else
    System.out.println("Prisoner now in Prison");
    thePrisoner[maxP] = newPrisoner;
    maxP++;
    return true;
    public boolean addHighPrisoner( HighPrisoner newHighPrisoner )
    if ( maxH == maxHighPrisoners )
    System.out.println("Prisons full");
    return false;
    else
    System.out.println("High Level Prisoner now in Prison");
    theHighPrisoner[maxH] = newHighPrisoner;
    maxH++;
    return true;
    public boolean addWarden( Warden newWarden )
    if ( maxW == maxWardens )
    System.out.println("We Have Anough Wardens");
    return false;
    else
    System.out.println("Warden now working at Prison");
    theWarden[maxW] = newWarden;
    maxW++;
    return true;
    public void outputAll()
    System.out.println("School Name: " + prisonName );
         System.out.println("");
    outputWardens();
         System.out.println("");
         outputPrisoners();
         System.out.println("");
    outputHighPrisoners();
    System.out.println("");
    public void outputWardens()
    System.out.println("The Wardens:");
    for( int i=0; i < maxW; ++i)
    System.out.println(theWarden);
    public void outputPrisoners()
    System.out.println("The Low Level Prisoners:");
    for( int i=0; i < maxP; ++i)
    System.out.println(thePrisoner[i]);
    public void outputHighPrisoners()
    System.out.println("The High Level Prisoners:");
    for( int i=0; i < maxH; ++i)
    System.out.println(theHighPrisoner[i]);
    public void getNum(String num)
    System.out.println("---------------");
    System.out.println("Search for Prisoner ID:");
    System.out.println("---------------");
    for(Prisoner nextPrisoner : thePrisoner)
         --> 128     if (nextPrisoner.getNum() == num)
              System.out.println(nextPrisoner);
    else
    System.out.println("Sorry no Prisoner ID found");
    for(HighPrisoner nextHighPrisoner : theHighPrisoner)
              if (nextHighPrisoner.getNum() == num)
              System.out.println(nextHighPrisoner);
    else
    System.out.println("Sorry No Prisoner ID found");
    System.out.println("");
    TestPrison
    import java.util.*;
    public class TestPrison
    public static void main(String []args)
         String sN;
    int sS;
         String sA;
         String tN;
    int tS;
         int input;
    String aN;
    int aS;
    String aA;
    int aL;
    String aC;
    String pN;
    String rN;
         Scanner kybd = new Scanner(System.in);
         Prison prison0 = new Prison("Alcatraz",200,200,100);
         do {
              menu();
              System.out.println("Enter Option: ");
              input = kybd.nextInt();
              switch(input) {
              case 1:
                   System.out.println("Enter Name: ");
                   tN = kybd.next();
                   System.out.println("Enter Rank: ");
                   tS = kybd.nextInt();
                   Warden wardenObject = new Warden(tN,tS);
                   prison0.addWarden(wardenObject);
                   System.out.println("\nWarden "+tN+" Added!");
                   break;
    case 2:
    System.out.println("Enter Prisoner Security Level: ");
    aL = kybd.nextInt();
    if (aL > 3)
    System.out.println("Enter Name: ");
                   aN = kybd.next();
                   System.out.println("Enter Remaining Jail Time: ");
                   aS = kybd.nextInt();
                   System.out.println("Enter Prisoner ID: ");
                   aA = kybd.next();
    System.out.println("Can Prisoner Share Cell? ");
    aC = kybd.next();
                   HighPrisoner highprisonerObject = new HighPrisoner(aN,aS,aA,aL,aC);
                   prison0.addHighPrisoner(highprisonerObject);
                   System.out.println("\nPrisoner " + aA + " Added!");
                   break;
    else
    System.out.println("Enter Name: ");
                   sN = kybd.next();
                   System.out.println("Enter Remaining Jail Time: ");
                   sS = kybd.nextInt();
                   System.out.println("Enter Prisoner ID: ");
                   sA = kybd.next();
                   Prisoner prisonerObject = new Prisoner(sN,sS,sA);
                   prison0.addPrisoner(prisonerObject);
                   System.out.println("\nPrisoner " + sA + " Added!");
                   break;
              case 3:
                   prison0.outputAll();
                   break;
              case 4:
                   prison0.outputWardens();
                   break;
              case 5:
                   prison0.outputPrisoners();
         break;
    case 6:
    prison0.outputHighPrisoners();
    break;
    case 7:
    prison0.outputPrisoners();
    prison0.outputHighPrisoners();
    break;
    case 8:
    System.out.println("Enter Prisoner ID: ");
                   pN = kybd.next();
    ---> 101 prison0.getNum(pN);
    break;
              default:
                   System.out.println("Error Selection Does Not Exist");
                   break;
         } while(input >= 0);
    public static void menu() {
         System.out.println("");
         System.out.println("MAIN MENU");
         System.out.println("*********\n");
         System.out.println("1. Add Warden\n");
    System.out.println("2. Add Prisoner\n");
         System.out.println("3. View All\n");
         System.out.println("4. View Wardens\n");
         System.out.println("5. View Low Level Prisoners\n");
    System.out.println("6. View High Level Prisoners\n");
    System.out.println("7. View All Prisoners\n");
    System.out.println("8. Search Prisoner ID\n\n");
    Once again any help would really be appreciated : )

    The nextPrisoner is null, and you can't call getNum() on a null reference.
    Try replacing that line with:if (nextPrisoner != null && nextPrisoner.getNum() == num) Oh, next time you're posting code, please use code tags:
    http://forum.java.sun.com/help.jspa?sec=formatting

  • Help with "ORA-06511: PL/SQL: cursor already open"

    I've tried numerous variations on this piece of code and I always get the same result. I'm sure this is painfully obvious to an experienced PL/SQL person.
    Any help will be appreciated!
    Thank You!
    1 DECLARE
    2 CURSOR EMP_CURSOR IS SELECT last_name from employees;
    3 current_last_name varchar2(25);
    4 BEGIN
    5 IF EMP_CURSOR%ISOPEN
    6 THEN
    7 dbms_output.put_line ('cursor is already open');
    8 close EMP_CURSOR;
    9 END IF;
    10 dbms_output.put_line ('opening cursor');
    11 OPEN EMP_CURSOR;
    12 FOR item in EMP_CURSOR LOOP
    13 FETCH EMP_CURSOR INTO current_last_name;
    14 EXIT WHEN EMP_CURSOR%NOTFOUND;
    15 dbms_output.put_line (item.last_name);
    16 END LOOP;
    17 CLOSE EMP_CURSOR;
    18* END;
    19 /
    DECLARE
    ERROR at line 1:
    ORA-06511: PL/SQL: cursor already open
    ORA-06512: at line 2
    ORA-06512: at line 12

    Mathieu,
    Log in as anotherSchema and grant select on 'IDsTable' to the current user.
    SQL> r
      1  create or replace function f1(theID varchar2) return mytype pipelined is
      2  out varchar2(30);
      3  cursor myCursor (x varchar2) is select * from scott.emp where job=x;
      4  begin
      5  for rec in myCursor(theID) loop
      6  pipe row(rec.ename);
      7  end loop;
      8  return;
      9* end;
    Warning: Function created with compilation errors.
    SQL> show errors
    Errors for FUNCTION F1:
    LINE/COL ERROR
    3/33     PL/SQL: SQL Statement ignored
    3/53     PL/SQL: ORA-00942: table or view does not exist
    6/1      PL/SQL: Statement ignored
    6/10     PLS-00364: loop index variable 'REC' use is invalid
    SQL> connect scott
    Enter password: *****
    Connected.
    SQL> grant select on emp to testuser;
    Grant succeeded.
    SQL> connect testuser
    Enter password: ****
    Connected.
    SQL> create or replace function f1(theID varchar2) return mytype pipelined is
      2  out varchar2(30);
      3  cursor myCursor (x varchar2) is select * from scott.emp where job=x;
      4  begin
      5  for rec in myCursor(theID) loop
      6  pipe row(rec.ename);
      7  end loop;
      8  return;
      9  end;
    10  /
    Function created.
    SQL> disconnect
    Disconnected from Oracle9i Enterprise Edition Release 9.2.0.3.0 - 64bit Production
    With the Partitioning option
    JServer Release 9.2.0.3.0 - Production
    SQL>

  • Need help with navigation within a spark list...

    hey guys, so in my application when you click on a list item, it opens up an image, and along with the image a few buttons are created dynamically...
    the image and the url/labels for the dynamic buttons is provided through an xml/xmlListCollection.
    what i need help with is the url or more specifically when you click on one of these dynamic buttons it needs to navigate me to another part of an list or display a certain set of images that is not in my spark list...
    please let me know if this makes no sence
    the code i have is
    <code>
        [Bindable] private var menuXml:XML;
        [Bindable] private var imgList:XMLListCollection = new XMLListCollection();
        [Bindable] private var navControl:XMLListCollection = new XMLListCollection();
        [Bindable] private var fullList:XMLListCollection = new XMLListCollection();
        private var returnedXml:XMLListCollection = new XMLListCollection();
        private var myXmlSource:XML = new XML();
        //[Bindable] private var xmlReturn:Object;
        private var currImage:int = 0;
        //public var userOpProv:XMLListCollection = new XMLListCollection();
        //private var troubleShootProvider:XMLListCollection = new XMLListCollection();
        private function myXml_resultHandeler(event:ResultEvent):void{
            userOptionProvider.source = event.result.apx32.userOptions.children();
            troubleShootProvider.source = event.result.apx32.troubleShooting.children();
            fullList.source = event.result.apx32.children();
            returnedXml.source = event.result[0].children();
            myXmlSource = event.result[0];
        private function myXml_faultHandler(event:FaultEvent):void{
            Alert.show("Error loading XML");
            Alert.show(event.fault.message);
        private function app_creationComplete(event:FlexEvent):void{
            userOptions.scroller.setStyle("horizontalScrollPolicy", ScrollPolicy.OFF);
            myXml.send();
            //trouble.scroller.setStyle("horizontalScrollPolicy", ScrollPolicy.OFF);
            myXml = new HTTPService();
            myXml.url = "modules/apx32/apx32TroubleshootingXml.xml";
            myXml.resultFormat = "e4x";
            myXml.addEventListener(ResultEvent.RESULT, myXml_resultHandeler);
            myXml.addEventListener(FaultEvent.FAULT, myXml_faultHandler);
            myXml.send();
        private function troubleShootChange(event:IndexChangeEvent):void{
            dynamicButtons.removeAllElements();
            navControl.source = troubleShootProvider[event.newIndex].children();
            currImage = 0;
            imgList.source = troubleShootProvider[event.newIndex].images.children();
            definition.source = imgList[currImage].@url;
            if(imgList[currImage].@details == "true"){
                if(imgList[currImage].buttons.@hasButtons == "true"){
                    for each(var item:XML in imgList[currImage].buttons.children()){
                        var newButton:LinkButton = new LinkButton();
                        newButton.label = item.@name;
                        newButton.x = item.@posX;
                        newButton.y = item.@posY;
                        newButton.setStyle("skin", null);
                        newButton.styleName = "dynamicButtonStyle";
                        dynamicButtons.addElement(newButton);
            //var isMultiPage:String = navControl[2]["multiPages"];
            //trace(isMultiPage);
            //        if(isMultiPage){
            if(currImage >= imgList.length - 1){
                next.visible = false;
                back.visible = false;
            else{
                back.visible = false;
                next.visible = true;
        private function customButtonPressed(event:Event):void{
            if(imgList[currImage].button.@changeTo != ""){
        private function userOptionsChange(event:IndexChangeEvent):void{
            dynamicButtons.removeAllElements();
            navControl.source = userOptionProvider[event.newIndex].children();
            currImage = 0;
            imgList.source = userOptionProvider[event.newIndex].images.children();
            definition.source = imgList[currImage].@url;
            if(imgList[currImage].@details == "true"){
                if(imgList[currImage].buttons.@hasButtons == "true"){
                    for each(var item:XML in imgList[currImage].buttons.children()){
                        var newButton:LinkButton = new LinkButton();
                        newButton.label = item.@name;
                        newButton.x = item.@posX;
                        newButton.y = item.@posY;
                        newButton.setStyle("skin", null);
                        newButton.styleName = "dynamicButtonStyle";
                        newButton.addEventListener(MouseEvent.MOUSE_DOWN, customButtonPressed);
                        dynamicButtons.addElement(newButton);
            var isMultiPage:String = navControl[2]["multiPages"];
            if(isMultiPage == "true"){
                if(navControl[2]["next"] == "NEXT STEP"){
                    navContainer.x = 630;
                else{
                    navContainer.x = 640;
                next.label = navControl[2]["next"];
                back.label = navControl[2]["back"];
            if(currImage >= imgList.length - 1){
                next.visible = false;
                back.visible = false;
            else{
                back.visible = false;
                next.visible = true;
        private function nextClickHandler(event:MouseEvent):void{
            currImage += 1;
            dynamicButtons.removeAllElements();
            if(currImage >= imgList.length-1){
                currImage = imgList.length - 1;
                //next.visible = false;
                next.label = "YOU'RE DONE";
            else
                next.label = navControl[2]["next"];
            back.visible = true;
            if(imgList[currImage].@details == "true"){
                if(imgList[currImage].buttons.@hasButtons == "true"){
                    for each(var item:XML in imgList[currImage].buttons.children()){
                        var newButton:LinkButton = new LinkButton();
                        newButton.label = item.@name;
                        newButton.x = item.@posX;
                        newButton.y = item.@posY;
                        newButton.setStyle("skin", null);
                        newButton.styleName = "dynamicButtonStyle";
                        dynamicButtons.addElement(newButton);
            definition.source = imgList[currImage].@url;
        private function backClickHandler(event:MouseEvent):void{
            currImage -= 1;
            dynamicButtons.removeAllElements();
            if(currImage == 0){
                back.visible = false;
            next.visible = true;
            next.label = navControl[2]["next"];
            if(imgList[currImage].@details == "true"){
                if(imgList[currImage].buttons.@hasButtons == "true"){
                    for each(var item:XML in imgList[currImage].buttons.children()){
                        var newButton:LinkButton = new LinkButton();
                        newButton.label = item.@name;
                        newButton.x = item.@posX;
                        newButton.y = item.@posY;
                        newButton.setStyle("skin", null);
                        newButton.styleName = "dynamicButtonStyle";
                        dynamicButtons.addElement(newButton);
            definition.source = imgList[currImage].@url;
    </code>
    i have attached a copy of the xml that i have right now to this post for reference...
    any help will be greatly appretiated!!! i've been stuck on this problem for the last week and my project is due soon
    again thank you in advance...

    hey david... just nevermind my previous post... I was able to subclass a link button, so i now have two variables that get assigned to a link button,
    one is "tabId" <-- contains the information on which tab to swtich to, and the second is, "changeTo"... this contans the label name which it needs to switch to
    I'm just stuck on how to change my selected item in my tabNavigator/list
    the code i have right now is
        private function customButtonPressed(event:Event):void{
            if(event.currentTarget.tabId == "troubleShooting"){
                for each(var item:Object in troubleShootProvider){
                    if(item.@label == event.currentTarget.changeTo){
        private function userOptionsChange(event:IndexChangeEvent):void{
            dynamicButtons.removeAllElements();
            navControl.source = userOptionProvider[event.newIndex].children();
            currImage = 0;
            imgList.source = userOptionProvider[event.newIndex].images.children();
            definition.source = imgList[currImage].@url;
            if(imgList[currImage].@details == "true"){
                if(imgList[currImage].buttons.@hasButtons == "true"){
                    for each(var item:XML in imgList[currImage].buttons.children()){
                        var newButton:customLinkButton = new customLinkButton();
                        newButton.label = item.@name;
                        newButton.tabId = item.@tab;
                        newButton.changeTo = item.@changeTo;
                        newButton.x = item.@posX;
                        newButton.y = item.@posY;
                        newButton.setStyle("skin", null);
                        newButton.styleName = "dynamicButtonStyle";
                        newButton.addEventListener(MouseEvent.MOUSE_DOWN, customButtonPressed);
                        dynamicButtons.addElement(newButton);
            var isMultiPage:String = navControl[2]["multiPages"];
            var videoPresent:String = navControl[1]["videoPresent"];
            if(videoPresent == "true"){
                if(isMultiPage != "true"){
                    navContainer.x = 825;
            if(isMultiPage == "true"){
                if(navControl[2]["next"] == "NEXT STEP"){
                    navContainer.x = 630;
                else{
                    navContainer.x = 640;
                next.label = navControl[2]["next"];
                back.label = navControl[2]["back"];
            if(currImage >= imgList.length - 1){
                next.visible = false;
                back.visible = false;
            else{
                back.visible = false;
                next.visible = true;
    as you know, my xml gets divided into two saperate xmllistcollections one is the userOptionProvider, and the troubleshootingProvider
    as is in the following xml
    <mx:TabNavigator id="tabNav" width="275" tabStyleName="tabStyle" fontWeight="bold" height="400" paddingTop="0"
                             tabWidth="137.5" creationPolicy="all" borderVisible="false">
                <mx:VBox label="USER OPTIONS" width="100%" height="100%" horizontalScrollPolicy="off" verticalScrollPolicy="off">
                    <s:List id="userOptions" width="100%" height="100%" itemRenderer="modules.apx32.myComponents.listRenderer"
                            borderVisible="false" contentBackgroundColor="#e9e9e9"
                            change="userOptionsChange(event)">
                        <s:dataProvider>
                            <s:XMLListCollection id="userOptionProvider" />
                        </s:dataProvider>
                    </s:List>
                </mx:VBox>
                <mx:VBox label="TROUBLESHOOTING">
                    <s:List id="trouble" width="100%" height="100%" itemRenderer="modules.apx32.myComponents.listRenderer"
                            borderAlpha="0" borderVisible="false" contentBackgroundColor="#e9e9e9"
                            change="troubleShootChange(event)">
                        <s:dataProvider>
                            <s:XMLListCollection id="troubleShootProvider" />
                        </s:dataProvider>
                    </s:List>
                </mx:VBox>
            </mx:TabNavigator>
    Im having some trouble updating my list... basically change to the troubleshooting tab, and then select the one that i need...
    hopefully that makes sence...

  • Help with VARRAY in PL/SQL

    I wrote the below Stored Procedure in a package. I am not able to execute this, can anyone please help
    Package Definition:
    CREATE OR REPLACE PACKAGE "CDS_SUBLIMIT_TYPE_PKG" as
    TYPE COLLATERAL_ARRAY is VARRAY(100) OF NUMBER(29);
    procedure get_original_balance_array_p(in_collateral_id IN NUMBER, l_data OUT COLLATERAL_ARRAY );
    end CDS_SUBLIMIT_TYPE_PKG;
    Package Body:
    CREATE OR REPLACE PACKAGE BODY "CDS_SUBLIMIT_TYPE_PKG" as
    procedure get_original_balance_array_p
    (in_collateral_id IN NUMBER, l_data OUT COLLATERAL_ARRAY ) IS
    CURSOR c_collateral IS
    SELECT collateral_id FROM collateral where rownum < 10;
    BEGIN
    l_data:=COLLATERAL_ARRAY();
    FOR collateral_rec IN c_collateral LOOP
    l_data.extend;
    l_data(l_data.count):=collateral_rec.collateral_id;
    END LOOP;
    l_data.extend;
    l_data(l_data.count):=in_collateral_id;
    END get_original_balance_array_p;
    end CDS_SUBLIMIT_TYPE_PKG;
    Execution:
    declare
    collateral_id number;
    collectionId collateral_array;
    begin
    collateral_id:=55;
    CDS_SUBLIMIT_TYPE_PKG.get_original_balance_array_p(collateral_id, collectionId);
    end;

    collectionId collateral_array;You missed out the package name - it should be
    collectionId cds_sublimit_type_pkg.collateral_array;VARRAYs are good as multivalue columns in database tables, if you're into that (I'm not particularly). In PL/SQL code, nested tables have more functionality, especially in 10g.
    www.williamrobertson.net/documents/collection-types.html

  • Need help with search function in my program

    Hello all, some of you may remeber me from my previous inventory programs. Well I am finally on my last one and I need to add a search option to the code. Here is the class that will contain that option.
    import java.util.*;
    import javax.swing.*;
    import java.awt.event.*;
    import java.awt.*;
    public class Inventory2 extends JFrame implements ActionListener {
    //Utility class for displaying the picture
    //If we are going to use a class/method/variable inside that class only, we declare it private in that class
    private class MyPanel extends JPanel {
    ImageIcon image = new ImageIcon("Sample.jpg");
    int width = image.getIconWidth();
    int height = image.getIconHeight();
    long angle = 30;
    public MyPanel(){
    super();
    public void paintComponent(Graphics g){
         super.paintComponent(g);
         Graphics2D g2d = (Graphics2D)g;
         g2d.rotate (Math.toRadians(angle), 60+width/2, 60+height/2);
         g2d.drawImage(image.getImage(), 60, 60, this);
         g2d.dispose();
    }//end class MyPanel
    int currentIndex; //Currently displayed Item
    Product[] supplies = new Product[4];
    JLabel name ;
    JLabel number;
    JLabel rating;
    JLabel quantity;
    JLabel price;
    JLabel fee;
    JLabel totalValue;
    JTextField nameField = new JTextField(20);
    JTextField numberField = new JTextField(20);
    JTextField ratingField = new JTextField(20);
    JTextField quantityField = new JTextField(20);
    JTextField priceField = new JTextField(20);
    JPanel display;
    JPanel displayHolder;
    JPanel panel;
    boolean locked = false; //Notice how I've used this flag to keep the interface clean
    public Inventory2() {
    makeTheDataItems();
    setSize(700, 500);
    setTitle("Inventory Program");
    //make the panels
    display = new JPanel();
    JPanel other = new JPanel();
    other.setLayout(new GridLayout(2, 1));
    JPanel picture = new MyPanel();
    JPanel buttons = new JPanel();
    JPanel centerPanel = new JPanel();
    displayHolder = new JPanel();
    display.setLayout(new GridLayout(7, 1));
    //other.setLayout(new GridLayout(1, 1));
    //make the labels
    name = new     JLabel("Name :");
    number = new JLabel("Number :");
    rating = new JLabel("Rating     :");
    quantity = new JLabel("Quantity :");
    price = new JLabel("Price     :");
    fee = new JLabel("Restocking Fee (5%) :");
    totalValue = new JLabel("Total Value :");
    //Use the utility method to make the buttons
    JButton first = makeButton("First");
    JButton next = makeButton("Next");
    JButton previous = makeButton("Previous");
    JButton last = makeButton("Last");
    JButton search = makeButton("Search");
    //Other buttons
    JButton add = makeButton("Add");
    JButton modify = makeButton("Modify");
    JButton delete = makeButton("Delete");
    JButton save = makeButton("Save");
    JButton exit = makeButton("Exit");
    //Add the labels to the display panel
    display.add(name);
    display.add(number);
    display.add(rating);
    display.add(quantity);
    display.add(price);
    display.add(fee);
    //add the buttons to the buttonPanel
    buttons.add(first);
    buttons.add(previous);
    buttons.add(next);
    buttons.add(last);
    buttons.add(search);
    //Add the picture panel and display to the centerPanel
    displayHolder.add(display);
    centerPanel.setLayout(new GridLayout(2, 1));
    centerPanel.add(picture);
    centerPanel.add(displayHolder);
    other.add(buttons);
    JPanel forAdd = new JPanel(); // add the other buttons to this panel
    forAdd.add(add);
    forAdd.add(modify);
    forAdd.add(delete);
    forAdd.add(save);
    forAdd.add(exit);
    other.add(forAdd);
    //Add the panels to the frame
    getContentPane().add(centerPanel, "Center");
    getContentPane().add(other, "South");
    this.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
    setVisible(true);
    private void makeTheDataItems () {
    Product p1 = new DVD("The one", 001, 200, 100, "The one");
    Product p2 = new DVD("Once upon a time in China V", 002, 500, 10000, "Once upon a time in China V");
    Product p3 = new DVD("Rat Race", 003, 100, 3000, "Rat Race");
    Product p4 = new DVD("The Man in the Iron Mask", 004, 3000, 9000, "The Man in the Iron Mask");
    supplies[0] = p1;
    supplies[1] = p2;
    supplies[2] = p3;
    supplies[3] = p4;
    //Utility method for creating and dressing buttons
    private JButton makeButton(String label) {
    JButton button = new JButton(label);
    button.setPreferredSize(new Dimension(100, 25));
    button.setActionCommand(label);
    button.addActionListener(this);
    return button;
    private void addItem() {
    panel = new JPanel();
    JPanel add = new JPanel();
    add.setLayout(new GridLayout(7, 2));
    JButton addIt = makeButton("Add Item");
    JLabel name = new JLabel("Name :");
    JLabel rating = new JLabel("Rating     :");
    JLabel quantity = new JLabel("Quantity :");
    JLabel price = new JLabel("Price     :");
    add.add(name); add.add(nameField);
    add.add(rating); add.add(ratingField);
    add.add(quantity); add.add(quantityField);
    add.add(price); add.add(priceField);
    panel.add(add);
    JPanel forAddIt = new JPanel();
    forAddIt.add(addIt);
    panel.add(forAddIt);
    displayHolder.remove(display);
    displayHolder.add(panel);
    //display = panel;
    this.setVisible(true);
    public static void main( String args[]) {
    new Inventory2().displayFirst(); //The main method should not have too much code
    } // end main method
    public void actionPerformed(ActionEvent event) {
      String command = event.getActionCommand(); //This retrieves the command that we set for the button
      //Always compare strings using the .equals method and not using ==
      if(command.equals("First")) {
       if(!locked) {
         displayFirst();
      else if(command.equals("Next")) {
       if(!locked) {
         displayNext();
      else if(command.equals("Previous")) {
       if(!locked) {
         displayPrevious();
      else if(command.equals("Last")) {
       if(!locked) {
         displayLast();
      else if(command.equals("Exit")) {
       this.dispose();
       System.exit(0);
      else if(command.equals("Add")) {
       if(!locked) {
         addItem();
         locked = true;
      else if(command.equals("Add Item")) {
       addItemToArray();
      else if(command.equals("Modify")) {
       if(!locked) {
         modify();
         locked = true;
      else if(command.equals("Update")) {
          if(!locked) {
         modifyItemInArray();
         locked = true;
      else if(command.equals("Delete")) {
       if(!locked) {
         DVD dvd = (DVD)supplies[currentIndex];
            int confirm = JOptionPane.showConfirmDialog(this, "Are you sure you want to delete item "+dvd.getItemNumber());
                if(confirm == JOptionPane.YES_OPTION) {
          removeItemAt(currentIndex);
          displayFirst();
    private void modify() {
    DVD dvd = (DVD)supplies[currentIndex];
    panel = new JPanel();
    JPanel add = new JPanel();
    add.setLayout(new GridLayout(7, 2));
    JButton update = makeButton("Update");
    JLabel number = new JLabel("Number :");
    JLabel name = new JLabel("Name :");
    JLabel rating = new JLabel("Rating     :");
    JLabel quantity = new JLabel("Quantity :");
    JLabel price = new JLabel("Price     :");
    add.add(number);
    numberField.setText(""+dvd.getItemNumber()); numberField.setEditable(false); add.add(numberField);
    add.add(name);
    nameField.setText(dvd.getItemName()); add.add(nameField);
    ratingField.setText(dvd.getRating()); ratingField.setEditable(false);
    add.add(rating); add.add(ratingField);
    add.add(quantity);
    quantityField.setText(""+dvd.getStockQuantity());
    add.add(quantityField);
    add.add(price);
    add.add(priceField); priceField.setText(""+dvd.getItemPrice());
    panel.add(add);
    JPanel forAddIt = new JPanel();
    forAddIt.add(update);
    panel.add(forAddIt);
    displayHolder.remove(display);
    displayHolder.add(panel);
    //display = panel;
          this.setVisible(true);
    private void addItemToArray() {
    Product p = new DVD(nameField.getText(), supplies.length + 1, Long.parseLong(quantityField.getText()),
    Double.parseDouble(priceField.getText()), ratingField.getText());
    //Extend size of array by one first
    Product[] ps = new Product[supplies.length + 1];
    for(int i = 0; i < ps.length-1; i++) {
    ps[i] = supplies;
    ps[supplies.length] = p;
    supplies = ps;
    displayHolder.remove(panel);
    displayHolder.add(display);
    displayLast();
    this.setVisible(false);
    this.setVisible(true);
    //Utility method to ease the typing and reuse code
    //This method reduces the number of lines of our code
    private void displayItemAt(int index) {
    DVD product = (DVD)supplies[index];
    name.setText("Item Name: "+ product.getItemName());
    number.setText("Item Number: "+ product.getItemNumber());
    rating.setText("Rating: "+ product.getRating());
    quantity.setText("Quantity In Stock: "+ product.getStockQuantity());
    price.setText("Item Price: "+ product.getItemPrice());
    totalValue.setText("Total: " + product.calculateInventoryValue());
    fee.setText("Restocking Fee (5%) :"+product.calculateRestockFee());
    locked = false;
    this.repaint();
    this.setVisible(true);
    private void modifyItemInArray() {
    Product p = new DVD(nameField.getText(), supplies.length + 1, Long.parseLong(quantityField.getText()),
    Double.parseDouble(priceField.getText()), ratingField.getText());
    supplies[currentIndex] = p;
    displayHolder.remove(panel);
    displayHolder.add(display);
         displayItemAt(currentIndex);
    this.setVisible(false);
    this.setVisible(true);
    private void removeItemAt(int index) {
    Product[] temp = new Product[supplies.length-1];
    int counter = 0;
    for(int i = 0; i < supplies.length;i++) {
    if(i == index) { //skip the item to delete
    else {
         temp[counter++] = supplies[i];
    supplies = temp;
    public void displayFirst() {
    displayItemAt(0);
    currentIndex = 0;
    public void displayNext() {
    if(currentIndex == supplies.length-1) {
    displayFirst();
    currentIndex = 0;
    else {
    displayItemAt(currentIndex + 1);
    currentIndex++;
    public void displayPrevious() {
    if(currentIndex == 0) {
    displayLast();
    currentIndex = supplies.length-1;
    else {
    displayItemAt(currentIndex - 1);
    currentIndex--;
    public void displayLast() {
    displayItemAt(supplies.length-1);
    currentIndex = supplies.length-1;
    }//end class Inventory2
    I am not sure where to put it and how to set it up. If you guys need the other two classes let me know. Thanks in advanced.

    Here are the other two classes:
    import java.util.*;
    import javax.swing.*;
    import java.awt.event.*;
    import java.awt.*;
    class Product implements Comparable {
    String name;
    int number;
    long stockQuantity;
    double price;
    public Product() {
      name = "";
          number = 0;
          stockQuantity = 0L;
          price = 0.0;
    public Product(String name, int number, long stockQuantity, double price) {
      this.name = name;
          this.number = number;
          this.stockQuantity = stockQuantity;
          this.price = price;
         public void setItemName(String name) {
      this.name = name;
    public String getItemName() {
      return name;
    public void setItemNumber(int number) {
      this.number = number;
    public int getItemNumber() {
      return number;
    public void setStockQuantity(long quantity) {
      stockQuantity = quantity;
    public long getStockQuantity() {
      return stockQuantity;
    public void setItemPrice(double price) {
      this.price = price;
    public double getItemPrice() {
      return price;
    public double calculateInventoryValue() {
      return getItemPrice() * getStockQuantity();
    public int compareTo (Object o) {
      Product p = (Product)o;
      return name.compareTo(p.getItemName());
    public String toString() {
      return "Name :"+getItemName() + "\nNumber"+number+"\nPrice"+price+"\nQuantity"+stockQuantity + "\nValue :"+calculateInventoryValue();
    class DVD extends Product implements Comparable {
    private String rating;
    public DVD() {
      super(); //Call the constructor in Product
      rating = ""; //Add the additonal attribute
    public DVD(String name, int number, long stockQuantity, double price, String rating) {
      super(name, number, stockQuantity, price); //Call the constructor in Product
      this.rating = rating; //Add the additonal attribute
         public void setRating(String rating) {
      this.rating = rating;
    public String getRating() {
      return rating;
    public double calculateInventoryValue() {
      return getItemPrice() * getStockQuantity() + getItemPrice()*getStockQuantity()*0.05;
    public double calculateRestockFee() {
      return getItemPrice() * 0.05;
    public int compareTo (Object o) {
      Product p = (Product)o;
      return getItemName().compareTo(p.getItemName());
    public String toString() {
      return "Name :"+getItemName() + "\nNumber"+getItemNumber()+"\nPrice"+getItemPrice()+"\nQuantity"+getStockQuantity() +"\nRating :"+getRating()+"\nValue"+calculateInventoryValue();
    }You should be able to search through these items, and any other items that have been added to the program.

  • Help with searching database

    good morning.... could someone please help me with some coding for the following program... i need a text box that i can enter a customers name into that then will search the database and display the appropriate record.. i have written the following code for displaying the whole database but am having trouble with the text box and the searching of the database if anyone could point me to some helpfull links or anything else that would be great.. thanks..
    CODE SO FAR
    import java.sql.*;
    import javax.swing.*;
    import javax.swing.event.*;
    import java.awt.*;
    import java.awt.event.*;
    import java.util.*;
    public class customer extends JFrame {
    private Connection connection;
    private JTable table;
    public customer()
    String url = "jdbc:odbc:Info";
    try{
    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
    connection = DriverManager.getConnection(url);
    catch (ClassNotFoundException cnfex){
    System.err.println(
    "Failed to load JDBC/ODBC driver.");
    cnfex.printStackTrace();
    System.exit(1);
    catch(SQLException sqlex){
    System.err.println("Unable to connect");
    sqlex.printStackTrace();
    getTable();
    setSize(450,200);
    show();
    private void getTable()
    Statement statement;
    ResultSet resultSet;
    try{
    String query = "Select * from custDetails";
    statement = connection.createStatement();
    resultSet = statement.executeQuery(query);
    displayresultSet(resultSet);
    statement.close();
    catch (SQLException sqlex){
    sqlex.printStackTrace();
    private void displayresultSet(ResultSet rs)
    throws SQLException
    boolean moreRecords = rs.next();
    if(!moreRecords){
    JOptionPane.showMessageDialog(this,
    "ResultSet contained no records");
    setTitle("No records to diaplay");
    return;
    setTitle("Customer Details Table from Customer");
    Vector columnHeads = new Vector();
    Vector rows = new Vector();
    try{
    ResultSetMetaData rsmd = rs.getMetaData();
    for(int i=1; i<=rsmd.getColumnCount();++i)
    columnHeads.addElement(rsmd.getColumnName(1));
    do{
    rows.addElement(getNextRow(rs, rsmd));
    }while (rs.next());
    table = new JTable(rows, columnHeads);
    JScrollPane scroller = new JScrollPane(table);
    getContentPane().add(
    scroller, BorderLayout.CENTER);
    validate();
    catch (SQLException sqlex){
    sqlex.printStackTrace();
    private Vector getNextRow(ResultSet rs,
    ResultSetMetaData rsmd)throws SQLException
    Vector currentRow = new Vector();
    for (int i=1; i<rsmd.getColumnCount();++i)
    switch(rsmd.getColumnType(i)){
    case Types.VARCHAR:
    currentRow.addElement(rs.getString(i));
    break;
    case Types.INTEGER:
    currentRow.addElement(
    new Long(rs.getLong(i)));
    break;
    default:
    System.out.println("Type was:"+
    rsmd.getColumnTypeName(i));
    return currentRow;
    public void shutDown()
    try{
    connection.close();
    catch (SQLException sqlex){
    System.err.println("Unable to disconnect");
    sqlex.printStackTrace();
    public static void main(String args[])
    final customer app = new customer();
    app.addWindowListener(
    new WindowAdapter(){
    public void windowClosing(WindowEvent e)
    app.shutDown();
    System.exit(0);
    }

    what is it that you actually want to do and what errors are u getting.
    cheers

  • Can anybody help with some subtleties to this code?

    Hello,
    I was wondering if anyone could take a look at the code in general for me, which is to go in an 'effects' pedal.  The first while loop is for a footswitch that either reads high or low.  It controls the mode of the pedal.  the first mode is the default, where no signal manipulation occurs, and what comes in the audio input just comes out; the second mode stores data (fundamental frequency, average FFT amplitude from 3 kHz to 5 kHz) from the E string of a guitar, which is plucked after that mode is actuated; the third mode does the same for the A string; and the final mode takes in a note on the E or string, recognizes it as either on the E or A string, and adjusts the frequency content to be in tune based the data stored in modes 2 and 3.  then the new magnitude vector is put through an inverse FFT and output through the DAC and sounded.
    What I'm curious to know is, are there any blatant errors I've made?  Will the signal coming out of the inverse FFT be sounded through the DAC? does it need to be changed from a double to an I32?  I am trying to debug, but right now I'm having problems getting the correct output voltages on the Blackfin (the SPORT 0 pinout doesn't seem to match what is on the board....).
    also, I was wondering if I will lose any phase information on the signal that I get out compared to the signal I put in.  Will it be detectable by ear?  Or would it all sound the same?  along with the phase change for some signals, using an inverse FFT resulted in a loss of amplitude (from about 1 to on the order of 10^-5.  that's a lot!).  but when the test program was played on my computer, the phase change was not noticeable from the output signal, and neither was the magnitude change!  the output played at the same volume as in the input, despite the waveform chart on the front panel showing an amplitude five orders of magnitude less!  can you help explain that to me?  what can I do, will it matter coming out of the Blackfin and into an amplifier?
    i appreciate any input anyone can give me on all this!!  thank you!!
    Attachments:
    102 project.vi ‏287 KB

    Hi noahgrant,
    I've had a look at your vi and can make some suggestions that you can try.
    From what I can see, your while loop with the wait timer of 100 ms and continue if true condition on it (we shall cool this loop 1) will always keep running.
    The other while loop (loop 2) is nested within a couple of case structures and will only run once (false to a continue if true condition). The default case has a different condition and will always run, instead.
    From what I can make of this, loop 2 and all its case structures will only run once (except for case 0, default). WHEN it runs will depend on how it was compiled on the Blackfin - case structure/loop2 may go first or loop 1 will go first.
    If you want loop 2 to go first (and only go once) then you need to link the output of the case structure to the input of loop 1 - this can be done by simply wiring up a boolean to it (data flow rules).
    If you want loop 2 to always be checking the status of the mode then you need to place the whole case structure within a while loop, to run continuously.
    That is a very quick interpretation of what you are trying to do. There are a lot of question marks (missing vi's) and some heavy use of local variables. I would consider using sub-vi's, in particular functional global variables (FGV's).
    I hope that helps.

  • Need help with division within a query

    Hello all~
    I am trying to divide these two columns to get a % of case numbers involving an accident. Im pretty sure you need to use decode to avoid the divide by 0 error but not sure how to implement this within my query. When i run this query below, it gives me the result of "1", which is not correct. Can someone help me please?
    Oracle Version 10g
    ACCIDENT is a datatype VARCHAR
    CASE_NUMBER is a datatype VARCHAR
    select to_char(count(ACCIDENT),'999,999,999') as "ACCIDENT",
    to_char(COUNT(CASE_NUMBER),'999,999,999')as "CASE NUMBER",
    round(ratio_to_report(count(accident))
    OVER()*100,2)as "%"
    from      "PURSUIT"
    WHERE ACCIDENT = 'Y'
    AND
    (:P1_BEG_DATE IS NULL AND :P1_END_DATE IS NULL
    OR
    pursuit_date BETWEEN to_date(:p1_beg_date,'MM/DD/YYYY') and to_date
    (:p1_end_date,'MM/DD/YYYY'))
    AND(:P1_TROOP=pursuit.officer_troop OR :p1_troop IS NULL) 
    AND(:P1_RADIO=pursuit.officer_radio OR :p1_radio IS NULL)
    group by case_numberThanks
    Deanna

    Are you sure that the ANDs and ORs in your WHERE clause will take precedence properly?
    Also, if you always select only cases where there has been an accident, what percentage would you like to display? Surely in this case the percentage of cases involving in accident in cases where there was an accident.. is 100%?
    as a simpler example
    SELECT
      accident,
      ROUND(RATIO_TO_REPORT(count(*)) OVER() * 100)
    FROM
      pursuit
    GROUP BY
      accidentHere's a trick to neaten up those IS NULLs:
    SELECT
      accident,
      ROUND(RATIO_TO_REPORT(count(*)) OVER() * 100)
    FROM
      pursuit
    WHERE
      pursuit_date >= COALESCE(:p1_beg_date, pursuit_date) AND
      pursuit_date <= COALESCE(:p1_end_date, pursuit_date) AND
      officer_troop LIKE :p1_troop AND
      offcier_radio LIKE :p1_radio
    GROUP BY
      accidentTo wildcard a date, simply pass NULL in; the coalesce will replace the null with the pursuit_date from the record (thus the >= and <= becomes true)
    To wildcard the troop or the radio, simply pass a '%' symbol as the value of the parameter. If the front end code is already set up to pass nulls, use the COALESCE trick above

  • Need help with select within select - daterange

    I use Crystal Reports v12.3.0.601 - I am a beginner.
    Problem:
    TABLE: ACCOUNTBILLFEE
    Columns are   
    FOLDERRSN
    STAMPDATE
    BILLNUMBER
    PAYMENTAMOUNT
    There are over 500,000 rows/ records...
    And I need to report the FOLDERRSN which has at least one {ACCOUNTBILLFEE.STAMPDATE} in DateTime
    (2014, 05, 01, 00, 00, 01) to DateTime (2014, 05, 31, 23, 59, 59)
    Out-put required is:
    FOLDERSN | STAMPDATE | BILLNUMBER   | PAYMENTAMOUNT
    Group by FOLDERRSN
    1010234               May01,2014                 1111                      25000
                                  May25, 2014                1112                       5000
                                  Jan 05, 2013                  998                          500
    1034567                May5, 2014                11325                       5000
    1033999                May15, 2014               6752                       15000
                                  Dec5 , 2011                1132                       25000
    Please help -
    The critical part for me, is to display  payments not within the date range in 'select expert' statement.
    Currenlty my report reflects only payments for FOLDERRSN, where {ACCOUNTBILLFEE.STAMPDATE} in DateTime
    (2014, 05, 01, 00, 00, 01) to DateTime (2014, 05, 31, 23, 59, 59) and not other payments outside the date range specified.
    Thank you for your time.

    Hi Abilash,
    This worked !!!
    My brother helped me with it here....ofcourse you have intiated the intial idea.
    It worked when i used the following SQL at 'Add Command'
    Select * from DATABASE_NAME.ACCOUNTBILLFEE A
    Where A.FOLDERSN = any ( select B.FOLDERSN from DATABASE_NAME.ACCOUNTBILLFEE B
    where B.STAMPDATE >= TO_DATE('20140501', 'YYYYMMDD')
    AND  B.STAMPDATE <= TO_DATE('20140531', 'YYYYMMDD'))
    Excellent support - Thank you so much for your immediate attention and response.
    I know, how hard it is to understand someones requirement and suggest solutions.
    You are the best and most helpful I have ever come across in my life.
    Thank you for your kind heart and extending help to me.
    Regs,
    Sridhar Lam

  • Verity search results showing SQL code

    This site is still in development and that's why the domain
    hasn't transferred yet:
    http://financial-strategist.dataride-previews.com/index.cfm.
    If you perform a search for the word
    business, for example, some of the search results display
    the SQL query code. How can I eliminate this from being included in
    the search results?
    My results page is as follows:
    <cfsearch
    name = "fs_search"
    collection = "fsdocs, affdocs, bodocs, profdocs, wibdocs"
    criteria = "#Form.Criteria#"
    maxrows = "35">
    <CFOUTPUT QUERY="fs_search">
    <a
    href="#url#"><strong>#Title#</strong></a>
    <br>
    #Summary# <br />
    <br />
    </CFOUTPUT>

    There are two ways Verity can index your CF pages (that I know of). One is to do it through the CF Admin Verity Collection and the other is the command line vspider.exe. I believe only the vspider will actually process your CF pages (processing your SQL as well) and the Verity Collection method in the CF Admin will only "read" your CF pages, this "reading" will just display what's in the pages (minus CF includes, etc.).
    I could be wrong in this of course because I've learned by trial and error. My experience has been the CF community sites (this one, HOF and Dev Shed) are very slim on Verity help. So I'd say RTFM as much as you can. HTH

  • I need help with network install of SQL Developer 3.2

    All,
    Does anyone have any references on how to perform a network install for SQL Developer? Here is what I'm trying to achieve:
    1. Network installation on drive S:\ (Windows, obviously)
    2. User links to network installation
    3. Connections are unique for each user
    I found the 2006 posting of network install for Raptor, but I could not find anything that correlates with the latest release. All I have done so far is downloaded and unzipped. Any help/instructions/guides/tutorials are welcome.

    You have installed!.  The code for SQLDeveloper does not have an installer.
    If the software is on S, say a shared drive, each user will start sqldeveloper and a directory called sqldeveloper  will be created in their local %APPLICATION_DATA% folder.  This will keep all connections etc unique for all users. 
    You will have to create a link from the S drive to the sqldeveloper.exe if you want a shortcut to start it.  We dont provide it.
    Thanks
    B

  • Please help with search

    I have a pretty large iTunes library, mostly "classical" music, and I've tried to improve on the Grace Notes database when ripping my CDs into iTunes.
    Unfortunately, iTunes does not provide a great foundation for cataloging music with an opus number or a key so I've tried to standardize most things in the name field.
    For example, the first movement of a Bach concerto might be listed as "Concerto for violin and oboe in c, BWV 1060: 1. Allegro" using a fairly standard lower case c implying that it is in the key of c minor.
    So, to my question: How do I find all the pieces in the key of, say, c minor? When I do a search (in the search field with the magnifying glass on the top right) with the parameters +in c+ I get several thousand pieces listed, many of which do not have the string +in c+. (My total database is about 17,000 songs.) If I try to put quotes around it so that it reads "in c" I get nothing returned.
    Is there a way to search for a string of characters including a space that is case sensitive?
    Thanks for any assistance.
    Message was edited by: BflatBlues

    The nextPrisoner is null, and you can't call getNum() on a null reference.
    Try replacing that line with:if (nextPrisoner != null && nextPrisoner.getNum() == num) Oh, next time you're posting code, please use code tags:
    http://forum.java.sun.com/help.jspa?sec=formatting

  • Help with Searching a Datagrid

    I am using the below code to search through a datagrid which is working fine.  However, I want to search through more than one column and I can't seem to figure out the syntax.  Can anyone help?
    It is the city field (highlighted in red below) that tells it to only look at the one column...anyone know how to make it look at several columns?
    Thanks.
    Dave
    private
    function onResult(evt:ResultEvent):void
         var sort:Sort = new Sort();     sort.fields = [new SortField("city",true) ];
         this.homesForSale = evt.result.data.region;  
         this.homesForSale.sort = sort;  
         this.homesForSale.refresh();  
         this.cursor = this.homesForSale.createCursor();}
    private function searchCity():void      { 
         if(search_ti.text != "") { 
         if(this.cursor.findFirst({city:search_ti.text})){ 
         var idx:int = this.homesForSale.getItemIndex(this.cursor.current); 
         this.grid.scrollToIndex(idx); 
         this.grid.selectedItem = this.cursor.current;

    Hi Alex,
    Thanks for the response.  I should have been more clear in my question.  I can add more fields to my Array but if I add them in the function as well, it looks for the combination of the colums...like an "AND" statement...what I want is an "OR" clause...if it is in this column or that column...so I can search through every column in the datagrid.
    Another question I have is how to use a variable for the column name.  I could loop through it and dynamically put a column name in if it would accept a variable but I can figure out why it won't.  In other words, replace the red city with a variable...it keeps giving a Flash player error says it needs a field name.
    Thanks for the comments.
    Dave

  • Help with searching and replacing

    This kind of carries on from the previous topic i posted, but that one came to a bit of a dead end. Here is the code that i have so far:
    import java.io.*;
    import java.util.*;
    class SearchReplaceApp
         public static InputStreamReader input =
         new InputStreamReader(System.in);
         public static BufferedReader keyboardInput =
         new BufferedReader(input);
         public static void main(String[] args) throws IOException
         FileReader file = new FileReader(args[0]);
         BufferedReader MyFile = new BufferedReader(file);
              StringTokenizer TokenizeMe;
              int NumberOfTokens = 0;
              int NumberOfWords = 0;
         TokenizeMe = new StringTokenizer(MyFile.readLine());
         NumberOfTokens = TokenizeMe.countTokens();
         while (NumberOfTokens != 0)
              for (int WordsInLine=1; WordsInLine<=NumberOfTokens;
                        WordsInLine++)
                   System.out.print(TokenizeMe.nextToken()+" ");
              System.out.println();
              NumberOfWords += NumberOfTokens;
              String line = MyFile.readLine();
              if (line==null) break;
              TokenizeMe = new StringTokenizer(line);
              NumberOfTokens = TokenizeMe.countTokens();
              String findWord;
              String replaceWord;
              System.out.println ("Search for?:");
              findWord = keyboardInput.readLine();
              System.out.println("Replace With?:");
              replaceWord = keyboardInput.readLine();
              if (line.equals(findWord)) {               
              line = replaceWord;
         System.out.println("\nThis file contains " + NumberOfWords + " words");
         MyFile.close();
         }The problem is that it asks to search for a word after it has read each line of the file to the screen, instead of just asking when it has read in the whole file, which is what i want it to do. can anyone help me with this?
    I think the problem lies in the part :
              String findWord;
              String replaceWord;
              System.out.println ("Search for?:");
              findWord = keyboardInput.readLine();
              System.out.println("Replace With?:");
              replaceWord = keyboardInput.readLine();
              if (line.equals(findWord)) {               
              line = replaceWord;
    I would also like the program to display the dedited text after the replace has been completed e.g.
    java SearchReplaceApp test.txt
    This is a test
    This is a test
    This is a Test
    This is a Test
    This file contains 16 words
    Search for?: test
    Replace with?: Test
    This is a Test
    This is a Test
    This is a Test
    This is a Test
    Search for?:
    etc............................
    Any help at all would be appreaciated as im getting a bit frustated with this program and also my own lack of knowledge.
    Thanks
    Max

    Hi,
    sorri for that code which sent. here's is the correct code
    import java.io.*;
    import java.util.*;
    class SearchReplaceApp
    public static InputStreamReader input = new InputStreamReader(System.in);
    public static BufferedReader keyboardInput = new BufferedReader(input);
    public static void main(String[] args) throws IOException
    FileReader file = new FileReader(args[0]);
    BufferedReader MyFile = new BufferedReader(file);
    StringTokenizer TokenizeMe;
    int NumberOfTokens = 0;
    int NumberOfWords = 0;
    String line = MyFile.readLine();
    String completeText = "";
    Vector strVec = new Vector();
    while(line!=null)
    completeText+="\r\n";
    StringTokenizer tokenizeLine = new StringTokenizer(line);
    NumberOfWords+=tokenizeLine.countTokens();
    completeText +=line;strVec.add(line);
    line = MyFile.readLine();
    MyFile.close();
    System.out.println(completeText);
    System.out.println("This file contains"+NumberOfWords+ "words");
    String findWord="";
    String replaceWord;
    String resultStr = "\r\n";
    for ( ;;)
    System.out.println ("Search for?:");
    System.out.println("Please enter quit for quit:");
    findWord = keyboardInput.readLine();
    if(findWord.equals("quit")) break;
    //While findWord is not =null do.......
    System.out.println("Replace With?:");
    replaceWord = keyboardInput.readLine();
    for(int i=0;i<strVec.size();i++)
    String str = (String)strVec.get(i);
    TokenizeMe = new StringTokenizer(str);
    while ( TokenizeMe.hasMoreTokens())
    String token = TokenizeMe.nextToken();
    if (token.trim().equals(findWord.trim()))
    token = replaceWord; resultStr+=" " +token;
    else{resultStr+=" "+token;}}resultStr+="\r\n";
    System.out.println("COMPLETE TEXT AFTER REPLACE IS "+resultStr);
    //Save changes back to original file
    String str = resultStr;
    FileWriter newFile = new FileWriter(args[0]);
    PrintWriter fw = new PrintWriter(newFile);
    char[] ch = new char[str.length()];
    str.getChars(0,str.length(),ch,0);
    fw.write(ch);
    fw.flush();
    fw.close();
    hope this solves your problem.
    shyam

Maybe you are looking for