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

911: Does the SAP HANA ODBC driver support passing a table type to a stored procedure?

$
0
0

I’m building a proof-of-concept C++ application that uses ODBC to create an Order with line items where I’m using a table type to hold the line items and then pass the type to a stored procedure along with an customer id.

Unfortunately, I’m getting the following ODBC driver error message when I attempt to make the call:


Error-Thread 1-[SAP AG][LIBODBCHDB DLL][HDBODBC] General error;7 feature not supported: Parameterized input table parameter is not allowed: Line 1 col 30 (at pos 29) [SAP AG][LIBODBCHDB DLL][HDBODBC] General error;-10210 Invalid command state (No prepared SQL command)

 

Does the HANA ODBC driver support passing a table type? If so, is there a trick to it. If not, do you have suggestions for a workaround?

 

Here is some of the relevant SAP HANA code that makes up the app.

-- Define the type for calling usp_InsertOrder procedure

CREATE TYPE "DBO"."INMEMDBTVPORDERS" AS TABLE 

(

"SEQ" INT CS_INT NOT NULL,

"PR_ID" BIGINT CS_FIXED NOT NULL,

"PR_QTY" INT CS_INT

);

 

-- usp_InsertOrder procedure using a TVP

CREATE PROCEDURE dbo.usp_InsertOrder

(IN C_ID bigint,

IN ORDERS dbo.InMemDBTVPOrders)

AS

BEGIN

    DECLARE CurrentRow integer;

     DECLARE RowsToProcess integer;

     DECLARE Pr_Id              bigint;

     DECLARE Pr_Qty integer;

    DECLARE Order_Id           bigint;

    DECLARE Pr_Price           decimal(9,2);

    DECLARE TotalPrice         decimal(12,2);

    DECLARE CurrentDate        timestamp;

   

    CurrentDate := CURRENT_TIMESTAMP;

    TotalPrice := 0;

 

    --insert an Order record to claim the O_ID

    INSERT INTO dbo.Orders (O_ID, O_C_ID, O_TOTAL, O_DTS) VALUES (dbo.ORDERS_ID.NEXTVAL, :C_ID, 0, :CurrentDate);

   

    -- get the inserted order id 

     SELECT dbo.ORDERS_ID.CURRVAL into Order_ID FROM DUMMY;

    

    -- now process the order lines

    INSERT INTO dbo.OrderLines

        SELECT  :Order_ID,

                O.SEQ,

                O.PR_ID,

                O.PR_QTY,

                P.PR_PRICE,

:CurrentDate

        FROM    :ORDERS O INNER JOIN dbo.Products P ON (O.PR_ID = P.PR_ID);

 

    --SELECT  @TotalPrice = ISNULL(SUM(OL_PRICE),0)

     SELECT Ifnull(SUM(OL_PRICE),0) into TotalPrice

    FROM    dbo.OrderLines

    WHERE   OL_O_ID = :order_id;

         

    -- now update the order with the total price

    UPDATE  dbo.Orders

    SET     O_TOTAL = :TotalPrice

    WHERE   O_ID = :Order_Id AND

            O_C_ID  = :C_ID;

 

    SELECT  :order_id,

            :C_ID,

            :TotalPrice

    FROM DUMMY;

 

END;

 

Here is the test code that we used to make sure the type passing works in HANA.

CREATE PROCEDURE dbo.Util_TestOrderInsert

(OUT tvp "DBO"."INMEMDBTVPORDERS")

LANGUAGE SQLSCRIPT

AS

BEGIN

     tvp = SELECT 1 AS "SEQ", 3678 AS "PR_ID", 100 AS "PR_QTY" FROM DUMMY;

     CALL dbo.usp_InsertOrder(3428, :tvp);

END;

 

I have a version of the C++ application that works fine with SQL Server and it’s table type, but when moving to HANA, this is the only call that fails.

Regards,

Bill


Viewing all articles
Browse latest Browse all 6412

Trending Articles



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