Results 1 to 3 of 3
  1. #1
    Join Date
    Dec 2003
    Posts
    78

    Question Unanswered: how to connect to a database with stored procedure

    hello,i have a question that may seem odd.
    Is it possible to connect to a database in another server using stored procedures in DB2UDB??If possible, how should the code look like?
    The stored procedure is SQL stored procedure,we're using stored procedure builder.

    For example, we are running a stored procedure and in the procedure,we 're connecting to a database and doing select statements.

    thanks..

  2. #2
    Join Date
    Aug 2001
    Location
    UK
    Posts
    4,650

    Re: how to connect to a database with stored procedure

    AFAIK, you cannot CONNECT from within a proc ..

    http://publib.boulder.ibm.com/infoce...n/r0007249.htm



    Originally posted by shedb
    hello,i have a question that may seem odd.
    Is it possible to connect to a database in another server using stored procedures in DB2UDB??If possible, how should the code look like?
    The stored procedure is SQL stored procedure,we're using stored procedure builder.

    For example, we are running a stored procedure and in the procedure,we 're connecting to a database and doing select statements.

    thanks..
    Visit the new-look IDUG Website , register to gain access to the excellent content.

  3. #3
    Join Date
    Jan 2004
    Location
    Tallahassee, FL, USA
    Posts
    96
    You can not connect to other database from stored procedure, but to accesss other database table in stored procedure can be done , by creating nick from other database tables or objects.


    this nick name concepts same as DBlink in Oracle

    to create nick name , you need to do 3 things

    1 > create wrapper
    2 > create server ( here you need to specify remote node , DB name)
    3 > create nick names from remote database

    use control center that will helps a lot

    for more info refer replication or SQL reference Manual

    then you access those nick names in your stored procedure
    Hope this may helps


    --Lekharaju Ennam

Posting Permissions

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