cancel
Showing results for 
Search instead for 
Did you mean: 

HANA Procedure and Table Type Clarifications

Former Member
0 Kudos

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

Accepted Solutions (0)

Answers (3)

Answers (3)

rindia
Active Contributor
0 Kudos

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

Former Member
0 Kudos

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

rama_shankar3
Active Contributor
0 Kudos

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

 

Former Member
0 Kudos

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