Purpose of this function: Returns a table
Implemented in Oracle, example:
1--in the types:2Create or replace type objtable as Object3 (4S_usercode VARCHAR2 (32767),5S_username VARCHAR2 (32767)6 );7 8 CREATE OR REPLACE TYPE tabtemp as TABLE of objtable;9 Ten One--In the function: A--using the pipeline pipe function and Pipe row () - Create or Replace function Getcsclient - ( the /* - Code: Getcsclient - Program Name: - Incoming parameters: + return Value: - remark: + Example: SELECT * FROM table (getcsclient (' Shadowxiong ')); A Version changes: at xx. yyyy/mm/dd VER AUTHOR COMMENTS - 2015/08/28 1.00 Anne_han New Create - */ - P_usercode varchar2 - ) - returntabtemp pipelined in as -S_usercode VARCHAR2 (32767); toS_username VARCHAR2 (32767); + v objtable; - begin the forMyrowinch(SelectCshortname,cenglishname frommv_liclientbaseinfo ORDER by Cshortname) * Loop $v:=objtable (myrow. Cshortname, Myrow. Cenglishname);Panax Notoginseng PIPE ROW (v); - end Loop; the + RETURN; A theEnd Getcsclient;
Implemented in SQL Service, example:
1--In the function:2CREATE FUNCTION [dbo]. [Getcsclient] (@USER_CODE NVARCHAR ( -)) 3RETURNS @objTable TABLE (ClientId nvarchar ( the), CLIENTNAME nvarchar ( Max))4 as5 BEGIN6 INSERT into @objTable (clientid,clientname)7 SELECT Clientid,clientname from CLIENT with (NOLOCK)8 ORDER by CLIENTID9 Ten RETURN One END A ---Call Function -SELECT * FROM dbo. Getcsclient ('Shadowxiong')
Return table by function in Oracle/sql service