• 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
  • 相关阅读:
    langflow agent 资料
    外贸新手如何利用领英寻找你的潜在客户(建议收藏)
    com.fasterxml.jackson.databind.exc.UnrecognizedPropertyException
    SVProgressHUD和MBProgressHUD的优缺点与SVProgressHUD震动实现
    LeetCode //C - 114. Flatten Binary Tree to Linked List
    java基础学习-多线程笔记
    ceres的常见用法总结
    HTTP协议深入理解+如何使用Fiddler抓包
    SpringBoot 调用外部接口的三种方式
    Unity记录5.6-地图-天空地面及地底的地形
  • 原文地址:https://blog.csdn.net/yunmu666/article/details/134270541