Home » SQL & PL/SQL » SQL & PL/SQL » Problem with Calling Procedure (PL/SQL) (10g)
Problem with Calling Procedure (PL/SQL) [message #346419] Mon, 08 September 2008 08:59 Go to next message
Creems
Messages: 70
Registered: July 2007
Location: Johannesburg
Member
Hello,

I created the function below and when I tried to call it I get an error that wrong number or arguments.

I called the function (bond_cal) from SQL*Plus as:
SQL> exec bond_cal(150000, 5);

ERROR at line 1:
ORA-06550: line 1, column 7:
PLS-00306: wrong number or types of arguments in call to 'BOND_CAL'
ORA-06550: line 1, column 7:
PL/SQL: Statement ignored

Please do put me through as I'm just learning PL/SQL proper. And below is the code

create or replace function bond_cal
(
amount in number,
months out number,
years in number,
interest out number,
insurance in number := 700,
bond in out number
)
return number
as

/* This program is used to calculate bond payable on your mortgage
with interest rate, service charges and insurance fees included.

With the following values as default,
insurance = R700
interest rate = 36/100
*/

begin
months := years * 12;
interest := amount * ( 36 / 100);
bond := (amount / months) + interest + insurance;
-- dbms_output.put_line('Bond Payable: '||bond||' per month');
end;
/

It ran successfully but when I want to call it ... it gives error. Maybe I passed wrong arguments ... I dont know

Can anyone help me please.


Thanks in good anticipation.

Creems
Re: Problem with Calling Procedure (PL/SQL) [message #346423 is a reply to message #346419] Mon, 08 September 2008 09:17 Go to previous messageGo to next message
BlackSwan
Messages: 25050
Registered: January 2009
Location: SoCal
Senior Member
http://www.orafaq.com/forum/t/88153/0/
Please read & FOLLOW the Posting Guidelines as stated in URL above

How many "IN" arguments did you declare & how many did you provide?
Re: Problem with Calling Procedure (PL/SQL) [message #346436 is a reply to message #346419] Mon, 08 September 2008 10:08 Go to previous messageGo to next message
Michel Cadot
Messages: 64152
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
As always, please read OraFAQ Forum Guide, especially "How to format your post?" section.
Make sure that lines of code do not exceed 80 characters when you format.
Indent the code (See SQL Formatter) and align the columns in result.
Use the "Preview Message" button to verify.
Also always post your Oracle version (4 decimals).

Regards
Michel
Re: Problem with Calling Procedure (PL/SQL) [message #346481 is a reply to message #346419] Mon, 08 September 2008 12:39 Go to previous messageGo to next message
joy_division
Messages: 4644
Registered: February 2005
Location: East Coast USA
Senior Member
CherishMe wrote on Mon, 08 September 2008 09:59

I created the function below and when I tried to call it I get an error that wrong number or arguments.

I called the function (bond_cal) from SQL*Plus as:
SQL> exec bond_cal(150000, 5);

ERROR at line 1:
ORA-06550: line 1, column 7:
PLS-00306: wrong number or types of arguments in call to 'BOND_CAL'
ORA-06550: line 1, column 7:
PL/SQL: Statement ignored



exec is used to execute a procedure, not a function. This error message is fudged.
Re: Problem with Calling Procedure (PL/SQL) [message #346592 is a reply to message #346481] Tue, 09 September 2008 01:32 Go to previous messageGo to next message
milind.khadloya
Messages: 4
Registered: September 2008
Location: India
Junior Member

When you define the function you have six parameters and none of the parameter is provided with the default value, so to execute this function you have to provide value for all six parameter.

If you would like to execute your define function correctly try below

Declare
--Define all out variable;
months number;
interest number;
insurance number := 700,
bond number;
i number;

BEGIN
/*i:=bond_cal(provide value for all in parameter and all out variable);/*
i:= bond_cal (15000,months ,5,interest out number, 700,bond);
--To view the value use dbms_output.put_line
DBMS_OUTPUT.put_line(i);
END;
Re: Problem with Calling Procedure (PL/SQL) [message #346711 is a reply to message #346592] Tue, 09 September 2008 08:38 Go to previous messageGo to next message
joy_division
Messages: 4644
Registered: February 2005
Location: East Coast USA
Senior Member
At least 2 errors in this code.

comma instead of semicolon.
poorly matched begin and end comment.

It's great you try to help, but helping by posting invalid code only confuses the original poster.

[Updated on: Tue, 09 September 2008 08:41]

Report message to a moderator

Re: Problem with Calling Procedure (PL/SQL) [message #346719 is a reply to message #346592] Tue, 09 September 2008 08:51 Go to previous message
Michel Cadot
Messages: 64152
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
@milind.khadloya

Also:
Michel Cadot wrote on Mon, 08 September 2008 17:08
As always, please read OraFAQ Forum Guide, especially "How to format your post?" section.
Make sure that lines of code do not exceed 80 characters when you format.
Indent the code (See SQL Formatter) and align the columns in result.
Use the "Preview Message" button to verify.

is also for those who answer.

Regards
Michel

Previous Topic: The Trouble with Triggers.
Next Topic: Data Updation.
Goto Forum:
  


Current Time: Sat Dec 10 18:38:51 CST 2016

Total time taken to generate the page: 0.07553 seconds