Database Reference
In-Depth Information
HIRE_DATE : 6/7/2002 12:00:00 AM
JOB_ID : HR_REP
JOB_TITLE : Human Resources Representative
SALARY : 6500
COMMISSION_PCT :
MANAGER_ID : 101
MANAGER_NAME : Neena Kochhar
DEPARTMENT_ID : 40
DEPARTMENT_NAME : Human Resources
LOCATION_ID : 2400
STREET_ADDRESS : 8204 Arthur St
POSTAL_CODE :
CITY : London
STATE_PROVINCE :
COUNTRY_ID : US
How it works...
The New-Connection function is slightly different than past connecting code in that it
deines the connection string in the same method and doesn't automatically open the
connection it creates.
New-ProcCommand expects a procedure name and an array of OracleParameter objects
and it creates the command, sets the command text to the procedure name, creates and
associates the OracleConnection object, set the command type, adds each parameter to
the Parameters collection, and returns the command.
The New-Param helper method saves some typing when creating OracleParameter
methods later via creating the object and defaulting some of the property values such as
size and duration. Likewise the New-CursorParameter goes a step further with setting the
parameter type and direction as well.
Get-ProcReader makes the call to create the command object. As it doesn't control the
creation of the command or connection, it also checks the state of connection and opens it if
it isn't open, though the connection would always be closed with the current deinition of the
functions. Finally it invokes the procedure with ExecuteReader and prevents unrolling the
returned results with the leading comma, as a data reader return value is expected.
Get-EmployeeDataset sets the procedure name and the array of OracleParameter
objects that Get-ProcReader expects. It also sets up a new DataSet via adding
DataTable s where the Ref Cursor results from the procedure will be stored. The DataSet
and DataTable s are given friendly names to make working with the results easier. Further
DataSet set up may often be desirable, this is a minimum. The data tables are then loaded
with the reader, in the order the cursors are opened in the database procedure. Finally the
clean up is done, the DataSet is returned, the function is invoked, and results are output.
 
Search WWH ::




Custom Search