Oracle/PLSQL: LPAD FunctionThis Oracle tutorial explains how to use the Oracle/PLSQL LPAD function with syntax and examples.DescriptionThe Oracle/PLSQL LPAD function pads the left-side of a string with a specific set of characters (when string1 is not null).SyntaxThe syntax for the LPAD function in Oracle/PLSQL is:LPAD( string1, padded_length [, pad_string] )Parameters or Argumentsstring1The strin...
Oracle/PLSQL: LENGTH FunctionThis Oracle tutorial explains how to use the Oracle/PLSQL LENGTH function with syntax and examples.DescriptionThe Oracle/PLSQL LENGTH function returns the length of the specified string.SyntaxThe syntax for the LENGTH function in Oracle/PLSQL is:LENGTH( string1 )Parameters or Argumentsstring1The string to return the length for.Note: If string1 is NULL, then the LENGTH ...
本系列链接导航:[独孤九剑]Oracle知识点梳理(一)表空间、用户[独孤九剑]Oracle知识点梳理(二)数据库的连接[独孤九剑]Oracle知识点梳理(三)导入、导出[独孤九剑]Oracle知识点梳理(四)SQL语句之DML和DDL[独孤九剑]Oracle知识点梳理(五)数据库常用对象之Table、View[独孤九剑]Oracle知识点梳理(六)数据库常用对象之Procedure、function、Sequence[独孤九剑]Oracle知识点梳理(七)数据库常用对象之Cursor[独孤九剑]Oracl...
开发过程中,需要不停的备份数据库对象, 特别是存储过程, 每次手动备份不免很低能啊
历经几次修改终于, 完美了,O(∩_∩)O哈哈~ (当然,你也可以再改简便一点~~~)
select dbms_metadata.get_ddl(‘PROCEDURE‘,"PROCEDURE_NAME",‘NAG‘) 遇到大存储过程老是丢东西不说, 对象名 还老是 "用户名"."对象名" 的格式,腻烦人!~CREATE OR REPLACE PROCEDURE OBJAUTOSTORE
AS
/* 功能:备份存储过程和视图
准备工作:
--1.创建文件夹 :...
--函数的创建
create function func1(dno number)
return NUMBER--必须带有返回值
is v_max number;--定义返回值beginselect max(sal) into v_max--赋值from emp where deptno= dno;RETURN v_max;--返回end;
--函数的调用,只能是表达式的一部分,不能单独调用select * from emp where sal= func1(10);---------------------------------------------------------------------------------创建过程存在则替换,带输出参数create or...
写在这里,以便于以后忘记格式后可以查询。
CREATE OR REPLACE FUNCTION TEMP_FUNC_WYL(PI_AAA100 VARCHAR2,PI_AAA102 VARCHAR2)
--字典转换,把代码值转换成对应的可理解的中文,wyl,20141105RETURN VARCHAR2 ISV_AAA103 VARCHAR2(1000);
BEGINSELECT AAA103INTO V_AAA103FROM AA10 AWHERE A.AAA100 = PI_AAA100AND A.AAA102 = PI_AAA102;RETURN V_AAA103;
EXCEPTIONWHEN NO_DATA_FOUND THENDBMS_OUTPUT.PUT_LINE(‘没有找到数据‘...
--在Types中:2 create or replace type objTable as object3 (4 s_usercode varchar2(32767),5 s_username varchar2(32767)6 );7 8 CREATE OR REPLACE TYPE tabTemp AS TABLE OF objtable;9
10
11 --在Function中:
12 --使用Pipeline管道函数和Pipe row()
13 create or replace function GetCSClient
14 (
15 /*
16 程式代号:GetCSClient
17 程式名称:
18 传入参数:
19 传回值:
20 备注:
21 范例:select * from tabl...
Scott表下有这么几个常用的表,而且还带有数据。分别是emp、dept、salgrade;
1、查看表结构用descdesc emp;
2、空表dual,最常用的空表,如:select 2 * 4 from dual;select sysdate from dual;
3、双引号能保持格式如:select sysdate “toDay 日 期” from dual;
4、|| 字符串连接如:select 2*3 || 8 from dual;select ename || sal from scott.emp;select ename || ‘ORACLE’ from scott.emp;
5、单引号,如:select...
CREATE OR REPLACE FUNCTION "FUNC_NEXTID"2 (tablename in varchar2) return number is3 4 nextid number(12);5 begin6 begin7 select nvl(max(id),-1) into nextid from tSequence where upper(name) = upper(tablename);8 exception9 when no_data_found then nextid := 0;
10 end;
11
12 if nextid = -1 then
13 INSERT INTO tSequence(name,id) VALUES(tablename,1);
14 nextid := 1;
15 else
1...
1).可以理解函数是存储过程的一种 2).函数可以没有参数,但是一定需要一个返回值,存储过程可以没有参数,不需要返回值 3).函数return返回值没有返回参数模式,存储过程通过out参数返回值, 如果需要返回多个参数则建议使用存储过程 4).在sql数据操纵语句中只能调用函数而不能调用存储过程, 5).function必须有返回值,并且只能有一个返回值; 6).procedur不叫返回值,叫带出,可以带出多个值; 7).packages、package、bodies是同时存在的...
*
* 功能描述:根据输入的日期以及天数,获取此日期之后的天数的工作日
* 输入参数:
* i_date YYYY-MM-DD
* i_day 天数
*/
create or replace function fun_get_workday(i_date varchar2, i_day number)
return varchar2
isk int:=0;d1 date;d2 date;
begink := i_day; d1 := to_date(i_date, ‘YYYY-MM-DD‘);d2 := d1 + k;while k > 0 loopselect count(c_rq) into k from t_fdjr twhere t.c_rq > d1 and t.c_rq <= d2;d1 :=...
存储过程创建语法:2 3create or replace procedure procedure_name(param1 in type,param2 out type,param3 in out type) --参数类型不需要定义值范围4 5 as6 7 变量1 类型(值范围);8 9 变量2 类型(值范围);
10
11 Begin
12 ...........
13 END [procedure_name];1 begin
2 execute immediate ‘ALTER TABLE RECORD_XWZX5_left ADD (ID NUMBER)‘;
3 execute immediate ‘ALTER TABLE RECORD_XWZX5_right ADD (ID NUMBER)...
The Oracle/PLSQL TO_CHAR function converts a number or date to a string.将数字转换为日期或字符串 Syntax TO_CHAR( value [, format_mask] [, nls_language] ) Parameters or Arguments Value A number or date that will be converted to a string. format_mask Optional. This is the format that will be used to convert value to a string. nls_language ...
LPAD(‘tech‘, 7);
Result: ‘ tech‘LPAD(‘tech‘, 2);
Result: ‘te‘LPAD(‘tech‘, 8, ‘0‘);
Result: ‘0000tech‘LPAD(‘tech on the net‘, 15, ‘z‘);
Result: ‘tech on the net‘LPAD(‘tech on the net‘, 16, ‘z‘);
Result: ‘ztech on the net‘
ORACLE_LPAD_FUNCTION标签:specific string returns hand xpl col style argument plsql 本文系统来源:http://www.cnblogs.com/yjhlsbnf/p/7...
SELECT ename, hiredate, TO_CHAR((hiredate),‘fmDay‘) "Day"
FROM emp
ORDER BY "Day";
Answer: In the above SQL, the fmDay format mask used in the TO_CHAR function will return the name of the Day and not the numeric value of the day.
To sort the days of the week in order, you need to return the numeric value of the day by using the fmD format mask as follows:
SELECT ename, hiredate, TO_CHAR((hiredat...