|
Comments
|
Today's Top SOA Links
Techniques Little Known, But Incredibly Useful, PowerBuilder Tips and Tricks
Techniques you can rely on
By: Lynn Hardin
Aug. 13, 2006 03:45 PM
My presentation at TechWave 2006 is intended for the beginner or the moderately experienced PowerBuilder developer. I hope to share some of the useful tips and tricks I have picked up in my 12 years as a PowerBuilder developer.
Converting a Tabular DataWindow to a Grid DataWindow When you select Edit Source, a script editor window opens (see Figure 2). The "processing" variable controls the presentation style of grid versus tabular. Change this to 1 and the DataWindow is a grid; change it to 0, and the DataWindow is tabular.
Changing the Source of a DataWindow from a Select to a Stored Procedure Make sure the entire line is selected. Copy this line to the clipboard, then locate the DataWindow that you wish to convert to a stored procedure. Again select Edit Source and locate the line that begins with "retrieve." It is critical that you select the entire line (it may be several lines). Now replace the entire retrieve statement with the line already on the clipboard. Close the script editor and you will now have a stored procedure-based DataWindow. Why is this useful? This technique allows you to preserve an elaborate GUI in a DataWindow while still utilizing the power of stored procedures. This is particularly important if you have a lot of DataWindows that are based on SQL statements and you start having performance issues as your database grows. Not only does this technique save many, many hours of developer time, it also completely preserves the GUI so users won't notice the change at all.
Updating a DataWindow Using a Stored Procedure On each tab, select the stored procedure that will be used for each update operation: insert, update, or delete. PowerBuilder will produce a line for each of the arguments of the stored procedure. Specify which columns of the DataWindow are used for each argument. If you look at the update properties after specifying a stored procedure update, you'll see the words "Stored Procedure" where a table name would normally be. The stored procedure update is an excellent option if you will be updating more than one table. Anyone who has utilized resetting the update flags, etc., to perform a multitable update will certainly find this to be extremely valuable.
Fetching from a Stored Procedure in PowerScript
OpenUserObjectWithParm The following line of code in the open event of the window will create a userobject of type uo_drop_down_calendar at an x, y position of 25, 50 and entitle it "Begin Date'. OpenUserObjectWithParm(iuo_begin, 'Begin Date', 25, 50) There are many other uses for this technique.
SQL Tool All of the database tables and columns are available in dropdown DataWindows so that SQL statements can be constructed easily without having to remember column names. A statement can be named and saved for future use. So, for example, let's say your user must find all the address types available in the database. Since this is very simple, you could talk him or her through the creation of the statement. The user would type the SQL statement into the DataWindow and click "Execute" and the results would then appear in the lower area. The user can then Save this data to Excel, etc.... Should a user require a more elaborate statement, you can write the statement and e-mail it. The user can paste it into the window and execute. This can be used to clean up a data problem, to create and run stored procedures, to create an ad hoc report, to grant permissions, most anything you can do from an enterprise manager. This tool has been extremely useful, however, it must be tightly secured so that a user does not create a Cartesian product or update data maliciously.
Saving a Dynamically Created DataWindow in Your Application When the user executes this script, the stored procedure is created (see Figure 6). You can then tell them the values of the variables to use, and the procedure can be executed. The results will show in the result set window. Now suppose you want to save this result set as a DataWindow. Access the DataWindow tab and click "Create DataWindow" (see Figure 7). Now click "Retrieve DataWindow" and the same result set appears. If you wish to have this DataWindow saved to use later, click "Save DataWindow". You can format it as appropriate and turn it into a canned report.
Conclusion As PowerBuilder developers, we have an extremely powerful tool and a tremendous advantage over our fellow IT professionals. It is my hope that some of these techniques will assist beginner and intermediate developers and help to create more PowerBuilder loyalty in the industry. Reader Feedback: Page 1 of 1
Your Feedback
Subscribe to the World's Most Powerful Newsletters
Subscribe to Our Rss Feeds & Get Your SYS-CON News Live!
|
SYS-CON Featured Whitepapers
Most Read This Week |
||||||||||||||||||||||||||||||||||||