Introduction to PowerBuilder

HomePrevious Lesson: Summary
Next Lesson: Exercises

Review Questions & Answers

Q: How do you retrieve data from the database into the DataWindow?

Ans: DWControlName.Retrieve() retrieves data from the database and populates the DataWindow.

Q: What happens if you provide more arguments than those defined in the SELECT statement to the Retrieve() function?

Ans: PowerBuilder generates an error if the PowerBuilder version is prior to 5.0. Otherwise, it ignores the extra arguments.

Q: Does deleting a row by calling Delete() in the DataWindow delete the row in the database? If not, what is to be done to apply changes to the database?

Ans: DeleteRow() deletes from the DataWindow only and doesn't delete a row in the database. You need to call Update() function for the DataWindow control to apply changes to the database.

Q: What is a Transaction object?

Ans:A Transaction object contains the necessary information needed to connect to a database and also contains the result of the last executed SQL statement.

Q: What is SQLCA?

Ans: SQLCA is SQL Communication Area, a type of transaction object. It is a global variable and is available to any PowerBuilder application.

Q: Which SQLCA's property contains the error code of the last executed SQL Statement?

Ans: SQLCA.SQLCode

Q: How do you stop an application?

Ans: By using HALT statement.

Q: Describe the functionality of AcceptText() function.

Ans: AcceptText() accepts the changed text in the current field, even if the user doesn't press the tab key or click with the mouse button on some other field.

Q: Is it possible to share data between two or more DataWindows? If so, how?

Ans: Yes. Just call PrimaryDw.ShareData( SecondaryDw).

Q: What command rolls back the changes done to the database?

Ans: Call: ROLLBACK USING TransactionObjectName ;

Q: Write the code to put the DataWindow in the query mode.

Ans: DWControlName.Modify("DataWindow.QueryMode=yes")

Q: How do you turn on the 'Print Preview Rulers' for a DataWindow?

Ans: DWControlName.Modify("DW.Print.Preview.Rulers=yes")

Q: List the functions learned till now in this session.

Ans: MessageBox(), Open(), SetTransObject(), SetTrans(), ShareData(), Retrieve(), InsertRow(), ScrollToRow(), Close(), DeleteRow(), Update(), Print(), PrintSetUp(), Describe(), Modify(), SetSort(), SetFilter(), Sort(), Filter(), SaveAs(), SetPointer(), AcceptText() and SetNull().

Q: List all the statements learned till now in this session.

Ans: Database statements: Connect, Commit, Rollback. Other statements: Halt

Q: How do you change the mouser pointer?

Ans: SetPointer( PointerName!)

Q: Describe the functionality of SetTransObject().

Ans: SetTransObject() tells the DataWindow to use a specified transaction object while talking to the database. Using this function also gives more control over transactions to the programmer, such as committing and rolling back the transactions.

Q: __________ adds a row to the DataWindow.

Ans: DWControlName.InsertRow( Row no. before which you want to Insert)

Q: __________ moves the cursor position to the specified row in a DataWindow.

Ans: DWControlName.ScrollToRow( RowNo)

Q: __________ brings the specified object to the front.

Ans: ControlName.BringToTop = True

Q: __________ displays a window.

Ans: Open( WindowName)

Q: What is the difference between TriggerEvent() and PostEvent()?

Ans: PowerBuilder executes TriggerEvent() in synchronous mode and PostEvent() in asynchronous mode.

Q: What is the difference between TriggerEvent() and Send()?

Ans: TriggerEvent() just executes the script for the specified event, where as, Send() executes the script as well as it makes the specified event to really happen.

Q: Is it possible to post a function?

Ans: Yes, it is possible to post a function.

Q: What will happen if you trigger a non-existing event?

Ans: Except for the return code being a -1, nothing happens.

Q: Triggering an event that doesn't return a return code, will return ______ return code.

Ans: 0 (ZERO)

Q: Triggering an event that doesn't have script, will return ______ return code.

Ans: -1

Q: What is the difference between passing an argument "By Value" and "By Reference"?

Ans: In case of "By Value", the changed value (in the called event/function) of the variable reflects in the calling function/event. In case of "By Reference", the changed value (in the called event/function) doesn't reflect in the calling event/function.

Q: What is the difference between passing an argument "By Reference" and "Read-Only"?

Ans: Both are same, except for one difference. Assigning another object to the argument object is not allowed, if the object is passed as "Read Only". In case of traditional datatypes such as int, string, any statement that assigns a value to the argument will generate compilation error when argument is passed as ReadOnly.

Q: If you trigger a non-existing function, what will happen?

Ans: Results in run-time error.

Q: An event id can be mapped to multiple events of an object. True/False?

Ans: False.

Q: An event can be defined at an object without mapping it to an event id. True/False?

Ans: True.

Q: Write the code to trigger Close event of w_script_practice. Write it by using both old and new Syntax.

Ans: Old Syntax: w_script_practice.TriggerEvent(Close!)

In the New Syntax, it would be: w_script_practice Event STATIC Trigger Close().

Q: Write the code to trigger ue_close event that is defined at w_script_practice. Write using old and new Syntax.

Ans: Old Syntax: w_script_practice.TriggerEvent("ue_Close")

New Syntax: w_script_practice.Event STATIC Trigger ue_Close()

Q: How do you signal an error?

Ans: Using SignalError() function.

Q: Which object contains error information?

Ans: Error Object.

Q: Whenever an error occurs, _______________ event at ________________ object gets triggered automatically

Ans: SystemError, Application.

Q: Explain the "Retrieve As Needed" property of DataWindow control.

Ans: Setting on the "Retrieve As Needed" property makes PowerBuilder bring data, that a DataWindow control can display at any moment of time.

Q: Explain the difference between "Query Mode" and "Prompt for Criteria".

Ans: Query Mode allows the user to specify query criteria on all the columns that are being displayed in the DataWindow control, and has a tab order greater than Zero. Prompt for Criteria allows the user to specify query criteria on selected columns (set either through PowerScript, using Modify() function, or set in the DataWindow painter).

Q: Which function sets the value of a column in the DataWindow control.

Ans: SetItem()

Q: Which function returns the value of a string data type column in the DataWindow control.

Ans: GetItemString()

Q: Which function returns the value of a "Date" data type column in the DataWindow control.

Ans: GetItemDate()

Q: The following two statements do the same thing. True/False

Ans: True, because identifiers are case insensitive in PowerBuilder.

Q: Is it possible to get environment information from PowerBuilder?

Ans: GetEnvironment() function gives environment information. You can get operating system name, it's revision numbers, character set name, screen width and height in pixels, CPU information, etc.

Q: Which functions allow you to read or modify registry database?

Ans: RegistryGet() gives the specified key's value and RegistrySet() sets the specified key's value. The later function creates keys if the key doesn't exist.
HomePrevious Lesson: Summary
Next Lesson: Exercises