function of PPAs with custom type array and call __ function

Source: Internet
Author: User

PPAs is the Enterprisedb company's PostgreSQL database product Postgres Plus advised Server.

Here's a look at the example:

1
--Create a table
CREATE TABLE TABLE2
(COLUMN1 number (10,0),
COLUMN2 VARCHAR2 (20),
COLUMN3 VARCHAR2 (20),
PRIMARY KEY (COLUMN1)
);

2
--Create Type
Create or replace type T_type is Object (Column2 varchar2 (), Column3 varchar2 (20));

3
--Create a stored procedure
Create or Replace procedure P_table_test (example T_type ARRAY)
As
V_count int:=0;
Begin
Select Array_length (example,1) into V_count;
ForAll I in 1..v_count
Insert into table2 (COLUMN1,COLUMN2,COLUMN3)
VALUES (i, example[i].column2, example[i].column3);
End

4
--Calling a stored procedure
DECLARE
V_example T_type ARRAY;
BEGIN
V_example: = Array[t_type (' Meeting ', ' Lunch '), T_type (' Training ', ' presentation ')];
EXEC p_table_test (v_example);
End;

5
--Check the results
dbtest=# select * from Table2;
Column1 |   Column2 | Column3
---------+----------+--------------
1 | Meeting | Lunch
2 | Training | Presentation
(2 Line Records)

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.