on 04-10-2012 10:15 AM
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
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
84 | |
10 | |
10 | |
10 | |
7 | |
6 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.