0

How to create user defined function with declare temporary table in AS400?

I can't create a temporary table under parent procedure, because i'm using Parallel Jobs. So i need to create temporary table inside function only helps me.

Did anybody knows the solution, kindly update here friends.

Vivek Harry
  • 419
  • 3
  • 11
  • 25
  • What needs to be accomplished, for what purpose the temporary table would be created, is unstated. Per no mention, consider that a derived table expression [e.g. NTE or CTE] might be capable to achieve what is needed [but undescribed]; NB: derived tables are true-temporary objects, scoped to the query, rather than merely given the moniker of temporary like the GTT for which an actual permanent database file object is created [with all the overhead of any other persistent object]. – CRPence Sep 24 '16 at 17:17

1 Answers1

1

example of temporary table :

      DECLARE GLOBAL TEMPORARY TABLE nametemporarychoice AS ( 
      YOURQUERYHERE
      ) WITH DATA WITH REPLACE NOT LOGGED;

you can use your table like this:

     select * from qtemp.nametemporarychoice 

or like this:

     select * from session.nametemporarychoice 
Esperento57
  • 16,521
  • 3
  • 39
  • 45