Q:

how can I out a parameter as varchar2 in oracle

I am using oracle 10g
this is my package specification and body
CREATE OR REPLACE PACKAGE P_1 AS
    TYPE T_CURSOR IS REF CURSOR;
    PROCEDURE USP_1(SP_NUM OUT VARCHAR2);
END P_1;

CREATE OR REPLACE PACKAGE BODY P_1 AS
    PROCEDURE USP_1(SP_NUM OUT VARCHAR2) IS
    BEGIN
        SELECT to_char(concat(to_char(sysdate, 'yyyymm'),
                              to_char("ActionId".nextval, '000')))
            INTO SP_NUM FROM dual;
    END USP_1;
END P_1;

my back-end code is
using (OracleConnection oracleConnection = new BaseRepository().Connection)
{
    oracleConnection.Open();

    OracleCommand command = new OracleCommand("P_1.USP_1", oracleConnection);

    command.CommandType = System.Data.CommandType.StoredProcedure;
    command.Parameters.Add("SP_NUM", OracleDbType.Varchar2, 50,
                           System.Data.ParameterDirection.Output);

    command.ExecuteNonQuery();  // exception arises at this line

    var Number = Convert.ToInt32(command.Parameters["SP_REQ_NUM"].Value.ToString());

this is the exception i am getting.
ORA-06502: PL/SQL: numeric or value error

I don't know where i am doing something wrong.

A:

There are no less than 10 overloads of the OracleParameterCollection.Add method.  It looks like you have accidentally called the wrong one.
I believe the one you want is Add(string, OracleDbType, int, object, ParameterDirection), in which case you're just missing a value for the object parameter.  This parameter should contain an initial value for the Oracle parameter you're using.  In your case, however, the initial value doesn't matter as it's an out parameter.  Add null after 50 and your stored procedure call should succeed.
The one you have called is Add(string, OracleDbType, object, ParameterDirection).  The size 50 has been interpreted as an initial value for the parameter.  I'm not sure how to interpret the error that Oracle returns ("numeric or value error") – that implies to me that Oracle has tried to convert a string to a number and failed.  Perhaps the value 50 overrides the type OracleDbType.Varchar2 and so Oracle expects a number rather than a string?
There were another couple of problems I found:

Should command.Parameters["SP_REQ_NUM"] be command.Parameters["SP_NUM"]?
Your stored procedure doesn't return a number; calling Convert.ToInt32 on a string such as 201405 001 will fail.

