stored-proceduresteradata

Display result of a variable in teradata stored procedure


I need to print results of variables in Teradata stored procedures, but print does not work in teradata, should I use the below method or please suggest the proper one: My code:

REPLACE PROCEDURE Name()
---some code goes here
BEGIN
      TRANSACTION;

      SET var1= var2+ 3;

      SET var3= var2;
      /* !!! PRINT var1*/
      /* !!! PRINT var3*/
end;
--some code here

I used the out in stored procedure declaration, suggest me another way to print the values of variable:

REPLACE PROCEDURE Name(out var1, out var3)

Solution

  • As long as there's only a single line of values has to be returned you can utilize OUT variables.

    For multiple lines you can use a Volatile Table where those lines are inserted and a final DYNAMIC RESULT SET returns them as an answer set.