Oow2009 Plsqltiptricksanddebugging 133700
Oow2009 Plsqltiptricksanddebugging 133700
PL/SQL Development
Lifecycle with Visual
Studio
SQL and PL/SQL Development Lifecycle
PL/SQL Lifecycle
<Insert Picture Here>
• Data Types
– PL/SQL Types
– REF Cursor
– Associative Array (formerly index-by table)
• ODP.NET Types vs. .NET types
– OracleParameter.DbType
– OracleParameter.OracleDbType
– .NET DataSet can store ODP.NET types
• Available in ADO.NET 2.0
• OracleDataAdapter.ReturnProviderSpecificTypes = true
D E M O N S T R A T I O N
Hello PL/SQL
Batching SQL and deferring fetching
• Characteristics
– Pointer to result set on server side
– Read only
– Forward only
• Advantages
– Input REF Cursor parameters
– Retrieve multiple REF Cursors in a single round trip
D E M O N S T R A T I O N
REF Cursors
Anonymous PL/SQL
//
// C#
C#
string
string cmdtxt
cmdtxt == "BEGIN
"BEGIN "" ++
"OPEN
"OPEN :1
:1 for
for select
select ** from
from emp
emp where
where deptno
deptno == 10;
10; "" ++
"OPEN
"OPEN :2
:2 for
for select
select ** from
from dept
dept where
where deptno
deptno == 20;
20; "" ++
"INSERT
"INSERT INTO
INTO DEPT
DEPT VALUES
VALUES (50,
(50, ‘IT',
‘IT', ‘SAN
‘SAN FRANCISCO');"
FRANCISCO');" ++
"END;";
"END;";
D E M O N S T R A T I O N
Anonymous
PL/SQL
Passing large amounts of data
• Characteristics
– Must declare size of array
– Index key must be sequential
– Index key must be non-negative integers
• Advantages
– Pass large amount of data between the DB and .NET in one
array
• Reduces number of parameters
• Reduces round trips
• Easier batch processing
Using Associative Arrays in .NET
Associative
Arrays
Using Pre-Defined PL/SQL Packages
pa.StatusArray
pa.StatusArray == new
new OracleUdtStatus[]
OracleUdtStatus[] {{
OracleUdtStatus.NotNull….
OracleUdtStatus.NotNull….
param.OracleDbType
param.OracleDbType == OracleDbType.Array;
OracleDbType.Array;
param.Direction
param.Direction == ParameterDirection.Input;
ParameterDirection.Input;
param.UdtTypeName
param.UdtTypeName == “MYVARRAY";
“MYVARRAY";
param.Value = pa;
param.Value = pa;
<Insert Picture Here>
Connect user/pass
Oracle Developer
Tools for VS.NET Oracle
ORA_DEBUG_JDWP= 9.2 or
later
host=hostname;port=portnum
Visual
Visual Studio
Studio
Environment
Environment Da PL/SQL
tab Debug
as Engine
“Step Over Please”, ec
on
“Step Into <p nec ---
Please”, “What are or ts
tn t o Current
the local variable um V
values?” > So Line
np number
or
t
Variable
Values
PL/SQL Debugging Configuration
PL/SQL
Debugging
External Application Debugging
External PL/SQL
Debugging
Advanced Debugging
DBMS_DEBUG_JDWP Package
Next Steps
.NET Hands On Lab!
or
search.oracle.com
The preceding is intended to outline our general
product direction. It is intended for information
purposes only, and may not be incorporated into any
contract. It is not a commitment to deliver any
material, code, or functionality, and should not be
relied upon in making purchasing decisions.
The development, release, and timing of any
features or functionality described for Oracle’s
products remains at the sole discretion of Oracle.