Comments
litl_phil wrote: While it's nice that Google and Acer share the vision of cloud-based computing, it's also worth noting that we at litl already have a webbook on the market (available at litl.com) that runs our own cloud-based OS. Unlike Chrome, litlOS is focused on creating a new and better web experience for the home, so we don't have the usual browser interface, we have our own innovative UI. In conjunction with easel mode (litl's inverted-V position) and our growing cohort of litl channels (special apps t...
Cloud Expo on Google News


2008 West
DIAMOND SPONSOR:
Data Direct
SOA, WOA and Cloud Computing: The New Frontier for Data Services
PLATINUM SPONSORS:
Red Hat
The Opening of Virtualization
GOLD SPONSORS:
Appsense
User Environment Management – The Third Layer of the Desktop
Cordys
Cloud Computing for Business Agility
EMC
CMIS: A Multi-Vendor Proposal for a Service-Based Content Management Interoperability Standard
Freedom OSS
Practical SOA” Max Yankelevich
Intel
Architecting an Enterprise Service Router (ESR) – A Cost-Effective Way to Scale SOA Across the Enterprise
Sensedia
Return on Assests: Bringing Visibility to your SOA Strategy
Symantec
Managing Hybrid Endpoint Environments
VMWare
Game-Changing Technology for Enterprise Clouds and Applications
Click For 2008 West
Event Webcasts

2008 West
PLATINUM SPONSORS:
Appcelerator
Get ‘Rich’ Quick: Rapid Prototyping for RIA with ZERO Server Code
Keynote Systems
Designing for and Managing Performance in the New Frontier of Rich Internet Applications
GOLD SPONSORS:
ICEsoft
How Can AJAX Improve Homeland Security?
Isomorphic
Beyond Widgets: What a RIA Platform Should Offer
Oracle
REAs: Rich Enterprise Applications
Click For 2008 Event Webcasts
SYS-CON.TV
Top Links You Must Click On


PBDJ Cover Story — A DataWindow Based on Oracle Stored Procedures with a Result Set
In DataWindow.NET 2.0, Sybase added support for access to Oracle

In DataWindow.NET 2.0, Sybase added support for access to Oracle through the Oracle managed data provider (ODP.NET). A managed data provider provides better performance and more support than a non-managed driver for database-specific functions, though not as much as the Oracle native driver.

On the other hand, the managed data provider can still utilize ADO features of the .NET Framework (including connection caching), which native drivers cannot. In addition, Oracle recently added support to ODP.NET for returning REF CURSORS from Oracle stored procedures. That opens up the possibility of using Oracle stored procedures as the data source for a DataWindow.NET DataWindowObject.

Unfortunately, the ADO.NET driver provided with DataWindow.NET currently doesn't support that functionality. Therefore, our demonstration to implement such functionality will still use the native drivers. At some point, when the ADO.NET driver supports this functionality, the techniques shown in this article should still be applicable.

Bruce Armstrong provided an excellent description of using the DataWindow with Oracle stored procedures in his article "Using Oracle Stored Procedures in Your DataWindows" (PBDJ, Vol. 10, issue 2). It has a detailed explanation of the REF CURSOR concept, which is the key to the solution. The main ideas of that article are still the same for both DataWindows in PowerBuilder and DataWindow.NET. Therefore, we won't discuss the theory, but instead focus on a practical example.

Oracle Stored Procedure Example
A standard Oracle installation has a special SCOTT scheme for demonstration and learning purposes. If you don't have it, the script for this scheme installation could be found in <ORACLE_DB>\RDBMS\ADMIN\scott.sql. In our example, we want to create a stored procedure that returns a list of employees for a given department.

REF CURSOR ORACLE TYPE
For our procedure we need a special Oracle type called a REF CURSOR. We can create this type in any package. An example of such a package is provided in Listing 1.

We need only one ref cursor because we can use the same ref cursor for all procedures; that's why we use an unconstrained ref cursor. At the end of Listing 1, we granted access to our package (and our ref cursor) to every database user.

STORED PROCEDURE
The Oracle stored procedure with the result set can contain any number of input parameters, but the last one should be declared as an IN OUT ref cursor. In Listing 2, we can see the procedure SCOTT.EMP_BY_DEPT. This procedure has two arguments. The first argument (P_DEPTNO) is a department number and it's declared as IN INTEGER. The second argument (P_RESULTSET) is declared as IN OUT SCOTT.MYCURSOR.CURTYPE. This is the type we created in Listing 1.

We can populate the cursor many different ways, but the simplest one is OPEN cursor FOR SELECT.

Sybase DataWindow.NET 2.0 Example
Let's create a simple WinForms application using our procedure. For this purpose, we can create a new project using the Windows Application template. Add a combo-box for the Department selection and a DataWindowControl to show the list of employees from the chosen department.

Sybase DataWindow.NET has two classes for a database connection: AdoTransaction and Transaction. The AdoTransaction class is used for managed and unmanaged ADO.NET providers. However, since it currently doesn't handle REF CURSOR from the stored procedure, we will be using the Transaction class only.

DataWindow
In the Sybase DataWindow Designer, we should connect to Oracle using either O10 Oracle 10g or O90 Oracle 9i interface. Then we can create a new DataWindow d_emp_by_dept based on our stored procedure and put it into demo.pbl library.

REFERENCES
Next we add the references shown in Table 1 to our project.

INSTANCE VARIABLES
Next, put instance variables to the Form1 class declaration.

public partial class Form1 : Form
{
    private string m_ConnectionString = null; // Connection string
    private DataSet m_DeptDS = new DataSet(); // Dataset for Departments
    private Transaction m_Trans = new Transaction();// Sybase transaction object

CONNECTION SETTINGS
It's not a good idea to place the hard-coded connection strings into code, but we do so to simplify our example.

private void Form1_Load(object sender, EventArgs e)
{
    // Connection string
    this.m_ConnectionString = "Data Source=;User ID=SCOTT;Password=TIGER;";

    // Connection parameters
    this.m_Trans.DbParameter = "ConnectString=\'" + this.m_ConnectionString + "\'";
    this.m_Trans.Dbms = DbmsType.Oracle10g;
    this.m_Trans.UserId = "SCOTT";
    this.m_Trans.Password = "TIGER";
    this.m_Trans.ServerName = ""; // put TNS-service name here

LIST OF DEPARTMENTS
We want to allow the user to select a Department from the list and use the Department Number as a first argument to our procedure. For this purpose we can use either standard WinForms Combobox or a DataWindow with a single column and a DropDownDataWindow (dddw) presentation style.

The second solution is better, because it's simpler and allows you to avoid the hard coding of Oracle classes, which in turn provides an opportunity to create a program that supports different database vendors. However, this is not as obvious to .NET developers as it is to PowerBuilder ones, so we will populate Combo-box with the example in Listing 3.

SHOW LIST OF EMPLOYEES FOR THE CHOSEN DEPARTMENT
To get the data we need to connect to the database, retrieve data and disconnect at the end. The script to do this is shown in Listing 4.

RESULT
We can see the result of our application in Figure 1.

Conclusion
It is possible to create a stored procedure-based DataWindow for Oracle as easily as it is for other database vendors. Using Sybase DataWindow.NET 2.0, you can make it transparent for developers and hide Oracle-specific details from the client side, so the same application can be used to access several different DBMS from different vendors.

References

About Mikhail Klygin
Mikhail Klygin is a senior developer and has been using PowerBuilder since version 5.0.

In order to post a comment you need to be registered and logged in.

Register | Sign-in

Reader Feedback: Page 1 of 1

In DataWindow.NET 2.0, Sybase added support for access to Oracle through the Oracle managed data provider (ODP.NET). A managed data provider provides better performance and more support than a non-managed driver for database-specific functions, though not as much as the Oracle native driver.


Your Feedback
PBDJ News Desk wrote: In DataWindow.NET 2.0, Sybase added support for access to Oracle through the Oracle managed data provider (ODP.NET). A managed data provider provides better performance and more support than a non-managed driver for database-specific functions, though not as much as the Oracle native driver.
Enterprise Open Source Magazine Latest Stories . . .
Oracle seems to have divided the open source ranks over the MySQL delay it’s having closing its acquisition of Sun. Eben Moglin, the GPL’s most ardent defender and delineator, the lawyer who has worked hand in glove for years with the Free Software Foundation’s founder Richard Stallman...
Cloud computing is a game changer. The cloud is disrupting traditional software and hardware business models by disrupting how IT service gets delivered. Entrepreneurial opportunities abound as this classic disruptive technology begins to proliferate, so it is no surprise that SYS-CON'...
The irony is that Oracle has advanced MySQL, lost money in the process, and helped its competitors - all at the same time. When Oracle buys Sun and controls MySQL the gift (other than to Microsoft SQL Server) keeps on giving as the existential threat to RDBs is managed by Redwood Shore...
WSO2, the open source SOA company, today announced the launch of the WSO2 Cloud Platform. Available today, the new WSO2 Cloud Platform features a family of WSO2 Cloud Virtual Machines; WSO2 Cloud Connectors for enabling fast, secure cloud services; and the multi-tenant WSO2 Governance-...
Now, the open source Mozilla Thunderbird client software can be used with Open-Xchange collaboration software. The "Community OXtender for Thunderbird" software connector gives users full access to appointments and contacts stored in the Open-Xchange Server and enables them to use Thun...
Morph Labs, a leading provider of enterprise cloud computing technology, today announced an introductory trial of the Morph CloudServer, an open, standards-based server IT organizations can use to rapidly model and evaluate their cloud implementations. A miniature "Cloud Environment in...
Subscribe to the World's Most Powerful Newsletters
Subscribe to Our Rss Feeds & Get Your SYS-CON News Live!
Click to Add our RSS Feeds to the Service of Your Choice:
Google Reader or Homepage Add to My Yahoo! Subscribe with Bloglines Subscribe in NewsGator Online
myFeedster Add to My AOL Subscribe in Rojo Add 'Hugg' to Newsburst from CNET News.com Kinja Digest View Additional SYS-CON Feeds
Publish Your Article! Please send it to editorial(at)sys-con.com!

Advertise on this site! Contact advertising(at)sys-con.com! 201 802-3021


SYS-CON Featured Whitepapers
ADS BY GOOGLE