| Hyderabad Jobs | Book Website | ![]() |
I Love Hyderabad | Hyderabad Colleges |
| Home | Business Emails | Hyderabad Classifieds | Contact Us | |
| 7 Wonders of Hyderabad | Web Hosting | Yellow Pages | Our Network | |
Mastering PowerBuilder
Pipeline Object At WorkPaint a window as shown in the picture below:
The window has a DataWindow dw_error. All the controls in the right hand side are CommandButtons, cb_execute, cb_cancel, cb_repair, cb_close. The rest are StaticText controls. Name the StaticText controls in the bottom which are shown with border as st_read, st_written and st_errors ( from left to right ). Save the window as w_move_to_history. Please note that, no DataWindow object is associated with dw_error DataWindow. Declare the following instance variables:
Write the following code to the window's Open event:
In the above code, we have created a new transaction object. This is require because, we need two transaction objects for the data pipeline execution, one for connecting to the source database and another for connecting to the target database. Actually, we are connecting to the same database "product" in this example. After creating the transaction object, we are populating the values from the SQLCA, since we are connecting to the same database. Similarly, we have created an user object of type uop_copy_to_history. Then we set the instance variables that we have declared in the user object for displaying the status. Write the following code for the window Close event.
In the close event, we are destroying the objects that we have created in the open event.
In this function we are deleting all obsolete products from the product_master table.
In the above code, we are actually executing the pipe object by calling Start() function. This function takes three parameters. Source transaction object, target transaction object and the DataWindow name in which it has to display any errors. PowerBuilder automatically creates the DataWindow depending on the errors and displays in the specified DataWindow. Once copying is successful, we are calling a function in which we deleting all the copied rows from the product_master table. If everything is successful, then we are committing otherwise, we are rolling back the changes. What happens when there is error. PowerBuilder displays all the errors in the DataWindow. User can then do appropriate changes and click on the Repair button.
Repair() function takes the target transaction object as the parameter and applies the changes that are done to the errors in the target database.
If user wants to cancel by any reason, he can do so by clicking on the Cancel CommandButton. We are calling the Cancel() function at the pipeline object and rolling back any changes that are made. That's all. In the open event of the application object, append the following code for testing purpose and run the application.
You will see that 0 rows are copied, since there is no obsolete product. Open the product master window at run-time and prefix few products description with "obsolete" and save it. Then run the pipe object. You might get some errors when you try to delete any products that have transactions. This is because of the referential integrity we have declared using the foreign keys in the database. Just for the purpose of testing, add few new products in the product_master table with "obsolete" prefix in the description and try it.
|
| Copyright © 1996 - 2006 HamaraShehar.com Pvt. Ltd. All Rights Reserved.
Domain Registration, Website Design, Website Hosting by HamaraShehar.com |