Results 1 to 8 of 8
  1. #1
    Join Date
    May 2012
    Posts
    3

    Unanswered: Running Sql Select statments on DB2

    Hi,

    I need help in running SQL select statements on a DB2 database housed in a AIX machine,

    I am accessing the AIX machine remotely from my windows machine.

    I am not a database guy, and there is no one else to help.

    Firstly connecting to the database

    #db2 connect to <DBNAME>

    and paste the select statements onto the command prompt.

    #select * from <Table name1> select * from <Table name2> etc

    Thank you in advance.

  2. #2
    Join Date
    Jan 2009
    Location
    United Kingdom
    Posts
    77
    I usually use Putty to access an AIX. But you will need OpenSSL and OpenSSH on the AIX server. Once you're on , you can connect and run code
    Another option is via Telnet on the Putty.

  3. #3
    Join Date
    Jan 2007
    Location
    Jena, Germany
    Posts
    2,721
    Quote Originally Posted by Nishanth Rao View Post
    and paste the select statements onto the command prompt.

    #select * from <Table name1> select * from <Table name2> etc
    What you are doing here is to paste the SQL statement into the shell. This is not a DB2 shell, so the operating system has no idea what to do with it. Try this instead:
    Code:
    #db2 "select * from <Table name1> select * from <Table name2> etc"
    Note that any special characters like '*' or so will still be interpreted by the shell potentially. You may have to escape them. Another alternative is to use a DB2 shell:
    Code:
    #db2<enter>
    db2 => select * from <Table name1> select * from <Table name2> etc
    Knut Stolze
    IBM DB2 Analytics Accelerator
    IBM Germany Research & Development

  4. #4
    Join Date
    May 2012
    Posts
    3
    Jack,

    We use SecureCRT to connect to the AIX system. and able to login into the system

    Stolze,

    Thank you for the heads up on running the SQL statements, I will have to use the second option which you have mentioned as there is a Count (*) in the sql..

    #db2<enter>
    db2 => select .,.,.,.,Count(*),.,. from <Table name1> select * from <Table name2> etc

    But unfortunately I am not able to check this out right now as I am not able to connect to the database.. Will get back once I get clarification form the Network access people.

    Thank you,
    Nishanth

  5. #5
    Join Date
    May 2012
    Posts
    3
    To clarify
    When I type the db2 connect <DBNAME> I am getting a message
    ksh: db2: not found

    Waiting on that from the network admins.

    Thank you,
    Nishanth

  6. #6
    Join Date
    Jan 2007
    Location
    Jena, Germany
    Posts
    2,721
    You have some sort of problem with your setup. I recommend that you grab the DB2 manual and work through the "Getting Started" sections.
    Knut Stolze
    IBM DB2 Analytics Accelerator
    IBM Germany Research & Development

  7. #7
    Join Date
    Apr 2012
    Posts
    1,034
    Provided Answers: 18
    Your post says "there is no one else to help" and "I' am not a database guy".
    It is unwise to do it by yourself when you don't know what you are doing. When your colleagues are available, anyone who already has DB2 access will show you what to do, but remember that it is posisble that you might need to ask a DBA to ensure that you are permitted to connect to the database if it is a secured database.

  8. #8
    Join Date
    Apr 2012
    Posts
    7
    Probably you don't have db2 profile loaded. Try to issue
    . /home/db_instance_name/.profile where db_instance_name is your db instance name from console.

Tags for this Thread

Posting Permissions

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