PL/SQL Programming for.net Developers: Tips, Tricks, and Debugging. Christian Shay Product Manager, Oracle

Similar documents
Copyright 2013, Oracle and/or its affiliates. All rights reserved.

Copyright 2013, Oracle and/or its affiliates. All rights reserved.

Best Practices for Performance Part 2.NET and Oracle Database

Best Practices for Performance Part 1.NET and Oracle Database

1 Copyright 2011, Oracle and/or its affiliates. All rights reserved.

Getting Started with Oracle and.net

Oracle and.net: Best Practices for Performance. Christian Shay & Alex Keh Product Managers Oracle October 28, 2015

Copyright 2013, Oracle and/or its affiliates. All rights reserved.

<Insert Picture Here> Getting Started with Oracle and.net

Copyright 2012, Oracle and/or its affiliates. All rights reserved.

What s New for.net Developers in Oracle Database

Oracle and.net Introduction and What s New. Copyright 2017, Oracle and/or its affiliates. All rights reserved.

Getting Started with Oracle and.net

Best Practices for Performance

<Insert Picture Here> What's New for.net Developers for Oracle Database

What s New with Oracle Database 12c on Windows: On-Premises and in the Cloud

<Insert Picture Here> Oracle SQL Developer: PL/SQL Support and Unit Testing

Copyright 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 13

Contents I Introduction 1 Introduction to PL/SQL iii

What s New for Oracle Database 11gR2 on Windows?

Pro ODP.NET for Oracle. Database 11 g. Edmund Zehoo. Apress

Using.NET Core and Entity Framework Core Linux/Windows with Oracle Database

<Insert Picture Here> Maximizing Database Performance: Performance Tuning with DB Time

The following is intended to outline our general product direction. It is intended for information purposes only, and may not be incorporated into

Oracle Database 12c: Program with PL/SQL Duration: 5 Days Method: Instructor-Led

<Insert Picture Here> Active Directory and Windows Security Integration with Oracle Database

DB2 for z/os: Programmer Essentials for Designing, Building and Tuning

Safe Harbor Statement

Oracle Database: Program with PL/SQL

Oracle Database: Program with PL/SQL Ed 2

Oracle Database 12c R2: Program with PL/SQL Ed 2 Duration: 5 Days

Conditionally control code flow (loops, control structures). Create stored procedures and functions.

Implementing and Maintaining Microsoft SQL Server 2008 Integration Services

Learn Well Technocraft

Oracle - Oracle Database: Program with PL/SQL Ed 2

Real Application Security Administration

Introduction to Web Development with Microsoft Visual Studio 2010

2310C VB - Developing Web Applications Using Microsoft Visual Studio 2008 Course Number: 2310C Course Length: 5 Days

The Fastest and Most Cost-Effective Backup for Oracle Database: What s New in Oracle Secure Backup 10.2

APEX Times Ten Berichte. Tuning DB-Browser Datenmodellierung Schema Copy & Compare Data Grids. Extension Exchange.

Oracle PLSQL Training Syllabus

Oracle PLSQL. Course Summary. Duration. Objectives

Using Automatic Workload Repository for Database Tuning: Tips for Expert DBAs. Kurt Engeleiter Product Manager

Oracle APEX 18.1 New Features

Oracle Database. Installation and Configuration of Real Application Security Administration (RASADM) Prerequisites

Mobile Application Development: Introducing ADF Mobile Native Client Framework

ORACLE TRAINING. ORACLE Training Course syllabus ORACLE SQL ORACLE PLSQL. Oracle SQL Training Syllabus

Using SQL Developer. Oracle University and Egabi Solutions use only

<Insert Picture Here> DBA s New Best Friend: Advanced SQL Tuning Features of Oracle Database 11g

Oracle Database 11g: Program with PL/SQL Release 2

Developing Microsoft.NET Applications for Windows (Visual Basic.NET)

ASP.NET Web Forms Programming Using Visual Basic.NET

Introduction to Web Development with Microsoft Visual Studio 2010

TipsandTricks. Jeff Smith Senior Principal Product Database Tools, Oracle Corp

New Features PowerBuilder 12.0

Oracle Database: Introduction to SQL/PLSQL Accelerated

Build and Deploy Stored Procedures with IBM Data Studio

Oracle SQL Developer & REST Data Services

1 Copyright 2013, Oracle and/or its affiliates. All rights reserved.

Developing Web Applications Using Microsoft Visual Studio 2008 SP1

This presentation is for informational purposes only and may not be incorporated into a contract or agreement.

Oracle Developer Track Course Contents. Mr. Sandeep M Shinde. Oracle Application Techno-Functional Consultant

1 Copyright 2011, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 8

IZ0-144Oracle 11g PL/SQL Certification (OCA) training

Using Active Session History for Performance Tuning: Advanced Topics in Performance Diagnostics

"Charting the Course... MOC A Introduction to Web Development with Microsoft Visual Studio Course Summary

<Insert Picture Here> Scale your PHP Application to Tens of Thousands of Connections

1 Copyright 2011, Oracle and/or its affiliates. All rights reserved.

NoSQL + SQL = MySQL Get the Best of Both Worlds

Creating and Working with JSON in Oracle Database

10267 Introduction to Web Development with Microsoft Visual Studio 2010

Toad Data Point - Professional Edition. The Toad Data Point Professional edition includes the following new features and enhancements.

Copyright 2018, Oracle and/or its affiliates. All rights reserved.

10267A CS: Developing Web Applications Using Microsoft Visual Studio 2010

Maximum Availability Architecture (MAA): Oracle E-Business Suite Release 12

APEX installation on Linux - Step by Step

Oracle Application Express: Administration 1-2

Oracle Database 11g Production Case Study: Porting to Oracle Database 11 - Tips, Techniques, and Experiences

Introduction to Oracle Objects

DB2 for z/os Stored Procedures Update

Microsoft Official Courseware Course Introduction to Web Development with Microsoft Visual Studio

Version Installation Guide. 1 Bocada Installation Guide

<Insert Picture Here> Looking at Performance - What s new in MySQL Workbench 6.2

Microsoft Visual Studio.NET. Anil Mahadev. Database Enthusiast and Oracle User

Extend EBS Using Applications Express

Create a DBaaS Catalog in an Hour with a PaaS-Ready Infrastructure

<Insert Picture Here>

COURSE OUTLINE: OD10267A Introduction to Web Development with Microsoft Visual Studio 2010

Introduction to Microsoft.NET Programming Using Microsoft Visual Studio 2008 (C#) Course Overview. Prerequisites. Audience.

SQL Gone Wild: Taming Bad SQL the Easy Way (or the Hard Way) Sergey Koltakov Product Manager, Database Manageability

This presentation is for informational purposes only and may not be incorporated into a contract or agreement.

Introduction to Microsoft.NET Framework Programming using VS 2005 (C#)

<Insert Picture Here> Making the Most of PeopleSoft Query

Oracle Database Express Edition

Introduction to SQL/PLSQL Accelerated Ed 2

Course Outline: Course 10267A: Introduction to Web Development with Microsoft Visual Studio 2010 Learning Method: Instructor-led Classroom Learning

Unleash the power of Essbase Custom Defined Functions

Introduction to Programming Microsoft.NET Framework Applications with Microsoft Visual Studio 2005 (C#)

[Contents. Sharing. sqlplus. Storage 6. System Support Processes 15 Operating System Files 16. Synonyms. SQL*Developer

Data Integration and ETL with Oracle Warehouse Builder

Transcription:

1

PL/SQL Programming for.net Developers: Tips, Tricks, and Debugging Christian Shay Product Manager, Oracle

Program Agenda PL/SQL Development Lifecycle in VS Using PL/SQL with ODP.NET Introduction PL/SQL Data Types Mapping in.net Anonymous PL/SQL Blocks Using Oracle Supplied PL/SQL Packages in.net VARRAYs and Nested Tables PL/SQL Debugging in Visual Studio Next Steps <Insert Picture Here> 3

SQL and PL/SQL Development Lifecycle Create Users, and Roles and grant privileges to them User and Role Designers Grant and Revoke Privileges Wizard Create Schema Objects, PL/SQL procedures, functions, packages Oracle Wizards Query Window Ad Hoc SQL Run SQL*Plus Scripts for existing scripts Import Table Wizard 4

SQL and PL/SQL Development Lifecycle Create SQL and PL/SQL scripts Generate Create Script from existing schema objects Use Schema Compare tool to generate diff script Store scripts in source control Oracle Database Project 5

SQL and PL/SQL Development Lifecycle Edit SQL and PL/SQL Scripts Oracle SQL Editor file based Oracle PL/SQL Editor database based Tune SQL Oracle Performance Analyzer SQL Tuning Advisor 6

SQL and PL/SQL Development Lifecycle Create client side.net code (C#, VB.NET, ASP.NET) Use Oracle Data Provider for.net to call PL/SQL Debug.NET and PL/SQL together PL/SQL Debugger in Visual Studio Deploy 7

Oracle s.net Products Oracle Developer Tools for Visual Studio Tightly integrated Add-in for Visual Studio 2012, 2010, 2008 Oracle Data Provider for.net (ODP.NET) ADO.NET compliant data provider Native access to Oracle database Utilize advanced Oracle Database features RAC, performance, security, data types, XML, etc. Both available for free download: http://otn.oracle.com/dotnet/ 8

D E M O N S T R A T I O N PL/SQL Lifecycle 9

Program Agenda PL/SQL Development Lifecycle in VS Using PL/SQL with ODP.NET Introduction PL/SQL Data Types Mapping in.net Anonymous PL/SQL Blocks Using Oracle Supplied PL/SQL Packages in.net VARRAYs and Nested Tables PL/SQL Debugging in Visual Studio Next Steps <Insert Picture Here> 10

Introduction Any PL/SQL Call is Supported Stored Procedure Stored Function Package Method Anonymous block Batch SQL support 11

PL/SQL Data Types Available in.net 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 OracleDataAdapter.ReturnProviderSpecificTypes = true 12

D E M O N S T R A T I O N Hello PL/SQL 13

Batching SQL and deferring fetching You want to execute SQL queries in Stored Procedures and then fetch as needed from the client You want to batch SQL multiple SQL statements in one PL/SQL anonymous block Solution: Use REF CURSORS and Anonymous PL/SQL 14

REF Cursors 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 15

D E M O N S T R A T I O N REF CURSORS 16

Passing large amounts of data You want to pass in or retrieve large amounts of data in one round trip with best performance possible You are using scalar types Solution: Use associative arrays 17

Associative Arrays 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 18

Using Associative Arrays in.net Steps to bind an associative array parameter Set OracleParameter.CollectionType to OracleCollectionType.PLSQLAssociativeArray Set OracleParameter.ArrayBindSize for *each* array element Only necessary for variable-length data types Set OracleParameter.Size for number of array elements 19

D E M O N S T R A T I O N Associative Arrays 20

Anonymous PL/SQL Executes multiple SQL statements in a single batch Saves DB round trips Execute as CommandType.Text Generate dynamically based on application requirements string cmdtxt = "BEGIN " + "OPEN :1 for select * from emp where deptno = 10; " + "OPEN :2 for select * from dept where deptno = 20; " + "INSERT INTO DEPT VALUES (50, IT', SAN FRANCISCO');" + "END;"; 21

D E M O N S T R A T I O N Anonymous PL/SQL 22

Using Pre-Defined PL/SQL Packages DB server provides PL/SQL packages to all of Oracle s key functionality Can be used from ODP.NET, similar to any other PL/SQL call Sample pre-packaged functionality DBMS_AQ DBMS_OLAP DBMS_STREAMS SDO_GEOM 23

VARRAYs and NESTED TABLES Supported as of ODAC 11g Use Custom Class Code Generation wizard Check out code samples in directory <OH>\odp.net\samples\4.x\UDT 24

VARRAYs and NESTED TABLES MyVarrayCustomClass pa = new MyVarrayCustomClass(); pa.array = new Int32[] { 1, 2, 3, 4 }; pa.statusarray = new OracleUdtStatus[] { OracleUdtStatus.NotNull. param.oracledbtype = OracleDbType.Array; param.direction = ParameterDirection.Input; param.udttypename = MYVARRAY"; param.value = pa; 25

Program Agenda PL/SQL Development Lifecycle in VS Using PL/SQL with ODP.NET Introduction PL/SQL Data Types Mapping in.net Anonymous PL/SQL Blocks Using Oracle Supplied PL/SQL Packages in.net VARRAYs and Nested Tables PL/SQL Debugging in Visual Studio Next Steps <Insert Picture Here> 26

Oracle PL/SQL Debugging Architecture Oracle Developer Tools for Visual Studio Visual Studio Environment VS sends requests to Oracle over TCP/IP connection: Step Into Please What are the local variable values? Set Breakpoint here Connect user/pass When connect to Oracle we pass: ORA_DEBUG_JDWP= host=hostname;port=portnum Oracle 9.2 or later PL/SQL Debugging Engine Does all the work of debugging 27

PL/SQL Debugging Configuration Can be tricky the first time since so many steps Check out the PL/SQL Debugging Chapter in ODT doc Debugging Setup Checklist See ODT release notes for known issues <ORACLE_HOME>\odt\doc\readme.html 28

D E M O N S T R A T I O N PL/SQL Debugging Doc 29

PL/SQL Debugging Configuration GRANT debug privileges as SYSDBA 9.2 or later: GRANT DEBUG ANY PROCEDURE TO username, and 10g or later also requires: GRANT DEBUG CONNECT SESSION TO username Set port range and IP in Debugging Options page Tools -> Options->Oracle Developer Tools Compile PL/SQL units for Debug Via menu in PL/SQL editor or in Oracle Explorer 30

PL/SQL Debugging Configuration New requirement in 12c: SYSDBA must grant ACL access on IP Address Port Range Schema name Use new Grant Debugging Privileges dialog Right click on Schema name to be granted both debugging roles and the ACL privileges 31

PL/SQL Debugging Configuration Or issue this PL/SQL as SYSDBA: BEGIN DBMS_NETWORK_ACL_ADMIN.APPEND_HOST_ACE( HOST => 127.0.0.1', LOWER_PORT => 65000, UPPER_PORT => 65300, ACE => XS$ACE_TYPE(PRIVILEGE_LIST => XS$NAME_LIST('jdwp'), PRINCIPAL_NAME => 'HR', PRINCIPAL_TYPE => XS_ACL.PTYPE_DB)); END; 32

Direct Database Debugging Debug directly inside the database, no application code Step Into from Server Explorer Run Debug from Server Explorer Enter parameters manually Not useful with array parameters or complex types 33

Application Debugging Mode Step from.net code into PL/SQL and back from one instance of Visual Studio Useful for client server code (not web apps) Check off Tools -> Oracle Application Debugging ODT automatically starts listener using port in range given in Options page Uncheck "Enable the Visual Studio hosting process" in the.net Project Properties Debug tab 34

D E M O N S T R A T I O N Direct and App Debugging 35

External Application Debugging Dedicated VS instance for debugging PL/SQL only Use additional VS instance for any.net code (eg ASP.NET app) 10.2 client or later running on ANY platform Set ORA_DEBUG_JDWP in client environment SET ORA_DEBUG_JDWP=host=mymachine;port=4444 Set in web app environment BEFORE connecting Start Listener Tools-> Start Oracle External Application Debugger 36

D E M O N S T R A T I O N External PL/SQL Debugging 37

Advanced Debugging DBMS_DEBUG_JDWP Package Allows you to pick and choose when debugging is turned on Enable External Application Debugging Provide port number and IP address 38

Advanced Debugging DBMS_DEBUG_JDWP Package Add calls to these PL/SQL Procedures to your SP: DBMS_DEBUG_JDWP CONNECT_TCP(HOST VARCHAR2, PORT VARCHAR2) DBMS_DEBUG_JDWP.DISCONNECT Compile Debug Set Breakpoint Call SP from external application 39

Next Steps 40

Upcoming.NET Sessions Wednesday Sept 25 ALM with Visual Studio: SQL and PL/SQL Development, Source Control, and Deployment 3:30 PM - 4:30 PM, Marriott Marquis - Golden Gate C2 Oracle Database 12c on Windows 5:00 PM 6:00 PM, Moscone South - 104 41

Upcoming.NET Sessions Thursday Sept 26 Hands-on Lab: Building.NET Applications with Oracle 11:00 AM - 1:30 PM, Marriott Marquis - Salon 3/4 Oracle and.net: Best Practices for Performance and Deployment 2:00 PM - 3:00 PM, Marriott Marquis - Golden Gate C2 42

Visit.NET Experts at the Demogrounds Monday through Wednesday.NET Development for Oracle Database 12c Moscone South, Left Rear in Oracle Database Section Booth # SL-044 43

Additional Oracle.NET Resources OTN.NET Developer Center http://otn.oracle.com/dotnet Twitter @OracleDOTNET YouTube http://www.youtube.com/user/oracledotnetteam For more questions christian.shay@oracle.com 44

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. 45

46

47