locked
how can I get output parameter from sql oracle RRS feed

  • Question

  • User-804681621 posted

    how can I get output parameter returned by function from sql using oracle
    Thursday, October 13, 2016 4:37 AM

All replies

  • User-654786183 posted

    You can do something like

    OracleCommand cmd = new OracleCommand("myCommand", myConnection);
    cmd.CommandType = CommandType.StoredProcedure;
    cmd.Parameters.Add("myVariable", OracleDbType.Int32).Direction = ParameterDirection.Output;
    cmd.ExecuteNonQuery();

    Please refer

    http://stackoverflow.com/questions/14247921/how-to-return-oracle-output-parameters-from-a-stored-procedure-in-net

    https://csharpdeveloper.wordpress.com/2009/01/14/getting-values-back-from-oracle-procedures-in-c-net/

    Thursday, October 13, 2016 5:26 AM
  • User-804681621 posted
    I mean if I am using function in the sql, may be it just in the oracle package, how can I get the function parameter output immediately in sql? Not program, so it does not need programming
    Thursday, October 13, 2016 9:14 AM
  • User-654786183 posted

    Try something like this

    CREATE OR REPLACE FUNCTION yourFunction (outParam OUT VARCHAR2)
    RETURN VARCHAR2 IS
     
    BEGIN
      outParam := 'out param';
      RETURN 'return param';
    END yourFunction ;
    /
     
    SET serveroutput ON
     
    DECLARE
      returnValue VARCHAR2(20);
      outValue VARCHAR2(20);
    BEGIN
      returnValue := yourFunction(outValue);
      DBMS_OUTPUT.put_line(outValue);
      DBMS_OUTPUT.put_line(returnValue);
    END;
    /

    Thursday, October 13, 2016 1:38 PM