dcsimg
DBAsupport.com Forums - Powered by vBulletin
Results 1 to 2 of 2

Thread: connecting using ODBC ...

  1. #1
    Join Date
    Jun 2001
    Posts
    5

    Question

    How to retrieve data from AS400 database using ODBC
    in form builder design of developer 2000?
    Assume that the database file locate in LIBJ44/DATFILE
    which has configured as ODBC data sourcename "as400".
    Any one can help me with it?
    Thanx a lot!!

  2. #2
    Join Date
    Oct 2001
    Location
    Hong Kong
    Posts
    7

    Wink

    user exec_sql package.

    conn := 'username/password@odbc:as400';
    sql_text := 'select col1 from lib.datafile';

    connHandle := EXEC_SQL.OPEN_CONNECTION(conn);
    cursNo := EXEC_SQL.OPEN_CURSOR(conHandle);
    EXEC_SQL.PARSE(conHandle, cursNo,sql_text);

    --Define the columns for the data to be returned into.
    EXEC_SQL.DEFINE_COLUMN(conHandle,cursNo,1,:bk1.data1,10);

    -- And execute it.
    rowsAffected := EXEC_SQL.EXECUTE(conHandle, cursNo);

    --fetch row from the result set.
    if exec_sql.fetch_rows(conHandle,cursNo) > 0 then
    exec_sql.column_value(conHandle,cursNo,1,:bk1.data1);
    end if;
    exec_sql.close_cursor(conHandle,cursNo);

    exec_sql.close_connection(conHandle);

    if no of records is more than one, you need to add the loop in the procedure to retrieve data...

    hope it helps


Posting Permissions

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


Click Here to Expand Forum to Full Width