• LightDB23.4 table函数支持column_value列


    功能介绍

    用户在使用LightDB数据库Oracle兼容模式的过程中发现table函数不支持column_value列,导致部分在Oracle数据库可以运行的SQL在LightDB上报错。所以,在LightDB23.4版本上table函数支持了column_value列。
    使用约束:

    1. 需要是Oracle兼容模式;
    2. table函数需要在from子句中;

    使用示例

    1. 不在from子句中,列名为table_func
    lightdb@oracle_test=# create type kk as table of int;
    CREATE TYPE
    lightdb@oracle_test=# 
    lightdb@oracle_test=# select table(kk(1,2,3));
     table_func 
    ------------
              1
              2
              3
    (3 rows)
    
    lightdb@oracle_test=# 
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    1. 在from子句中,输出的列名为column_value
    lightdb@oracle_test=# select * from table(kk(1,2,3));
     column_value 
    --------------
                1
                2
                3
    (3 rows)
    
    lightdb@oracle_test=# 
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    1. table函数返回多列数据,会保持原来的列名
    lightdb@oracle_test=# create table t1(a int, b int);
    CREATE TABLE
    lightdb@oracle_test=# insert into t1 (values (1,1), (2,2), (3,3));
    INSERT 0 3
    lightdb@oracle_test=# 
    lightdb@oracle_test=# 
    lightdb@oracle_test=# create or replace package pkg
    lightdb@oracle_test-# as
    lightdb@oracle_test$# type nt is table of t1%rowtype;
    lightdb@oracle_test$# res nt;
    lightdb@oracle_test$# function myfunc() return nt;
    lightdb@oracle_test$# end;
    lightdb@oracle_test$# /
    CREATE PACKAGE
    lightdb@oracle_test=# 
    lightdb@oracle_test=# create or replace package body pkg
    lightdb@oracle_test-# as
    lightdb@oracle_test$# function myfunc() return nt
    lightdb@oracle_test$# is
    lightdb@oracle_test$# begin
    lightdb@oracle_test$# 
    
    lightdb@oracle_test$# res(1) := ROW(1,1);
    lightdb@oracle_test$# 
    
    lightdb@oracle_test$# res(2) := ROW(2,2);
    lightdb@oracle_test$# 
    
    lightdb@oracle_test$# res(3) := ROW(3,3);
    lightdb@oracle_test$# 
    
    lightdb@oracle_test$# return res;
    lightdb@oracle_test$# end;
    lightdb@oracle_test$# end;
    lightdb@oracle_test$# /
    CREATE PACKAGE BODY
    lightdb@oracle_test=# 
    lightdb@oracle_test=# select * from table(pkg.myfunc());
     a | b 
    ---+---
     1 | 1
     2 | 2
     3 | 3
    (3 rows)
    
    lightdb@oracle_test=# 
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    • 29
    • 30
    • 31
    • 32
    • 33
    • 34
    • 35
    • 36
    • 37
    • 38
    • 39
    • 40
    • 41
    • 42
    • 43
    • 44
    • 45
    • 46
  • 相关阅读:
    OSG文字-HUD显示汉字示例(3)
    用Markdown记录“学习用Markdown写数学公式”
    sqlserver列出所有的存储过程
    自动控制原理 - 2 控制系统的数学模型 节2.4-2.6
    单机部署ELK + Filebeat 收集应用日志
    Java 8中的map和flatMap方法的区别
    免杀笔记 ----->汇编基础
    反转字符串II
    Navicat for mysql 设置用户账号密码永不过期
    [附源码]java毕业设计学习资源共享与在线学习系统
  • 原文地址:https://blog.csdn.net/yunmu666/article/details/134270541