System function

Numerical function

Find absolute
valueSelect abs(-1) from dual rounding
methodselect
ceil(12.1) from dual
tail- cutting methodselect
floor(12.6) from dual
roundingselect
round(12.4) from dual
rounding with 2..n decimal
placesselect round ( 12.4123,2) from dual

digital interception
default intercept integer Function Convert to uppercase select upper('s') from dual to lowercase select lower('S') from dual to remove spaces (the problem with time spaces is very pitted) select trim(' as ') from dual to remove left spacesselect ltrim ('as') from dual select rtrim('as ') from dual





















Remove the characters specified on the left
select ltrim('abcdec','ab') from dualRemove
the characters specified on the right
select rtrim('abcdec','c') from dualReplace


functionselect
replace('as','s',' q') from dual
String addition
select 'aa'||'bb' from dual
select concat('aa','bb') from dual
Function to intercept strings
select substr('abcde',1,3)
from dual
function to find length
select length('as') from dual


conversion function

convert to number
select to_number('123') from dual
convert to string
select to_char(123) from dual
* convert to string, format time
select to_date (sysdate) from dual

to a full year, month, day, hour, minute and second
select to_char(sysdate,'yyyy-mm-dd hh24:mi:ss') from dual

time 24-hour clock
select to_char(sysdate,'yyyy-mm-dd hh24:mi:ss') from dual


function to handle Null

*returns the formula for null, not null and returns itself
select nvl('','b') from dual

* Not empty Return parameter 2 is empty Return parameter 3
select nvl2('','b','c') from dual

Oracle custom function
Function must have a return value

Oracle stored procedure
Advantages:
1. Stored procedure precompiles SQL Statement, compiled once and then executed without recompilation
. Execution efficiency is faster.
2. SQL coding can be performed in stored procedures, which can reduce server pressure
. Disadvantages:
1. Large amount of code, difficult to maintain

 Open cache
Set Serveroutput on

 Create stored procedure
Create procedure storage name
As
Begin
Dbms_output.put_line();--output
End;

 Execute stored procedure
Beign
stored procedure name;
End;





declare pr int;
begin
proc_ddd(1,2,pr);
Dbms_output.put_line(pr);
end;

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326176883&siteId=291194637