Method 1: variables with the same table Type
Create or replace function f_get_cust_name (v_no in customer. No % Type, v_compno in customer. compno % Type)
Return customer. Name % Type
Is
V_name customer. Name % Type;
Begin
Select customer. Name into v_name
From customer
Where
No = V_no and compno = V_compno;
Return v_name;
Exception when no_data_found then return ' ' ; --- Restore Blank
End;
Method 2: Change Data with a self-defined sequence
Create or replace function f_get_cust_name (v_no in varchar2, v_compno in varchar2)
Return varchar2
Is
V_name varchar2;
Begin
Select customer. Name into v_name
From customer
Where
No = V_no and compno = V_compno;
Return v_name;
Exception when no_data_found then return ' ' ; --- Restore Blank
End;
Example: -- 1 to confirm Login
-- 2. The password is incorrect.
-- 3. The specified snapshot does not exist.
-- Return Value Type
Create or replace function getaccount (acc_id In Members. account_id % Type, acc_pwd In Members. account_password % Type)
Return Number
Is
V_result number;
V_count number;
V_acc_pwd members. account_password % Type;
Begin
Select count (*)AsCount, Members. account_password into v_count, v_acc_pwd
From members
WhereMembers. account_id=Acc_id
Group by members. account_password;
If V_count > 0
Then
If V_acc_pwd = Acc_pwd then
V_result: = 1 ;
Else
V_result: = 2 ;
End If ;
Else
V_result: = 3 ;
End If ;
ReturnV_result;
Exception when no_data_found then return3;
End;Since: http://tw.myblog.yahoo.com/adar168-ADARA/article? Mid = 252 & l = F & FID = 7 # yarttrk