Click here to Skip to main content
16,017,151 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Here i have a funtion and now i want to pass data for that type from c#. How can i pass variables to type and execute that function.

/*** Function to create wallet by passing customer information ******/
WTPKS_ACCOUT.WTFN_GET_WALLET
( P_CUST_INFO IN WTTP_CUST_INFO
, P_CUST_WALL_ID OUT WTTM_CUST_MASTER.CUST_WALL_ID%TYPE -- VARCHAR2
, P_ERR_CODE OUT VARCHAR2
, P_ERR_MSG OUT VARCHAR2
)
RETURN NUMBER;

TYPE WTTP_CUST_INFO IS RECORD
( CUST_NAME WTTM_CUST_MASTER.CUST_NAME%TYPE
, CUST_PHONE_NO WTTM_CUST_MASTER.CUST_PHONE_NO%TYPE
, CUST_STR_ADDRESS WTTM_CUST_MASTER.CUST_STR_ADDRESS%TYPE
, CUST_PST_ADDRESS WTTM_CUST_MASTER.CUST_PST_ADDRESS%TYPE
, CUST_CITY WTTM_CUST_MASTER.CUST_CITY%TYPE
, EMAIL_ID WTTM_CUST_MASTER.EMAIL_ID%TYPE
, ID_TYPE WTTM_CUST_MASTER.ID_TYPE%TYPE
, ID_NUMBER WTTM_CUST_MASTER.ID_NUMBER%TYPE
, CUST_AC_NO WTTM_CUST_MASTER.CUST_AC_NO%TYPE
, CUST_AC_BANK WTTM_CUST_MASTER.CUST_AC_BANK%TYPE
, CUST_AC_BRN_CODE WTTM_CUST_MASTER.CUST_AC_BRN_CODE%TYPE
, CREATED_BY WTTM_CUST_MASTER.CREATED_BY%TYPE
);
Posted
Comments
Sajith Dilhan 6-Aug-15 2:46am    
Here you can find how to pass parameters to SQL from C# code
http://stackoverflow.com/questions/7542517/call-a-stored-procedure-with-parameter-in-c-sharp
Ambati Dilip 6-Aug-15 3:05am    
Here is my solution tell me what is wrong , while executing it says invalid parameters.

WTTP_CUST_INFO wc = new WTTP_CUST_INFO();
wc.CUST_NAME = "Dilip";
wc.CUST_PHONE_NO = "4545121212";
wc.CUST_STR_ADDRESS = "blablalba";
wc.CUST_PST_ADDRESS = "blalbla";
wc.CUST_CITY = "Bangalore";
wc.EMAIL_ID = "dcccxxx@gmail.com";
wc.ID_TYPE = "Driving License";
wc.ID_NUMBER = "Bvvavava8";
wc.CUST_AC_NO = "";
wc.CUST_AC_BANK = "";
wc.CUST_AC_BRN_CODE = "";
wc.CREATED_BY = "Admin";
OracleConnection conn = new OracleConnection();
OracleCommand cmd = new OracleCommand();
// OracleConnection conn = new OracleConnection();
string strCon = ConnectionString;
OracleParameter Orstr1 = new OracleParameter("P_CUST_INFO", OracleDbType.Object, ParameterDirection.Input);
Orstr1.OracleDbType = OracleDbType.Object;
//Orstr1.UdtTypeName = "WTPKS_ACCOUT.P_CUST_INFO";
Orstr1.Value = wc;
// OracleParameter refcursor = new OracleParameter("P_CUST_WALL_ID", OracleDbType.RefCursor, ParameterDirection.Output);
OracleParameter refcursor = new OracleParameter("P_CUST_WALL_ID", OracleDbType.Varchar2, ParameterDirection.Output);
refcursor.Direction = ParameterDirection.Output;
refcursor.Size = 4000;
OracleParameter Success = new OracleParameter("str1", OracleDbType.Varchar2, ParameterDirection.Output);
Success.Direction = ParameterDirection.Output;
Success.Size = 4000;
OracleParameter SuccessMsg = new OracleParameter("str2", OracleDbType.Varchar2, ParameterDirection.Output);
SuccessMsg.Direction = ParameterDirection.Output;
SuccessMsg.Size = 4000;
cmd.Parameters.Add(Orstr1);
cmd.Parameters.Add(refcursor);
cmd.Parameters.Add(Success);
cmd.Parameters.Add(SuccessMsg);
conn.ConnectionString = strCon;
cmd.CommandType = CommandType.StoredProcedure;
cmd.CommandText = "WTPKS_ACCOUT_1.WTFN_GET_WALLET";
cmd.Connection = conn;
//cmd.CommandText = procedureName;
conn.Open();
// cmd.ExecuteNonQuery();

OracleDataReader rdr;
DataTable dt = new DataTable();
rdr = cmd.ExecuteReader();
Ambati Dilip 6-Aug-15 3:07am    
Replace this line OracleParameter refcursor = new OracleParameter("P_CUST_WALL_ID", OracleDbType.Varchar2, ParameterDirection.Output); to

OracleParameter refcursor = new OracleParameter("WTTP_CUST_INFO", OracleDbType.Varchar2, ParameterDirection.Output);

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900