Results 1 to 6 of 6

Thread: console output

  1. #1
    Join Date
    Sep 2003
    Posts
    8

    Unanswered: console output

    I need to write to the console from a DB2 stored proc, upon calling the stored from the console. Anybody who knows what is the command to be used?
    Thx.

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

    Re: console output

    As far as I know there is no db2 feature to do this ...

    You should consider a combination of your Stored Proc language and Operating System features to achive this

    Cheers
    Sathyaram

    Originally posted by java guy
    I need to write to the console from a DB2 stored proc, upon calling the stored from the console. Anybody who knows what is the command to be used?
    Thx.
    Visit the new-look IDUG Website , register to gain access to the excellent content.

  3. #3
    Join Date
    Sep 2003
    Posts
    8

    Re: console output

    By console I meant any client app that allows me to query the DB server. For instance, to run sql scripts I am using 'Run Sql Query' app that is part of the iSeries Navigator. I know I can see messages sent from the DB server, in the event of an syntax error for instance. I was wondering if there a way to log messages from inside the stored proc.
    Last edited by java guy; 09-17-03 at 19:13.

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

    Re: console output

    As I mentioned in the previous post, AFAIK, DB2 does not provide a feature to write to a file ...

    But this is not hard to achieve :

    1) If you are writing a stored proc using a prog lang like Java, COBOL, C etc, you can use these programs features to write to a file

    2) If you are using a SQL Stored Procedure, you can write a UDF inn one of the above languages which takes the message as the argument and writes that to the file ...
    So you can say , select writetofile('Entering Step1') from sysibm.systables ...


    HTH

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

  5. #5
    Join Date
    Sep 2003
    Posts
    8

    Re: console output

    Right. Check this out:

    "You can view the result set for a stored procedure in Run SQL Scripts by typing in a CALL statement as an SQL statement. The results are available in the results window just like a normal query. If you have multiple results sets, they will each be represented by an additional results tab. Additionally, you can view the output parameters in the Messages tab.
    "
    So, if I am specifying the message, variable, etc that I want to see as an output param I can see it after the stored proc is doen running. As a downside, if there are many variables to monitor, the list of param can become a pain to deal with, but it is a decent compromise considering the outcome.
    Thx.

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

    Re: console output

    If you would want it just for monitoring and not as a prod requirement, the best is to use the Stored Procedure Builder(V7) or Development Centre (V8)

    If you do not want to use the stored procedure builder, but still want to monitor , you can use a dummy select or Values statement and return it as a result set ...

    In this manner, your dev procedure and your prod procedure will be as similar as possible except the retunring of the resultsets ...

    HTH

    Sathyaram
    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
  •