1. Forum Rules (PLEASE CLICK HERE TO READ BEFORE POSTING) Click the link to access ADSM.ORG Acceptable Use Policy and forum rules which should be observed when using this website. Violators may be banned from this website. This message will disappear after you have made at least 12 posts. Thank you for your cooperation.

Problem with direct DB2 SQL queries

Discussion in 'Scripting' started by Saroz, Aug 2, 2011.

  1. Saroz

    Saroz New Member

    Joined:
    Aug 2, 2011
    Messages:
    3
    Likes Received:
    0
    Hi,

    I want to build an API to pull information from TSM.
    I plan on using PHP and the DB2 extension to access the TSM DB2 database directly.

    I've run into some odd problems though.

    When I do some queries, columns containing the name of nodes, appear as NULL. Consider the following:

    PHP:
    $sql db2_exec($db"select * from TSMDB1.BACKUPS")
    var_dump(db2_fetch_assoc($sql));
    This returns:

    Code:
    array(12) {
      ["NODE_NAME"]=>
      NULL
      ["FILESPACE_NAME"]=>
      string(14) "2F54534D444231"
      ["FILESPACE_ID"]=>
      int(888)
      ["STATE"]=>
      string(14) "ACTIVE_VERSION"
      ["TYPE"]=>
      string(4) "FILE"
      ["HL_NAME"]=>
      string(20) "5C4E4F4445303030305C"
      ["LL_NAME"]=>
      string(56) "46554C4C5F4241434B55502E32303131303830313034303032392E32"
      ["OBJECT_ID"]=>
      string(5) "10268"
      ["BACKUP_DATE"]=>
      string(26) "2011-08-01 04:00:33.000000"
      ["DEACTIVATE_DATE"]=>
      NULL
      ["OWNER"]=>
      string(0) ""
      ["CLASS_NAME"]=>
      string(7) "DEFAULT"
    }
    
    This happens on all tables, I simply cannot get the information about the node, out of the DB2 database.

    Anyone know why this happens, and also if there are any ressources relating to TSM DB2 queries out there? Or maybe there's a better way to achieve my goal?

    Thanks
     
  2.  
  3. rore

    rore Senior Member

    Joined:
    Nov 27, 2005
    Messages:
    642
    Likes Received:
    15
    Occupation:
    SysAdmin
    Location:
    Montreal, CA
    What happens when you run the query directly on a bash shell (db2 "select .......")?. Make sure you login with the instance owner and load the environment variables.
     
  4. Saroz

    Saroz New Member

    Joined:
    Aug 2, 2011
    Messages:
    3
    Likes Received:
    0
    Sorry, I forgot to mention this is a remote DB2 server. I'm connecting to it using db2_connect() and a DSN - from an entirely different server.

    If I run the query directly on the TSM server (windows), with Eclipse, it works fine - all values are returned correctly.
     
  5. gimlet

    gimlet New Member

    Joined:
    Apr 25, 2008
    Messages:
    154
    Likes Received:
    4
    Occupation:
    Infrastructure Monkey
    Location:
    St. Louis, Missouri
    I vaguely remember looking at this a while ago and realizing that there wasn't anything listening on 523/tcp. Not sure if there is a way to enable that in the DB2 that is included.
     
  6. Saroz

    Saroz New Member

    Joined:
    Aug 2, 2011
    Messages:
    3
    Likes Received:
    0
    It's running on port 50000 and the connection works fine, since query results are returned - just returned as NULL.

    Has noone else really every tried to connect to the db2 instance directly? What do people do when they want to query data from TSM in a web-API?
     
  7. gimlet

    gimlet New Member

    Joined:
    Apr 25, 2008
    Messages:
    154
    Likes Received:
    4
    Occupation:
    Infrastructure Monkey
    Location:
    St. Louis, Missouri
    Did you enable TCP connections? They don't seem to be enabled on my instance.
     
: db2, php, sql

Share This Page