本文主要是介绍lightdb object支持authid current_user,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
文章目录
- 背景
- 语法
- 示例
背景
在信创适配中,从Oracle迁移过来的程序使用authid current_user。为此LightDB从24.1版本开始,对该功能进行了语法层面上的支持。
语法
CREATE [ OR REPLACE ] TYPE name opt_invoker_rights_clause as_is OBJECT ( [ object_type_element_list ] )where opt_invoker_rights_clause is:[ AUTHID CURRENT | AUTHID DEFINER ]and as_is is:AS | ISand object_type_element_list is:TableFuncElementList [ object_type_func_list ]and TableFuncElementList is:attribute_name data_type [ COLLATE collation ] [, ... ]and object_type_func_list is:{ type_function_spec | type_procedure_spec } [, ... ]and type_function_spec is:MEMBER FUNCTION func_name ( [ [ argmode ] [ argname ] argtype [ { DEFAULT | = } default_expr ] [, ...] ] ) RETURN rettypeSTATIC FUNCTION func_name ( [ [ argmode ] [ argname ] argtype [ { DEFAULT | = } default_expr ] [, ...] ] ) RETURN rettypeand type_procedure_spec is:MEMBER PROCEDURE func_name ( [ [ argmode ] [ argname ] argtype [ { DEFAULT | = } default_expr ] [, ...] ] )STATIC PROCEDURE func_name ( [ [ argmode ] [ argname ] argtype [ { DEFAULT | = } default_expr ] [, ...] ] )CREATE [ OR REPLACE ] TYPE BODY name as_is subprog_decl_in_type_list ENDwhere subprog_decl_in_type_list is:{ func_decl_in_type | proc_decl_in_type } [ ... ]and func_decl_in_type is:MEMBER FUNCTION func_name ( [ [ argmode ] [ argname ] argtype [ { DEFAULT | = } default_expr ] [, ...] ] ) RETURN rettype as_is pl_block ;STATIC FUNCTION func_name ( [ [ argmode ] [ argname ] argtype [ { DEFAULT | = } default_expr ] [, ...] ] ) RETURN rettype as_is pl_block ;and proc_decl_in_type is:MEMBER PROCEDURE func_name ( [ [ argmode ] [ argname ] argtype [ { DEFAULT | = } default_expr ] [, ...] ] ) as_is pl_block ;STATIC PROCEDURE func_name ( [ [ argmode ] [ argname ] argtype [ { DEFAULT | = } default_expr ] [, ...] ] ) as_is pl_block ;and as_is is:AS | ISand pl_block is:[ DECLARE decl_stmts ] BEGIN statement [ , ... ] END
示例
CREATE OR REPLACE TYPE tp_point authid current_user as object (x int,y int,member procedure plus_x(v number),member procedure plus_y(v number),static procedure p_display(p tp_point),static function f_display(p tp_point) return varchar
);CREATE OR REPLACE TYPE BODY tp_point AS member procedure plus_x(v number) is BEGINself.x := self.x + v;end;member procedure plus_y(v number) is BEGINself.y := self.y + v;end;static procedure p_display(p tp_point) is BEGINdbms_output.put_line('x=' || p.x || ',' || 'y=' || p.y);end;static function f_display(p tp_point) return varchar is BEGINreturn 'x=' || p.x || ',' || 'y=' || p.y;end;
END;
/declarep tp_point := tp_point(1.0, 2.0);
BEGINtp_point.p_display(p);p.plus_x(1.0);p.plus_y(2.0);dbms_output.put_line(tp_point.f_display(p));
end;
/
x=1,y=2
x=2,y=4
DO
这篇关于lightdb object支持authid current_user的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!