Results 1 to 13 of 13
Like Tree1Likes
  • 1 Post By Tolls

Thread: How to get Record Names?

  1. #1
    sandeep43 is offline Member
    Join Date
    May 2011
    Posts
    97
    Rep Power
    0

    Default How to get Record Names?

    Hi

    My doubt is when i pass a sql string as input, i should get all record names present in the sql string passed, is there any logic that we can do to get this, please help me out


    Regards
    Sandeep

  2. #2
    DarrylBurke's Avatar
    DarrylBurke is offline Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,189
    Rep Power
    19

    Default

    Recommended reading: How to ask questions the smart way

    db

  3. #3
    sandeep43 is offline Member
    Join Date
    May 2011
    Posts
    97
    Rep Power
    0

    Default

    Hi Darryl

    what is wrong in my question most important is how to get that solution man, always you bang on English, you cant expect everyone to be like you, i am weak at English, your are a moderator man you should understand our problem and try giving solution and then recommend us to read, not just always give us link how to improve English and stuff. I am dam sure i have logged into java-forums not English tutorials website.

    Regards
    Sandeep

  4. #4
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    11,450
    Rep Power
    18

    Default

    I think Darryl is pointing out that your question, as it stands, makes no sense.
    What are you trying to do?
    Do you have some code (or at least pseudo code) to show what it is you are trying to figure out?
    DarrylBurke likes this.

  5. #5
    sandeep43 is offline Member
    Join Date
    May 2011
    Posts
    97
    Rep Power
    0

    Default

    Hi tolls,
    i thought you will understand me, because you were the one who usually answer my question more appropriately.

    Question is simple tolls, i will fetch sql statements for views present in database, later i want to pass these fetched sql statements one by one such that i have to get TableNames and ViewNames present in fetched sql Statement.

    What logic can be employed?

    Sandeep

  6. #6
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    11,450
    Rep Power
    18

    Default

    What do you mean by "fetched SQL statements"?
    Do you mean the result sets?

  7. #7
    sandeep43 is offline Member
    Join Date
    May 2011
    Posts
    97
    Rep Power
    0

    Default

    Hi Tolls

    Java Code:
    select OBJECT_DEFINITION(OBJECT_ID('ViewName')) AS TABLE_NAME
    if you execute this sql whatever it retrieves is Fetched Sql Statement for that view name.

    Sandeep

  8. #8
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    11,450
    Rep Power
    18

    Default

    It's a resultset (in Java).
    Or fetched rows (in most DBs).

    Is that what you want to know?
    What to do with the ResultSet? That depends on what you want to do with that data.

  9. #9
    sandeep43 is offline Member
    Join Date
    May 2011
    Posts
    97
    Rep Power
    0

    Default

    There is nothing to do with ResultSet, i wanted to know how to get TableNames and ViewNames from that Sql Fetched Statements

    Sandeep

  10. #10
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    11,450
    Rep Power
    18

    Default

    No, it's a ResultSet.
    Whether the rows in that are simply a list of table names, or some STRUCT or other, is irrelevant.
    What is the Type returned by OBJECT_DEFINITION?
    What DB are we on here?

  11. #11
    sandeep43 is offline Member
    Join Date
    May 2011
    Posts
    97
    Rep Power
    0

    Default

    we are using MS sql server2005, it returns of type varchar

    Sandeep

  12. #12
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    11,450
    Rep Power
    18

    Default

    So what's wrong with:
    Java Code:
    ResultSet rs = yourSQL.execute();
    while (rs.next) {
        System.out.println(rs.getString(1));
    }
    ?
    What you do in the loop is entirely up to you. That there will print out all the "TABLENAMES" returned by your query.

  13. #13
    sandeep43 is offline Member
    Join Date
    May 2011
    Posts
    97
    Rep Power
    0

    Default

    HI tolls,

    I got it, i found better logic, thnks man for helping

    Sandeep

Similar Threads

  1. Replies: 9
    Last Post: 07-09-2011, 07:15 PM
  2. name in a range of names
    By Evii0 in forum New To Java
    Replies: 2
    Last Post: 04-05-2011, 06:35 AM
  3. Set names utf8
    By initmax in forum JDBC
    Replies: 1
    Last Post: 11-22-2009, 10:29 AM
  4. Replies: 4
    Last Post: 10-02-2008, 10:05 PM
  5. how to get the names of the files
    By mary in forum Advanced Java
    Replies: 2
    Last Post: 08-05-2007, 04:01 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •