当前位置: 首页 > news >正文

Lightdb 23.3 plorasql函数支持DML

开篇立意

oracle在函数中使用dml语句时,有两者情况。即:(1)直接使用select调用该函数;(2)在匿名块中调用该函数。
针对第一种情况我们测试一下
简单的函数:

create table nested_tab(id int, name varchar2(100), job varchar2(100), age int);
insert into nested_tab values (1, 'asda', 'gfdgd', 12);
insert into nested_tab values (2, 'sdfsd', 'cvxvx', 14);
insert into nested_tab values (3, 'uyiy', 'mmbv', 16);create or replace function support_dml return int as
beginupdate nested_tab set id = 4 where name = 'uyiy';return 12;
end;
/
报错如下
SQL> select support_dml() from dual;
select support_dml() from dual*
ERROR at line 1:
ORA-14551: cannot perform a DML operation inside a query
ORA-06512: at "SYS.SUPPORT_DML", line 3

针对第二种情况我们测试一下

declareretcode int := 1;
beginretcode := support_dml();dbms_output.put_line(retcode);
end;
/
12PL/SQL procedure successfully completed.

由此可以知道定义在函数中的dml,只能在plsql中使用。

plorasql实现

lightdb 在兼容的过程中,上面描述的oracle的两种情况都支持。

plorasql测试

create table nested_tab(id int, name varchar2(100), job varchar2(100), age int);
insert into nested_tab values (1, 'asda', 'gfdgd', 12);
insert into nested_tab values (2, 'sdfsd', 'cvxvx', 14);
insert into nested_tab values (3, 'uyiy', 'mmbv', 16);create or replace function support_dml return int as
beginupdate nested_tab set id = 4 where name = 'uyiy';return 12;
end;
/lightdb@test_hs_oracle=# select support_dml() from dual;support_dml 
-------------12
(1 row)lightdb@test_hs_oracle=# select dbms_output.serveroutput('t');serveroutput 
--------------(1 row)lightdb@test_hs_oracle=# declare
lightdb@test_hs_oracle$# retcode int := 1;
lightdb@test_hs_oracle$# begin
lightdb@test_hs_oracle$#     retcode := support_dml();
lightdb@test_hs_oracle$# dbms_output.put_line(retcode);
lightdb@test_hs_oracle$# end;
lightdb@test_hs_oracle$# /
12
DO
http://www.lryc.cn/news/163788.html

相关文章:

  • 电容笔值不值得买?开学季比较好用的电容笔
  • Mybatis 框架 ( 五 ) 分页
  • Python模板注入
  • Java常用的设计模式
  • 攻防世界-WEB-Web_php_include
  • angular中多层嵌套结构的表单如何处理回显问题
  • Leetcode646. 最长数对链
  • Windows 下安装NPM
  • 【ARM CoreLink 系列 2 -- CCI-400 控制器简介】
  • LeetCode(力扣)77. 组合Python
  • uniapp h5 微信缓存,解决版本更新还是旧版本
  • Nacos——Distro一致性协议
  • 大模型参数高效微调PEFT的理解和应用
  • 工作游戏时mfc140u.dll丢失的解决方法,哪个方法可快速修复mfc140u.dll问题
  • 选择排序——直接选择排序
  • 【C++基础】观察者模式(“发布-订阅”模式)
  • 从业多年,我总结出软件测试工程师必须掌握的技能,你不可错过!
  • 【nerfStudio】5-nerfStudio导出3D Mesh模型
  • 重要公告|投票委托已经上线,应该如何选择社区代表?
  • 【操作系统】聊聊进程、线程、协程
  • springboot 下 activiti 7会签配置与实现
  • RK3399平台开发系列讲解(内核调试篇)spidev_test工具使用
  • 点云从入门到精通技术详解100篇-自适应点云局部邻域特征的特征提取与配准(续)
  • VBA技术资料MF52:VBA_在Excel中突出显示前 10 个值
  • leetcode做题笔记134. 加油站
  • Allegro166版本如何在颜色管理器中实时显示层面操作指导
  • 纷享销客入选中国信通院《高质量数字化转型产品及服务全景图》
  • C高级 DAY4
  • C高级day4
  • Java8-17 --- idea2022