Quantcast
Channel: SCN : Discussion List - SAP HANA Developer Center
Viewing all articles
Browse latest Browse all 6412

Calling Stored Procedure With Input Parameter as Table Type

$
0
0

Hi Experts,

 

I have created a stored procedure to update a table as shown below

 

PROCEDURE "ABC"."ABC.ABC_PE.Procedure::Material_Master_Update" (   

                                                                                    IN new "ABC"."ABC.ABC_PE.Structure::MM_DIM",

                                                                                    OUT err "ABC"."ABC.ABC_PE.Structure::error"

                                                                                 )

    LANGUAGE SQLSCRIPT

    SQL SECURITY INVOKER AS

    --DEFAULT SCHEMA <default_schema_name>

    --READS SQL DATA AS

   

   

    CURSOR c_cur for

   

    SELECT BASE_YR_UNIT_COST,

           ICP_IDP_ADJUSTMNT,

           LIFO_CODE,

           MARKET_VAL

    FROM  :new;

   

    l_lifo           varchar(10);

    l_base           decimal(10,8);

    l_icp           decimal(10,8);

    l_market           decimal(10,8);

   

BEGIN

/*****************************

    Write your procedure logic

*****************************/

 

open c_cur;

 

    for r_var as c_cur do

   

 

    if l_lifo = ' ' then

   

        err = select 400 as http_status_code,

                     'Check LIFO CODE' error_message,

                     'value must be >= 1000' detail

              from dummy;

             

    else       

     

        UPDATE  "ABC"."ABC.ABC_PE.TABLES::MM_DIM_TABLE"

        SET     BASE_YR_UNIT_COST = l_base,

                ICP_IDP_ADJUSTMNT = l_icp,

                MARKET_VAL          = l_market

               

        WHERE   LIFO_CODE = l_lifo;

       

    end if;   

   

    end for;

   

close c_cur;   

 

END;

 

Table Type Definition:

 

table.schemaName = "ABC";

table.columns =

 

    [

        {name="BASE_YR_UNIT_COST";         sqlType=DECIMAL;  precision = 10; scale = 8;},

        {name="ICP_IDP_ADJUSTMNT";         sqlType=DECIMAL;  precision = 10; scale = 8;},

        {name="LIFO_CODE";                    sqlType=VARCHAR;  length=10;},

        {name="MARKET_VAL";                sqlType=DECIMAL;  precision = 25; scale = 8;}

       

    ];

 

I would like to know how to call the stored procedure in SQL console in HANA


Viewing all articles
Browse latest Browse all 6412

Trending Articles



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