PLS-00306: wrong number or types of arguments in call to ‘PUT_LINE’ error occurs when the dbms_output.put_line stored procedure call cannot be matched to any declaration for that dbms_output.put_line(). The name of the dbms output.put line stored procedure may be misspelt, a parameter may not be of the string datatype, or the declaration may be incorrectly positioned in the block structure. Make that the name of the stored procedure dbms output.put line is spelled correctly and stated. Double-check that its call is legitimate, that its parameters are of the string datatype, and that its declaration is in the correct block structure. This will resolve the error PLS-00306: wrong number or types of arguments in call to ‘PUT_LINE’.
The problem
When you call a stored procedure with data type arguments that differ from the parameters’ declared data type, an error occurs. If the order of the parameter data type is changed and the arguments in the stored procedure are erroneously positioned, an error will be thrown. If the number of arguments supplied does not match the recorded procedure parameters, an error PLS-00306: wrong number or types of arguments in call to ‘PUT_LINE’ will be thrown.
If you try to print a variable value using the put line stored procedure, you’ll get the following error.
begin
dbms_output.put_line('nameIn = ' ,'yawin');
end;
Error
Error starting at line : 33 in command -
begin
dbms_output.put_line('nameIn = ' ,'yawin');
end;
Error report -
ORA-06550: line 2, column 5:
PLS-00306: wrong number or types of arguments in call to 'PUT_LINE'
ORA-06550: line 2, column 5:
PL/SQL: Statement ignored
06550. 00000 - "line %s, column %s:\n%s"
*Cause: Usually a PL/SQL compilation error.
*Action:
Solution 1
To print a value in the console window, use the dbms output.put line stored procedure. The stored procedure dbms output.put line takes a string argument and outputs it to the console. The error PLS-00306: wrong number or types of arguments in call to ‘PUT_LINE’ will be thrown if you send two parameters to the dbms output.put line stored procedure. To resolve the error, change the dbms output.put line arguments one at a time.
Error
begin
dbms_output.put_line('nameIn = ' ,'yawin');
end;
Solution
begin
dbms_output.put_line('nameIn = yawin');
end;
Output
nameIn = yawin
PL/SQL procedure successfully completed.
Solution 2
Concatenate two or more string values and give to the put line stored procedure if you wish to use two arguments in the dbms output.put line stored procedure. Only one value will be accepted by the dbms output.put line stored method. To resolve the problem PLS-00306: wrong number or types of arguments in call to ‘PUT_LINE’ , first concatenate all the data and use the dbms output.put line stored procedure.
Error
begin
dbms_output.put_line('nameIn = ' ,'yawin');
end;
Solution
begin
dbms_output.put_line('nameIn = ' || 'yawin');
end;
Output
nameIn = yawin
PL/SQL procedure successfully completed.
Solution 3
If you are not passing any argument value to the dbms_output.put_line stored procedure, Oracle will throw the error. The dbms_output.put_line stored procedure expects a string argument to be passed as an argument. If none of the argument is passed in the dbms_output.put_line stored procedure, the error PLS-00306: wrong number or types of arguments in call to ‘PUT_LINE’ will be thrown.
Error
begin
dbms_output.put_line();
end;
Solution
begin
dbms_output.put_line('nameIn = yawin');
end;
Output
nameIn = yawin
PL/SQL procedure successfully completed.
Solution 4
If you pass an argument other than a string value, Oracle will try to convert it to a string value from the specified data type. If a numeric number is provided as an argument, for example, the value is immediately transformed to a string and printed. The error PLS-00306: wrong number or types of arguments in call to ‘PUT_LINE’ will be thrown if you provide an argument that cannot be implicitly transformed to a string. The value should be converted as string explicitly.
Error
declare
flag boolean;
begin
dbms_output.put_line(flag);
end;
Solution
declare
flag boolean;
begin
dbms_output.put_line(CASE WHEN flag THEN 'true' ELSE 'true' END);
end;
Output
true
PL/SQL procedure successfully completed.