Quantcast
Channel: SCN: Message List
Viewing all articles
Browse latest Browse all 9212

How do I use table types as variables in procedures?

$
0
0

Hi,

 

I'm doing a query with ce_functions and my table structure changes during the processing.
That's why i created two table types

 

create type tt_bdd as table (          ProfileId VarChar (100),          DependencyId VarChar (100),          Dependency VarChar (255),          TrueDepId VarChar (100),          FalseDepId VarChar (100)
)

create type out_bdd as table (
          DependencyId_Count integer,          Dependency VarChar (255),          TrueDepId VarChar (100),          FalseDepId VarChar (100)
)

 

The first table type has the format of the Database I'm querying from and the second one is my output table type.

 

In my Procedure code I declare a temp table temp_bdd for the first few ce_queries and use the output  parameter bp_bdd for the last query.

CREATE PROCEDURE get_bdd_by_profileId_CE (          in profileId integer,          out bp_bdd out_bdd
)            LANGUAGE SQLSCRIPT          SQL SECURITY INVOKER           --DEFAULT SCHEMA <schema>          READS SQL DATA AS      
BEGIN
--*****************************           Write your procedure logic 
--*****************************/
DECLARE temp_bdd tt_bdd;
--QUERY DB */          temp_bdd = CE_COLUMN_TABLE("D060478"."tmp.d060478.helloWorld.data::obdd",                    ["ProfileId","DependencyId","Dependency","TrueDepId","FalseDepId"]);

--WHERE ProfileId = IP_ProfileId */
          temp_bdd = CE_PROJECTION(:temp_bdd,                    ["ProfileId","DependencyId","Dependency","TrueDepId","FalseDepId"],                    '"ProfileId" = :profileId' );

-- Group Similar Dependency Conditions, TrueDepId and FalseDepId for reduction */
          bp_bdd = CE_AGGREGATION(:temp_bdd,[COUNT("DependencyId") AS "DependencyId_Count"],                    ["Dependency","TrueDepId","FalseDepId"]);
END;

 

unfortunately I get the following error message when I'm activating my code.

ERROR      /helloWorld/models/get_bdd_by_profileId_CE.procedure

           Repository: Internal error during statement execution, please see the database error traces for additional details;error executing statement; invalid use of table variable: TEMP_BDD: line 6 col 18 (at pos 385) at ptime/query/checker/proc_check_decl.cc:113

 

can someone tell me how to correctly use the table variable?

 

When I add declaration of temp_bdd as a second out parameter the code compiles and works correctly.

 

Thanks and kind regards, 

Stefan


Viewing all articles
Browse latest Browse all 9212

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>