1
CREATE OR REPLACE
FUNCTION xxpos.IS_USER_VALID(
  user_name     IN VARCHAR,
  user_password IN VARCHAR)
RETURN boolean
AS
user_count INTEGER;
BEGIN
    SELECT COUNT(*)
    INTO user_count
    FROM xxpos.service_users
    WHERE user_id     = user_name
    AND user_password = user_password;
    IF user_count     >0 THEN
        return true;
    ELSE
       return false;
    END IF;
END;

I created the oracle function. And i tried to use it in C# my application Like:

        Oracle.DataAccess.Client.OracleParameter[] parameters = new Oracle.DataAccess.Client.OracleParameter[3];
        parameters[0] = new Oracle.DataAccess.Client.OracleParameter("user_name", this.UserName);
        parameters[1] = new Oracle.DataAccess.Client.OracleParameter("user_password", this.Password);
        parameters[2] = new Oracle.DataAccess.Client.OracleParameter("is_valid", 
            Oracle.DataAccess.Client.OracleDbType.Object, 
            System.Data.ParameterDirection.ReturnValue);
        using (MyOracleClient myOracleClient = new MyOracleClient())
        {
            myOracleClient.MyExicuteNonQuery(Command.IsUserValid, parameters);
            this.userValid = (bool)parameters[2].Value;
        }

But It doesn't work out. Cloud you Please enplane me, the right way of using Parameters with c# Database connection.

2
  • Getting a exception on the parameter "is_valid" Invalid parameter binding Parameter name: is_valid Commented Jun 10, 2013 at 12:55
  • Did you try setting the value of Size for the ReturnValue param Commented Jun 11, 2013 at 4:39

2 Answers 2

4

From the Oracle docs:

When binding by position (default) to a function, ODP.NET expects the return value to be bound first, before any other parameters.

Picky, I know.

Sign up to request clarification or add additional context in comments.

Comments

0

Try this:

this.userValid = ( (Oracle.DataAccess.Types.OracleBoolean)  parameters[2].Value).IsTrue;

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.