return table through function in Oracle/sql service

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.