tailieunhanh - ODP .NET Developer's Guide oracle database 10g development with visual studio 2005 phần 5

Passing Arrays to and Receiving Arrays from Oracle Database - Có một số phương pháp để gửi thông tin cho cơ sở dữ liệu tôi có thể gửi thông tin bằng cách sử dụng các thông số, XML, mảng kết hợp, Cursors Tài liệu tham khảo, vv Nếu bạn muốn gửi một giá trị duy nhất để cơ sở dữ liệu Oracle, nó là rất dễ dàng bằng cách sử dụng. | Programming with PL SQL As the routine getsalaryGrade accepts one parameter and returns one value the following statements add two parameters one for the input parameter and the other for the return value to OracleCommand . v_grade Nothing Nothing . v_empno Nothing 7839 Once the OracleCommand is executed the value is retrieved using the following statement Dim Result As String _ .Parameters v_grade . Finally the output is displayed using the following statement Succesfully executed with result Result Passing Arrays to and Receiving Arrays from Oracle Database There are several methods to send information to Oracle database. We can send information using parameters XML Associative Arrays Ref Cursors etc. If you would like to send a single value to Oracle database it is very easy by using parameters. If you would like to send several an unknown number of values to Oracle the issue becomes a bit complicated. We may have to use PL SQL packages along with certain Oracle constructs to handle our application requirements. In this section we will cover using associative arrays in to send arrays of information to and receive arrays from Oracle database. Sending an Array to Oracle Database The following package demonstrates the use of the PL SQL table type to receive an array from an application outside the Oracle database CREATE OR REPLACE PACKAGE pck_emp_tabledemo IS TYPE t_num_array IS TABLE OF NUMBER INDEX BY BINARY_INTEGER PROCEDURE IncreaseSalaries v_EmpArray t_num_array v_IncSal number END pck_emp_tabledemo ---------------------------------- 116 --------------------------------- Chapter 5 CREATE OR REPLACE PACKAGE BODY pck_emp_tabledemo IS PROCEDURE IncreaseSalaries v_EmpArray t_num_array v_IncSal number IS BEGIN FOR i IN LOOP UPDATE emp SET sal sal v_IncSal WHERE empno v_EmpArray i

TỪ KHÓA LIÊN QUAN