SQL
Oracle SQL
摘自:http://www.itpub.net/608483.html
DECODE的语法DECODE(value,if1,then1,if2,then2,if3,then3,…,else)
to_date(‘2008-04-23 00:00:00’ ,’yyyy-mm-dd hh24:mi:ss’)
SELECT TO_CHAR(CURRENT_DATE, 'YYYY-MM-DD') FROM dual;
SUBSTR 从1开始而不是0
SUBSTR ('shidong', 2) return idongOracle PIPELINED
Pipelined functions are useful if there is a need for a data source other than a table in a select statement.
Typical Pipelined Example:
- The producer function must use the PIPELINED keyword in its declaration.
- The producer function must use an OUT parameter that is a record, corresponding to a row in the result set.
- Once each output record is completed, it is sent to the consumer function through the use of the PIPE ROW keyword
- The producer function must end with a RETURN statement that does not specify any return value.
- The consumer function or SQL statement then must use the TABLE keyword to treat the resulting rows from the PIPELINE function like a regular table.
定义返回类型:
1 | CREATE OR REPLACE TYPE myObjectFormat AS OBJECT ( A INT, B DATE, C VARCHAR2(25) ) |
定义包/包体:
1 | CREATE OR REPLACE PACKAGE myDemoPack AS FUNCTION prodFunc RETURN myTableType PIPELINED; END; |
客户端调用:
1
SELECT * FROM TABLE(myDemoPack.prodFunc());
本博客所有文章除特别声明外,均采用 CC BY-NC-SA 4.0 许可协议。转载请注明来源 石头记!
评论