YOUR FEEDBACK
José D'Andrade wrote: "...it may never be released..." Why? "...if Midori isn’t heir to Windows Mi...
AJAXWorld RIA Conference
$300 Savings Expire August 8
Register Today and SAVE!


2007 West
GOLD SPONSORS:
Active Endpoints
Your SOA Needs BPEL for Orchestration
BEA
Virtualized SOA: Adaptive Infrastructure for Demanding Applications
Nexaweb
Overcoming Bandwidth Challenges with Nexaweb
TIBCO
What is Service Virtualization?
SILVER SPONSORS:
WSO2
Using Web Services Technologies and FOSS Solutions
Click For 2007 East
Event Webcasts

2008 East
PLATINUM SPONSORS:
Appcelerator
Think Fast: Accelerate AJAX Development with Appcelerator
GOLD SPONSORS:
DreamFace Interactive
The Ultimate Framework for Creating Personalized Web 2.0 Mashups
ICEsoft
AJAX and Social Computing for the Enterprise
Kaazing
Enterprise Comet: Real–Time, Real–Time, or Real–Time Web 2.0?
Nexaweb
Now Playing: Desktop Apps in the Browser!
Sun
jMaki as an AJAX Mashup Framework
POWER PANELS:
The Business Value
of RIAs
What Lies Beyond AJAX?
KEYNOTES:
Douglas Crockford
Can We Fix the Web?
Anthony Franco
2008: The Year of the RIA
Click For 2007 Event Webcasts
SYS-CON.TV
POWERBUILDER LINKS YOU MUST CLICK ON


PowerBuilder Standards and Frameworks
Building a better foundation

The ability to call stored procedures or functions in the database as remote procedure calls (RPCFuncs) is very powerful. However, in order to use RPCFuncs, you must create a standard class object of type transaction (you can follow the same instructions as those describing DataStore objects below). Create the object and save it as n_tr in appbase.pbl. Your application can create a descendant of n_tr and declare application-specific RPCFuncs there. Another reason to create an object of type transaction would be to handle transaction management in a more structured way. You can create placeholder functions for of_Begin() and of_End() (either a commit or rollback ends a transaction) as well as coding default implementations for of_Connect(), of_Commit(), and of_Rollback(). Take a look at the PFC object pfc_n_tr in pfcmain.pbl for additional ideas or just copy that object and n_tr from pfemain.pbl to your appbase.pbl. (Note that pfc_n_tr is not decoupled from the rest of the PFC and some slight code modification will be necessary to completely decouple it.)

DataStores do not have DBError event handlers nor can you add functions or other event handlers. However, it is extremely important that you handle database errors when you use DataStores. The way to do this is to create a new object of type DataStore. From the File menu, select New (see Figure 1), then click on the PB Object tab, select Standard Class, specify the target in your workspace in which you want to create the object, and then click OK.

Highlight DataStore in the Standard Class Type list (see Figure 2) and click OK.

You will now be able to write scripts, create functions, add instance variables, etc., in an object of type DataStore that, otherwise, would not have these capabilities. In our case, we know we need to handle the DBError event when we use DataStores. In our base DataStore object we can code the DBError event as indicated in Figure 3. There are additional things you may want to do, such as storing the error code and text values in protected instance variables for later user with a function such a of_GetLastError() that you can add to your DataStore object. Save your DataStore object as n_ds.

Why would I need to have my instance variables scoped as protected rather than just being public or perhaps being private? If they're public, they can be modified by any code that uses n_ds, allowing an easy way to make those variables useless. Since the values are set within the object as a result of an action the object took - a retrieve or update, for example - we want to encapsulate the values within the object. How do we access the values? Through an accessor or getter function we write - in this case, of_GetLastError(). If we wanted the values to be settable by the outside world, we would create a mutator or setter function like of_SetError(integer ai_ErrorCode, string as_ErrorText). On the other hand, we don't want our instance variables to be private because that will prevent any objects that are inherited from this object from accessing the instance variables directly. Descendant objects, in most cases, are pure extensions of the ancestor object and should have full read/write privileges on instance variables declared in the ancestor. If the instance variables were scoped as private, even the descendants would have to call of_GetLastError() to have access to the values. And, if there were no mutator functions, as in our case, the descendant would never be able to modify the values. (If you really get fancy, you can create the instance variables on the ancestor as private and create a protected scope mutator function that the descendants can use. However, you should do this only if the variables to be set need to be validated in the mutator against a very strict and static set of values or ranges that can confidently be built into the ancestor object. It is still better to implement this in a descendant object that may have more specific uses such as this.)

While issuing a rollback before a message box is crucial to ensuring that locks on the database are released as quickly as possible, the problem is determining which transaction object you should reference. However, since this is a base class, you can assume it will be SQLCA and just code rollback, without specifying a transaction object. This can always be overridden at a descendant level. Better yet, create a function, of_SetTransObject(), where you can keep track of the transaction object on which you would need to issue the rollback in case of an error. Declare the transaction object, of type n_tr, as a protected instance variable and name it itr.

After building our base object library, we should have (at least) the following objects:

w_base
w_sheet
n_tr
n_ds
u_dw

This should cover most of the basic objects that we need and provide a foundation on which we can build our application, leaving room for some flexibility and extensibility. Now we're ready to get started.

About Steve Katz
Steve Katz is a senior developer at HSBC Bank USA and has extensive experience developing applications utilizing PowerBuilder, Java, and other technologies. He has used PowerBuilder since v2.0a, taught at Techwave, and even wrote some articles about PowerBuilder a very long time ago.

About Larry Cermak
Larry Cermak is the president of Branick Consulting, Inc., an emerging technology consulting firm specializing in the Sybase products. Larry is a writer for the Sybase Developer Network and PowerBuilder Developer Journal, frequent speaker at Sybase conferences and seminars across the country, and has published the only book available on Web DataWindows. He has been helping customers move PowerBuilder applications to the Web since 1998 and has helped more than 30 companies.

PBDJ LATEST STORIES . . .
The first is Borland. Originally known for their development tools (e.g., Delphi, JBuilder, C++ Builder), in February of 2006 Borland announced they were planning to sell off the Development Tools Group so that they could focus on Application Lifecycle Management (ALM) product offering...
Even the most sceptical observer would be hard pressed to argue that Sybase isn’t making some smart - or at least pretty interesting - moves right now. Bringing in the Sybase 365 division to position the company as the ‘database company with the unique focus on mobile communication...
Sybase has announced the immediate availability of the Sybase Analytic Appliance, configured and tuned to provide extreme analytics and alleviate overburdened data warehouses, data marts and reporting systems. Sybase Analytic Appliance combines Sybase IQ with such technologies as Sybas...
Sybase iAnywhere has announced that SQL Anywhere version 11 on Dell PowerEdge has achieved outstanding price/performance results by delivering an audited TPC-C result at a cost of $0.85 per transaction1, demonstrating that high-performance database applications can be delivered inexpen...
Sybase iAnywhere has announced its new initiative to deliver SQL Anywhere for the web developer community. In addition to a number of web development features found in SQL Anywhere Version 11, its newest release, the company has also unveiled a new Web Edition that allows developers fr...
Sybase iAnywhere has announced that SQL Anywhere version 11 is now available to the marketplace. With more than 10 million deployed seats, SQL Anywhere is designed to be widely deployed in environments with little or no onsite IT support. Thousands of application partners worldwide emb...
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
BREAKING POWERBUILDER / SYBASE NEWS

Kurtosys Systems Inc. announces that Mike Loo has been appointed Chief Financial Of...