PowerBuilder Interview Question and Answers

31. Where is a Query stored?
  In a .PBL file.
Your Name Your Email-ID
Your Answer
32. How do you create a DataWindow object dynamically?

We use SyntaxFromSQL() and Create()
SQLCA.SyntaxFromSQL(select string, presentation string, Error string)
dw_1.Create(syntax, Error string)

To create a DataWindow dynamically we have to:
1. build a string to hold a SQL Select statement;
2. build a string to specify the presentation characteristics of the DataWindow object;
3. associate the syntax and description with an existing DataWindow control;
4. associate the DataWindow control with a transaction object, and perform a retrieval.
The DataWindow that is created exists only for the life of the DataWindow control, unless we use the LibraryImport() function to save it in a library. Dynamic DW objects allow us to create and modify DW objects on the fly. To create a DW dynamically, use the Create() function.
Creating takes two arguments: the name of the DataWindow object that will be replaced by the new DW object, and the syntax for creating the new DW object. We can create the DW object syntax in a script, but it is easier to use the SyntaxFromSQL() to generate the syntax from a SELECT statement.

Your Name Your Email-ID
Your Answer
33. Why must you specify the transaction object for a DataWindow control after creating the DataWindow object?
  The Create() function must be followed by SetTransObject() function because Create() destroys any previous association between the DataWindow and a transaction object. Then, we can issue a Retrieve().
Your Name Your Email-ID
Your Answer
34. Can you dynamically assign a DataWindow object?
  Yes, using DataWindow’s control attribute “DataObject”. DataWindow control has the attribute DataObject. If we want to change an associated DataWindow object at runtime we need to put a line in the script that changes the value of the DataObject attribute.
For example:
dw_1.DataObject = “d_name”
Your Name Your Email-ID
Your Answer
35. Let’s say, you share two DW buffers and the primary DW has some DDDW columns. Will this DDDW be shared automatically as well?
  NO. After we have shared 2 DataWindows, we have to share all DropDowns as well. First, we have to get the reference for the Child DataWindow using GetChild() function and then do sharing by using ShareData() function.
DataWindowChild dwc_1, dwc_2
dw_1.getchild(“employee”, dwc_1)
dw_2.getchild(“employee”, dwc_2)
Your Name Your Email-ID
Your Answer