Page 1 of 2 12 LastLast
Results 1 to 15 of 19
  1. #1
    Join Date
    Feb 2012
    Posts
    18

    Post Unanswered: Reading from the database

    Hello,

    I am new to DB2. Wanted to read each row by row and verify the data. I am using vb.net as front end.

    How to read data from db2 row by row in the front end.

    Thanks in advance.

    Asaad

  2. #2
    Join Date
    Sep 2004
    Location
    Belgium
    Posts
    1,126
    Quote Originally Posted by asaadbinshams View Post
    How to read data from db2 row by row in the front end.
    Try using a cursor.
    That way, you will be able to fetch row-by-row from your front-end.
    --_Peter Vanroose,
    __IBM Certified Database Administrator, DB2 9 for z/OS
    __IBM Certified Application Developer
    __ABIS Training and Consulting
    __http://www.abis.be/

  3. #3
    Join Date
    Feb 2012
    Posts
    18

    Post

    Quote Originally Posted by Peter.Vanroose View Post
    Try using a cursor.
    That way, you will be able to fetch row-by-row from your front-end.
    Hi Peter,

    Can you please be more elaborative. Also can you please say how to write a particular IP address into the database as the user logs in. I have the code to capture the IP address of the user.

    Thanks in advance.

    Asaad

  4. #4
    Join Date
    Sep 2004
    Location
    Belgium
    Posts
    1,126
    Sorry, but I cannot be more specific at this point: I've never used VB.net so I can only be of any help in 100% DB2 matters.
    If you post the VB.net code which you have right now, I could maybe suggest some modifications to make it do what you want.
    --_Peter Vanroose,
    __IBM Certified Database Administrator, DB2 9 for z/OS
    __IBM Certified Application Developer
    __ABIS Training and Consulting
    __http://www.abis.be/

  5. #5
    Join Date
    Jan 2007
    Location
    Jena, Germany
    Posts
    2,721
    Using cursors is standard SQL stuff and not specific to DB2. So whatever the mechanism is in VB.net, it should be applicable 1:1 for DB2.

    As for the IP address stuff: you can use the CONNECT_PROC in DB2 (assuming you have DB2 LUW 9.7): IBM DB2 9.7 for Linux, UNIX and Windows Information Center Then you can use the APPLICATION_ID() function and extract the IP address from that.
    Knut Stolze
    IBM DB2 Analytics Accelerator
    IBM Germany Research & Development

  6. #6
    Join Date
    Jan 2012
    Posts
    3

    You need to use the insert or update statement

    Hello,

    I think you need to use insert or update statement ( dependent on this data which going to be getting into database is new or just want to update some column.)

    And the sql statement (DML) which you use for microsoft sql server, you need to use same over here.

  7. #7
    Join Date
    Feb 2012
    Posts
    18

    Post

    Quote Originally Posted by dbawork View Post
    Hello,

    I think you need to use insert or update statement ( dependent on this data which going to be getting into database is new or just want to update some column.)

    And the sql statement (DML) which you use for microsoft sql server, you need to use same over here.
    Hi,

    Thanks for your reply. I inserted the IP addresses into the database. How do I check indivisual ip address against the one that I have.

    Please provide code.

    Thanks in advance.

    Asaad

  8. #8
    Join Date
    Jan 2007
    Location
    Jena, Germany
    Posts
    2,721
    If you want to know where to get the IP address from, refer to my prior post. As for the comparison, it depends on how you stored the address. Maybe a simply string comparison will do.
    Knut Stolze
    IBM DB2 Analytics Accelerator
    IBM Germany Research & Development

  9. #9
    Join Date
    Feb 2012
    Posts
    18

    Post

    Quote Originally Posted by stolze View Post
    If you want to know where to get the IP address from, refer to my prior post. As for the comparison, it depends on how you stored the address. Maybe a simply string comparison will do.
    Hi stolze,

    Thanks for your reply. But I would like to know "How to read IP ADDRESSES one by one from the database.?" What SQL statement should I use?
    Please do specify in detail.

    Thanks in advance.

    Asaad

  10. #10
    Join Date
    Feb 2008
    Location
    Japan
    Posts
    3,483
    Quote Originally Posted by asaadbinshams View Post
    ...

    ... But I would like to know "How to read IP ADDRESSES one by one from the database.?" What SQL statement should I use?

    ...
    Simple SELECT statement for the table would be enough.


    I want to know more concrete and detailed your requirements.
    Quote Originally Posted by asaadbinshams View Post
    Hello,

    I am new to DB2. Wanted to read each row by row and verify the data. I am using vb.net as front end.

    How to read data from db2 row by row in the front end.

    Thanks in advance.

    Asaad

    Quote Originally Posted by asaadbinshams View Post
    Hi,

    Thanks for your reply. I inserted the IP addresses into the database. How do I check indivisual ip address against the one that I have.

    Please provide code.

    Thanks in advance.

    Asaad
    From those your posts, I guessed that ...
    (1) You already inserted IP addresses into a column in a table.

    (2) You have an IP address and want to check it with IP addresses in a table.


    If my guesses were right, my questions are ...
    (1) Whats are the table name and the column name?

    (2) What verifications/checks do you want to do?
    For example:
    (2-1) Equal or not to an IP address which you have?

    (3) What result do you want after checking?
    For example:
    (3-1) List all IP addressed which didn't pass the check, with other data of the rows.
    (3-2) List matched IP addresses with other data of the rows.

    or others ...

  11. #11
    Join Date
    Feb 2012
    Posts
    18

    Post

    Quote Originally Posted by stolze View Post
    If you want to know where to get the IP address from, refer to my prior post. As for the comparison, it depends on how you stored the address. Maybe a simply string comparison will do.
    Hi stolze,

    Thanks for your reply. But I would like to know "How to read IP ADDRESSES one by one from the database.?" What SQL statement should I use?
    Please do specify in detail.

    Thanks in advance.

    Asaad

  12. #12
    Join Date
    Feb 2012
    Posts
    18

    Post

    Quote Originally Posted by tonkuma View Post
    Simple SELECT statement for the table would be enough.


    I want to know more concrete and detailed your requirements.





    From those your posts, I guessed that ...
    (1) You already inserted IP addresses into a column in a table.

    (2) You have an IP address and want to check it with IP addresses in a table.


    If my guesses were right, my questions are ...
    (1) Whats are the table name and the column name?

    (2) What verifications/checks do you want to do?
    For example:
    (2-1) Equal or not to an IP address which you have?

    (3) What result do you want after checking?
    For example:
    (3-1) List all IP addressed which didn't pass the check, with other data of the rows.
    (3-2) List matched IP addresses with other data of the rows.

    or others ...

    Hi,

    My table name is DETAIL and the column name is IP ADDRESS.

    I want a correct match fromthe IP ADDRESSES already in the list(table). If the IP addressis not in the list(table), then display "UNAUTHENTIC USER"
    and allow authentic IP address(match from the list(table)) to access the application.

    Thanks in advance.

    Asaad

  13. #13
    Join Date
    Jan 2007
    Location
    Jena, Germany
    Posts
    2,721
    You didn't answer the question how you store the IP addresses. What's the data type of the column? Do you do some kind of normalization, i.e. convert "001.002.003.004" to "1.2.3.4"? Or is it binary data?

    As for reading the IP addresses from a table, you simply select the column from the table and fetch the values. Nothing special about it. Or are you concerned with getting the IP address for the current connection and comparing it with the values stored in this table?
    Knut Stolze
    IBM DB2 Analytics Accelerator
    IBM Germany Research & Development

  14. #14
    Join Date
    Feb 2012
    Posts
    18

    Post

    Quote Originally Posted by stolze View Post
    You didn't answer the question how you store the IP addresses. What's the data type of the column? Do you do some kind of normalization, i.e. convert "001.002.003.004" to "1.2.3.4"? Or is it binary data?

    As for reading the IP addresses from a table, you simply select the column from the table and fetch the values. Nothing special about it. Or are you concerned with getting the IP address for the current connection and comparing it with the values stored in this table?

    Hi,

    Thanks for your interest in the question and reply. I have stored the IP addresses as is, i.e 001.002.003.004. I am able to get the IP address of the current connection. But I am facing problem in compairing it with the values stored in the table.
    How to do a row by row comparison in DB2. Please do help.

    Thanks in advance.

    Asaad

  15. #15
    Join Date
    Aug 2001
    Location
    UK
    Posts
    4,650
    Code:
    select * from table-name where ip-address-col-name='001.002.003.004'
    will list all rows that with the said column value.
    Visit the new-look IDUG Website , register to gain access to the excellent content.

Posting Permissions

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