create or replace procedure NrCopii2 (NrNume varchar2)
as
NrNume COPIL.nume%type;
begin
select count(nume) from Copil
dbms_output.put_line(NrNume);
end;
/
2 Answers
There are some typoes need to be fixed :
- add
into NrNume(just beforefrom) and add;to the end of that statement presuming the data type ofnumecolumn is plainnumberorinteger, otherwise you may replacecopil.nume%typewithinttoo - either remove
NrNumeparameter of the procedure or local variableNrNumewhile replacingNrCopii2 (NrNume varchar2)withNrCopii2 (NrNume out varchar2), those have same names, and one of them should be preferred to use
PS. don't forget to issue set serveroutput on whenever the procedure is invoked, in order to display the value returned for NrNume
As a result, the following code block might be used
SQL> SET SERVEROUTPUT ON
SQL> CREATE OR REPLACE PROCEDURE NrCopii2 AS
NrNume INT;
BEGIN
SELECT COUNT(nume) INTO NrNume FROM Copil;
DBMS_OUTPUT.PUT_LINE(NrNume);
END;
/
1 Comment
Bivol Victor
you can pls show how its need to look the code because I'm pretty bad and i can't understand the second point pls if need i can show the data base
You can make anonymous procedure as well.
DECLARE
NrNume COPIL.nume%type;
BEGIN
SELECT count(nume) INTO NrNume
FROM Copil;
dbms_output.put_line(NrNume);
END;
/
1 Comment
Bivol Victor
Can u make it in a procedure pls ?