lightdb oracle模式支持sys

编程入门 行业动态 更新时间:2024-10-22 12:30:18

lightdb oracle<a href=https://www.elefans.com/category/jswz/34/1771241.html style=模式支持sys"/>

lightdb oracle模式支持sys

背景

在业务产品中,存在Oracle移植过来的函数以及存储过程。它们把sys_refcursor作为参数的类型。

LightDB 23.4版本对此进行了支持。

示例

准备环境

create database test_oracle with lightdb_syntax_compatible_type  oracle;
\c test_oracle

准备数据

create table customer_address
(ca_address_sk             integer               not null,ca_address_id             char(16)              not null,ca_street_number          char(10)                      ,ca_street_name            varchar(60)                   ,ca_street_type            char(15)                      ,ca_suite_number           char(10)                      ,ca_city                   varchar(60)                   ,ca_county                 varchar(30)                   ,ca_state                  char(2)                       ,ca_zip                    char(10)                      ,ca_country                varchar(20)                   ,ca_gmt_offset             decimal(5,2)                  ,ca_location_type          char(20)                      ,primary key (ca_address_sk)
);declarei_id                   integer := 1;address_id             char(16);street_number          char(10);street_name            varchar(60) ;street_type            char(15);suite_number           char(10);city                   varchar(60);county                 varchar(30);state                  char(2);zip                    char(10);country                varchar(20);gmt_offset             decimal(5,2);location_type          char(20);
begin-- insertaddress_id     := 'address_id';street_number  := '3588' ;street_name    := 'street_name';street_type    := 'street_type';suite_number   := '1';city           := 'Hang Zhou';county         := 'Bin Jiang';state          := 'CN';zip            := '000000';country        := 'China';gmt_offset     := 1.02;location_type  := 'location_type';INSERT INTO customer_address(ca_address_sk, ca_address_id, ca_street_number, ca_street_name, ca_street_type, ca_suite_number, ca_city, ca_county, ca_state, ca_zip, ca_country, ca_gmt_offset, ca_location_type)VALUES (i_id, address_id, street_number, street_name, street_type, suite_number, city, county, state, zip, country, gmt_offset, location_type);
END;
/

定义使用sys_refcursor的函数

CREATE OR REPLACE PROCEDURE getCustomerAddress(cur OUT sys_refcursor) IS
beginopen cur for select * from customer_address;
end;
/

调用

declaread   sys_refcursor;res  customer_address%rowtype;
begingetCustomerAddress(ad);loop FETCH ad INTO res;EXIT WHEN ad%NOTFOUND;dbms_output.put_line('ca_address_sk:' || res.ca_address_sk);dbms_output.put_line('ca_address_id:' || res.ca_address_id);dbms_output.put_line('ca_street_number:' || res.ca_street_number);dbms_output.put_line('ca_street_name:' || res.ca_street_name);dbms_output.put_line('ca_street_type:' || res.ca_street_type);dbms_output.put_line('ca_suite_number:' || res.ca_suite_number);dbms_output.put_line('ca_city:' || res.ca_city);dbms_output.put_line('ca_county:' || res.ca_county);         dbms_output.put_line('ca_state:' || res.ca_state);    dbms_output.put_line('ca_zip:' || res.ca_zip);    dbms_output.put_line('ca_country:' || res.ca_country);     dbms_output.put_line('ca_gmt_offset:' || res.ca_gmt_offset);   dbms_output.put_line('ca_location_type:' || res.ca_location_type);end loop;
end;
/

更多推荐

lightdb oracle模式支持sys

本文发布于:2023-11-15 21:31:33,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1606671.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:模式   lightdb   oracle   sys

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!