Skip to Content
author's profile photo Former Member
Former Member

HANA Procedure and Table Type Clarifications

Hi All

I have some queries related to Procedures and Table Types please share your ideas on the below.

1.How to feed Table Types with data , I tried to feed with INSERT statement it says feature not supported.

2.Can we define primary key for columns involved in table type.

3.In procedures when I try to use CALL ins_msg_proc , it throws syntax error, how can I write output to the screen.

4.While writing procedures we have a statement with RESULT VIEW XXXX as so , if we have defined any out parameters the output will be stored in the XXXX view. where is this views present in databse, I serached it in SYS.VIEWS but no luck.

5.In a procedure we use some table type variables to store , are they restricted to the session ? if not where these objects are stored.

6.I tried to redirect the output of call procedure statement to store it in table as below.But it throws syntax error.

EMP_SUB = call emp_data(NULL);

7. When I try to insert data into table using procedure as below, it says feature not supported as it is read only procedure , is there any way or other type of procedure to write data to tables or database via procedures.

Please share your ideas on the above , these are the basics which I am trying to clarify.I tried hard to find the answers but could not .

Thanks

Santosh

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

3 Answers

  • Posted on Jan 11, 2014 at 04:10 AM

    Hi Santosh,

    1. Generaly we feed table types as tabular results in a procedure.
    2. Primary key not required for table types

    3. ins_msg_proc is not SAP supplied function/proc. We need to define it. Here is the example and can be modified as per your convenience:

    CREATE TABLE SCHEMANAME.message_box (p_msg VARCHAR(200), tstamp TIMESTAMP);
    CREATE PROCEDURE schemaname.ins_msg_proc (p_msg VARCHAR(200))
    LANGUAGE SQLSCRIPT AS
    BEGIN
    INSERT INTO message_box VALUES (:p_msg, CURRENT_TIMESTAMP);
    END;

    To view the content, use below statement after running the proc.
    select * from SCHEMANAME.message_box;

    4.If proc is defined "WITH RESULT VIEW schemaname.viewname AS" clause, you can find the results of your procedure in column views(ProcView) of the schema (schemaname).

    ex:
    CREATE PROCEDURE schemaname.Proc1(IN id INT, OUT o1 CUSTOMER)
    LANGUAGE SQLSCRIPT
    READS SQL DATA
    WITH RESULT VIEW schemaname.ProcView AS
    BEGIN o1 = SELECT * FROM schemaname.tablename WHERE columnname = ......;
    END;

    5. I think table type variable values exist only during run time. Not really sure about this.

    6.To redirect the output of call procedure, is nothing but using "WITH RESULT VIEW schemaname.viewname AS" and can find this in column view of schema.

    7.If you want to insert data in a procedure, do not use READS SQL DATA clause. If you use this then becomes read only.

    ex:
    CREATE PROCEDURE schemaname.Proc2(IN id INT, OUT o1 CUSTOMER)
    LANGUAGE SQLSCRIPT AS
    BEGIN
    write your insert stateement.........
    END;

    Regards

    Raj

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Apr 10, 2012 at 04:04 PM

    Santosh:

    Please download and review the SQL script and SQL reference guide. You will find most of your answers in the 2 docs.

    Below are my brief responses to your questions based on my experience with SAP HANA:

    1.How to feed Table Types with data , I tried to feed with INSERT statement it says feature not supported - You can not insert into table type. You define table types outside the procedure using SQL and then use the table types in the procedure as in or out parameter.

    Will answer othere questions shortly. Hope this helps.

    Rama

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member

      Hi Rama

      I have the docs mentioned , but I could not find the clear answers ,some of them I tried several ways but could find the answers for few. I will post my views at the end ,but if people share their thoughts , it would be more helpful.

      Awaiting feedback.

      Thanks

      Santosh

  • author's profile photo Former Member
    Former Member
    Posted on Jan 10, 2014 at 03:11 PM

    Hello Santosh,

    If you have figured out answers to your questions, please update the answers here and close the thread. Your answers might help someone in future, like me 😊

    Thanks

    Mesh

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.