Introduction to Oracle stored procedure parameters

Source: Internet
Author: User

The following articles mainly introduce the parameters related to Oracle stored procedures. The first three functions are input parameters, and the last three functions are output parameters, if you are not familiar with the actual application of parameters related to Oracle stored procedures, the following articles will provide you with relevant knowledge.

 
 
  1. Help.cs:  
  2. public static DataTable ReturnDataTable(int index,string sql,int pageSize)  
  3. {   
  4. DataTable dt = new DataTable();  
  5. try  
  6. {   
  7. OracleParameter []param=new OracleParameter 
    []{new OracleParameter("Pindex",OracleType.Number),
    new OracleParameter("Psql",OracleType.VarChar),
    new OracleParameter("Psize",OracleType.Number),
    new OracleParameter("Pcount",OracleType.Number),
    new OracleParameter("Prowcount",OracleType.Number),
    new OracleParameter("v_cur",OracleType.Cursor)};  
  8. param[0].Value = index;  
  9. param[1].Value = sql;  
  10. param[2].Value = pageSize;  
  11. param[0].Direction = ParameterDirection.Input;  
  12. param[1].Direction = ParameterDirection.Input;  
  13. param[2].Direction = ParameterDirection.Input;  
  14. param[3].Direction = ParameterDirection.Output;  
  15. param[4].Direction = ParameterDirection.Output;  
  16. param[5].Direction = ParameterDirection.Output;   
  17. dt= OracleHelper.ReturnDataTable(OracleHelper.dbCon, 
    CommandType.StoredProcedure, "JT_P_page.Pagination", param);  
  18. Help._rowCount = int.Parse(param[4].Value.ToString());   
  19. }  
  20. catch (OracleException on)  
  21. {  
  22. throw on;   
  23. }   
  24. return dt;  
  25. }   

Note that the parameter name must be consistent with the parameter in the Oracle stored procedure. Otherwise, an error may be returned, for example, new OracleParameter ("Pindex", OracleType. in Number), like Pindex in the Stored procedure Pagination (Pindex in number, Aspnetpage, as a third-party control, is directly downloaded from the internet and then stored in the VS2005 toolbar. after importing the dll, you can use the Update_Agent.aspx.cs file on the front-end page:

 
 
  1. protected void Page_Load(object sender, EventArgs e)  
  2. {  
  3. if (!IsPostBack)  
  4. {  
  5. BindGridView(0, "union_view", _pageSize);   
  6. AspNetPager1.RecordCount = (Help._rowCount >= 0) ? Help._rowCount : 0;   
  7. }   
  8. }  
  9. private void BindGridView(int index, string sql, int pageSize)  
  10. {  
  11. DataTable dt;  
  12. if (sql != "")  
  13. {  
  14. ViewState["IsProcedure"] = "yes";  
  15. dt = Help.ReturnDataTable(index, sql, pageSize);  
  16. }  
  17. else  
  18. {  
  19. ViewState["IsProcedure"] = "no";  
  20. dt = Help.ReturnDataTableByCondition
    (dateinput.Value, dateinput2.Value, 
    orderID.Value.Trim(), dgWay.SelectedValue, 
    AspNetPager1.CurrentPageIndex - 1, AspNetPager1.PageSize);  
  21. }  
  22. iagentView.DataSource = dt;  
  23. DataBind();  
  24. AspNetPager1.RecordCount = (sql!="")?Help._rowCount:
    Help.ReturnRows(dateinput.Value, dateinput2.Value, 
    orderID.Value.Trim(), dgWay.SelectedValue);  
  25. AspNetPager1.PageSize = pageSize;  

The above content is an introduction to the relevant parameters of the Oracle stored procedure. I hope you will find some gains.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.