Zoeken…
Syntaxis
CREATE [OF REPLACE] FUNCTION functienaam [(parameter [, parameter])]
RETURN return_datatype
IS | NET ZO
[Declaration_section]
BEGIN executable_section
[EXCEPTION exception_section]
END [functienaam];
GUID genereren
Create Or Replace Function Generateguid
Return Char Is
V_Guid Char(40);
Begin
Select Substr(Sys_Guid(),1,8)||'-'||Substr(Sys_Guid(),9,4)||'-'
||Substr(Sys_Guid(),13,4)||'-'||Substr(Sys_Guid(),17,4)||'-'
||Substr(Sys_Guid(),21) Into V_Guid
From Dual;
Return V_Guid;
Exception
When Others Then
dbms_output.put_line('Error '|| SQLERRM);
End Generateguid;
Belfuncties
Er zijn een paar manieren om functies te gebruiken.
Een functie oproepen met een toewijzingsverklaring
DECLARE
x NUMBER := functionName(); --functions can be called in declaration section
BEGIN
x := functionName();
END;
Een functie aanroepen in IF-instructie
IF functionName() = 100 THEN
Null;
END IF;
Een functie aanroepen in een SELECT-instructie
SELECT functionName() FROM DUAL;
Modified text is an extract of the original Stack Overflow Documentation
Licentie onder CC BY-SA 3.0
Niet aangesloten bij Stack Overflow