Sei sulla pagina 1di 29

PowerBuilder - Technical Telephone Interview -

5/2/2011
How do you Normalize the data? (4 steps)
Normalization is a series of tests you use to eliminate redundancy in the data and make sure the data is
associated with the correct table or relationship. There are five tests. In this section, we will talk about
the three tests that are usually used.

1. List the data:


· Identify at least one key for each table. Each table must have a primary key.
· Identify keys for relationships. The keys for a relationship are the keys from the two tables it
joins.
· Check for calculated data in your supporting data list. Calculated data is not normally stored in
the database.

2. Put data in first normal form:


· Remove repeating data from tables and relationships.
· Create one or more tables and relationships with the data you remove.

3. Put data in second normal form:


· Identify tables and relationships with more than one key.
· Remove data that depends on only one part of the key.
· Create one or more tables and relationships with the data you remove.

4. Put data in third normal form:


· Remove data that depends on other data in the table or relationship and not on the key.
· Create one or more tables and relationships with the data you remove.

Data and keys


Before you begin to normalize (test your data), simply list the data and identify a unique primary key for
each table. The key can be made up of one piece of data (column) or several (a concatenated key).
The primary key is the set of columns that uniquely identifies rows in a table.

1
PowerBuilder - Technical Telephone Interview -
5/2/2011
Dynamic SQL:
To execute some database queries that are not fully specified at runtime.

You can not use embedded SQL to perform these queries because embedded SQL requires that you
know all the result set columns when you code the query ( must be fully defined at compi.le time ).

Format 1 and 2 has no provision for retrieving data from the database. They are restricted to non-query
statements.

Formats 2, 3, and 4 uses the Dynamic Staging Area to provide a connection between a SQL statement
and a TransactionObject. Information about the SQL statement is placed in the Dynamic Staging Area
(SQLSA) by using the PREPARE statement.

Format 4 is the most dynamic of all dynamic SQL. Format 4 is used when the exact columns returned
by the query and exact WHERE clause needed by the query cannot be determined at runtime.

Dynamic SQL Formats. - Declarative SQL (To execute a SQL statement)


Format 1 - Non-result set statement with no input parameters. (CREATE, ALTER, DROP Table)
You can use this format to execute all forms of Data Definition Language (DDL).
( SQL sta. Are executed through the EXECUTE IMMEDIATE command )

Format 2 - Non-result set statement with input parameters. (INSERT,UPDATE,DELETE)


You can use this format to execute all forms of Data Manipulation Language (DML).
Ex. INSERT INTO “dba”.”department”(“dept_id) VALUES (?)

Format 3 - Result set statements in which the input parameters and result set columns are known at
compile time. This format differs from the previous two formats in that the SQL returns a result set. To
handle the result test, PB uses either a dynamic cursor or dynamic stored procedure.
Ex. (dynamic CURSOR to process a list of employee based on the job title, experience,
and salary entered by user)

Format 4 - Result set statements in which the input parameters, the result set columns or both are
unknown
at compile time. To handle the result test, PB uses either a dynamic cursor or dynamic stored
procedure. Because PB the input parameters and the result set columns are not known until
runtime, PB uses a Dynamic Description Area (SQLDA) , by default to store information about
these variables.
Queries:
Ex. SELECT id, last_name, state FROM contact WHERE city =? and state =?
SELECT emp_id, emp_fname, emp_lname FROM employee WHERE emp_dept=?

To fully support dynamic SQL , PowerBuilder uses two object types in addition to the transaction
object:
DynamicStagingArea data type. (SQLSA)
PowerBuilder uses variables of this data type to store the following information for use in subsequent
statements:
-The SQL statement in your PREPARE statements.
-The transaction object for use in subsequent statements.
DynamicDescriptionArea data type. (SQLDA)To store information about the input and output
parameters used in Format 4 of dynamic SQL. PowerBuilder provides a global-level
dynamicDescriptionArea named SQLDA that you can use when you need a DynamicDescriptionArea
variable.

2
PowerBuilder - Technical Telephone Interview -
5/2/2011
SQL Topics:
SQL Data Definition Language Statements.
Create, Alter, Drop

SQL DataControl Language Commands.


Grant Revoke

Locking can be implemented at the following levels.


Row, Page, Table, Database

SQL Data Manipulation Language Statements.


Select, Insert, Update, Delete

SQL Statements that limit the data retrieved.


Where, Having

SQL Outer Join.


includes all rows in Table A regardless of whether there are matching rows in table B.

PREDICATES.
The consistency of the database is typically expressible through predicates or conditions on the current
state of the database. A predicate is a statement of the form A(X), which means that X has the property of
A. For example, “John is from Indiana” is a predicate statement; here, “John” is the subject and “is from
Indiana” is the predicate. A relation is a predicate with two or more subjects. “John and Bob are brothers”
is an example of a relation. The common way of visualizing a set of relational statements is a table where
the columns are attributes of the relation and each row is a specific relational statement.

Where clause.
Specifies a table by applying a search condition to each row of the result from the preceding FROM
clause.

What are the SQL Aggregate Functions?


COUNT - produces the number of rows or non NULL field values that the query selected.
The COUNT is slightly different. It counts the number of values in a given column, or the
number of rows in a table. When it is counting column values, it is used with
DISTINCT to produce a count of the number of different values in given field.
SUM - produces the arithmetic sum of all selected values of a given field.
AVG - produces the average (mean) of all selected values.
MAX - produces the largest of al selected values of a given field.
MIN - produces the smallest of all selected values of a given field.

When do you use Group By and Having?


A Group By clause specifies a grouped table derived from the result of the previously specified clause.
Each column specification in the Group By clause (the ”grouping” column) must be a column in the
result of the previously specified clause.

A Having clause specifies a restriction on a grouped table by eliminating groups that do not satisfy a
search condition.

How do you setup a sort at the backend?


Datawindow Painter, SQL, Sort tab, Drag and Drop columns in the order you want to be sorted.

How do you setup a sort at the front-end?


Datawindow Painter, Rows, Sort, Specify Sort Columns, Data Source, Column, (Ascending)

SQL Statements syntax: (DML - Data Manipulation Language)

3
PowerBuilder - Technical Telephone Interview -
5/2/2011

What is the syntax for Union, Insert, Join, Update and Delete,?

UNION of two queries in which the second selects the rows excluded by the first.
Union = SELECT Salespeople.snum, sname,cname,comm
FROM Salespeople, Customers
WHERE Salespeople.city = Customers.city
UNION
SELECT snum,sname, ‘NO MATCH’, comm
FROM Salespeople
WHERE NOT city = ANY
(SELECT city
FROM Customers)
ORDER BY 2 DESC;

Insert = INSERT INTO Salespeople


VALUES (1001, ‘Peel’, ‘London’, .12);

Join = SELECT Customer.cname, Salespeople.sname, Salespeople.city


FROM Salespeople, Customers (joining two tables)
WHERE Salespeople.city=Customer.city (the predicate) (equijoins =)

Update = UPDATE Customers


SET rating = 200
WHERE snum = 1001;

Delete = DELETE FROM Salespeople;


WHERE snum = 1003;

Return code difference for Update dw and embedded SQL.


SQLCode : 0 = OK, 100=NotFound, -1=SQLError

Update: 1=Success, -1=Update Fails

INNER and OUTER


Each row of:
Customer INNER JOIN Invoice
contains the information from one Customer row and one Invoice row. If a particular customer has no
invoices, there will be no information for that customer.

A LEFT OUTER JOIN B


includes all rows of table A whether or not there is a row in B that satisfies the join condition. If a
particular row in A has no matching row in B, the columns in the join corresponding to table B will
contain the NULL value. Similarly,

A RIGHT OUTER JOIN B


includes all rows of table B whether or not there is a row in A that satisfies the join condition.

4
PowerBuilder - Technical Telephone Interview -
5/2/2011

How do you call the ancestor script?


For example, to call the parent's Clicked script, code the following.

CALL Super::Clicked

Note that you can't use Super to call scripts associated with controls in the ancestor window.
If you are calling an ancestor function, you only need to use Super if the descendant has a function with
the same name and the same arguments as the ancestor function. Otherwise, you would simply call the
function with no qualifiers. This example calls the ancestor function wf_myfunc. Presumably, the
descendant also has a function called wf_myfunc.

Super::wf_myfunc()

You can only use Super in an event or function associated with a direct descendant of the ancestor who's
function is being called. Otherwise the compiler will return a syntax error. The example above would
have to be part of a script or function in the descendant window, not one of the window's controls. For
example, if it were in the Clicked event of a button on the descendant window, you would get a syntax
error when the script was compiled.

How do you override scripts or events from an Ancestor?


(Things that you can do to an Ancestor Object.)
1. Extend Ancestor Script
2. Override Ancestor Script

Calling an Ancestor for a window/control or user event Script.


CALL calls an ancestor script from a script for a descendant object. You can call scripts for events in an
ancestor of the user object, menu, or window. You can also call scripts for events for controls in an
ancestor of the user object or window.

CALL ancestorobject {`controlname}::event


CALL ancestorwindow::event
CALL ancestorwindow’control::event
CALL ancestorwindow’object::event
CALL ancestoruserobject::event
CALL ancestoruserobject’object::event

The following statement calls a script for an event in an ancestor window.


CALL w_emp::Open

The following statement calls a script for an event in a control in an ancestor window.
CALL w_emp`cb_close::Clicked

5
PowerBuilder - Technical Telephone Interview -
5/2/2011
Updating Multiples Tables from One Datawindow:
In this example, the Datawindow is built on a join of two tables, Department and Employees, based on a
SELECT statement:

The Datawindow was initially set up with update capability against the Department table. Therefore, you
update Department first, setting the reset flag to false so that the modified row/column status of the
Datawindow is not cleared.

String ls_err

IF dw_master.Update(TRUE,FALSE) = 1 THEN
//Turn off update for Department’s columns
dw_master.Modify(“department_dept_name.Updated=NO”)
dw_master.Modify(“department_dept_id.Updated=NO”)
dw_master.Modify(“department_dept_id.key=NO”)

//make Employee the new updateable table


dw_master.Modify(“Datawindow.Table.UpdateTable=’employee’”)

//Turn on update for desired employee columns


dw_master.Modify(“employee_emp_id.Update=YES”)
dw_master.Modify(“employee_emp_fname.Update=YES”)
dw_master.Modify(“employee_emp_lname.Update=YES”)
dw_master.Modify(“employee_emp_id.key=YES”)

//Then update the Employee table


IF dw_master.Update() = 1 THEN
COMMIT Using SQLCA;
dw_master.ResetUpdate ()
ELSE
ROLLBACK Using SQLCA;
MessageBox(“Update of employee table failed, “Rolling back changes”)
ELSE
ROLLBACK Using SQLCA;
MessageBox(“Update of department table failed, ”Rolling back changes”)
END IF
How do you manage the update flags?
You manage these flags by setting the Reset option to FALSE and then explicitly resetting the flag later
with the ResetUpdate() function.

IF dw_orderheader.Update(TRUE,FALSE) = 1 THEN
IF dw_orderitem.Update(TRUE,FALSE) = 1 THEN
COMMIT Using SQLCA;
// Clear the flags for both windows
dw_orderheader.ResetUpdate()
dw_orderitem.ResetUpdate()
ELSE
ROLLBACK Using SQLCA:
END IF

ELSE
// make sure everything is cleared
ROLLBACK Using SQLCA;
END IF

Variables (Local, Instance Shared, Global)

6
PowerBuilder - Technical Telephone Interview -
5/2/2011

Shared vs. Local


Shared:
A variable that belongs to an object definition an exists across all instances of the object. Shared variable
retain their value when object is closed and open again.

Shared variables are always private. They are accessible only in scripts for the object and for controls
associated with the object.

Shared variable can belong to the application object, a window, a user object, or a menu.

Local:
A temporary variable that is accessible on in the script in which you define it. When the script is finished,
the variable ceases to exist.

Structure vs. Array


Structure (a collection of one or more related variables of the same or different data type grouped under
one name. Structure allow you to move data around and refer to the data under a single name instead of
using several names.)

Array (a group of variables of the same type grouped under one name)

7
PowerBuilder - Technical Telephone Interview -
5/2/2011

What is the Edit Control?


The Edit Control takes your data and holds it until the field loses focus. When this happen, EditControl
tries to validate the data to ensure that you have entered the appropriate data. There are four levels of
validation. (the contents of the edit control is called text)

Four Levels of Validation:


1. has anything change?
2. is the data of the correct type? If the data isn’t of the correct type, the ItemError Event will be
triggered.
3. does the data pass the validation rules?
4. does the data pass the ItemChange Event? It is usually used to validate any business rules pertaining to
the column.

If the value is accepted, PowerBuilder will move the data from the edit control to the DataWindow buffer
and enable the focus to change.

Changing Rules Dynamically:


Rules can be changed at runtime using the
dwcontrol.GetValidate (column)
dwcontrol.SetValidate (column, rule)

ItemError Event:
Occurs when a field has been modified, the field loses focus (for example, the user presses ENTER,
TAB, or an arrow key or clicks the mouse on another field in the DataWindow), and the data in the field
does not pass the validation rules for its column. ItemError can also occur when a value imported into a
DataWindow control or DataStore does not pass the validation rules for its column.

Return codes are:


0 - Reject the data value and show an error message box. (default)
1 - Reject the data value with no message box.
2 - Accept the data value.
3 - Reject the data value but allow focus to change.

ItemChanged Event:
Occurs when a field in a DataWindow control has been modified and loses focus (for example, the user
presses ENTER, the TAB key, or an arrow key or clicks the mouse on another field within the
DataWindow). ItemChanged can also occur when the AcceptText or Update function is called for a
DataWindow control or DataStore object.

It is important that code in the ItemChanged Event not cause another ItemChanged event to be triggered,
resulting in an endless loop. To keep this from occurring, AccepText(), SetColumn(), and SetRow()
functions calls should not be put into the ItemChanged script.

Return codes are:


0 - accept the data value (default)
1 - reject the data value and don’t allow focus to change
2 - reject the data value but allow the focus to change

Functions Related to the Edit Control.


GetText() = To find out the value in the Edit Control
SetText() = To place a value into the Edit Control
AcceptText() = To ensure or to force the DataWindow to validate and accept the value in the edit
box.

8
PowerBuilder - Technical Telephone Interview -
5/2/2011
What is the difference between EditChange event and ItemChanged
event?
An EditChanged event occurs when a user types in an edit control in a DataWindow.

In the script for the EditChanged event, use GetText to obtain the text of the edit control, SetText to
replace the text, and SetColumn to set the current column.

An ItemChanged event occurs in a DataWindow when three conditions are met:

1. A field has been modified and loses focus (for example, the user clicks the mouse in another field or
presses Enter, the Tab key, or the up or down arrow key).
2. The data has passed data type checking.
3. The data has passed a validation rule (if one is defined for the column).

If conditions 2 or 3 are not met, the ItemError event is triggered instead of the ItemChanged event.
The ItemChanged event is also triggered when a user selects an item in a column with a
DropDownListBox edit style. In this case, the event is triggered before the column loses focus.
The ItemChanged event has action codes that specify the action that takes place when the event occurs.
To set the action code, call the SetActionCode function. The action codes are:

0 - (Default) Accept the data value.


1 - Reject the data value and trigger the ItemError event.
2 - Reject the data value but allow the focus to change. Replace the column value just entered with the
value originally in the column.

9
PowerBuilder - Technical Telephone Interview -
5/2/2011
Function Declaration

Passing a PowerObject by reference or by value.


1. when passed by reference, means that the address of the argument is passed and any changes made to
the argument within the function are reflected in the original argument.

2. when passed by value, means that the function receives a copy of the argument and any changes made
to it are not reflected in the original argument.

Passing an integer or other non-PowerObject variable by reference or by value.


when passed by reference, you are passing the address of the memory that contains the integer.
when passed by value, you are passing the value of the integer.

What is the difference of passing variable by reference or by value?


passing variable by reference (contains a pointer, not the actual object) the called function can now
change the value in your variable.

passing variable by value (PB creates a temporary variable in memory and copies the value from your
variable to the temporary variable)

10
PowerBuilder - Technical Telephone Interview -
5/2/2011
User objects are objects that you build to perform processing that you use frequently in your applications.
You can use these objects in windows and in other user objects the same way you use the PB controls.

Why a NVO is better than a function? (Encapsulation)


Encapsulation = information hiding, or techniques for hiding the implementation details of an object by
making them private or protected. This means, other objects needing to access attribute values or change
their values need a mechanism to do so. To give read-only access to a private or protected attribute we
implement a public function (method) to return the value of the attribute. To give update access to a
private or protected attribute, we implement a public function to which we the new value of the
attributes. These public functions become part of the object’s public interface.

11
PowerBuilder - Technical Telephone Interview -
5/2/2011

Describe the Transaction Object.


Specifies the parameters that PB uses to connect to a database. The TransObject must be established
before you can access a database through a datawindow.

The attributes of a transaction object can be divided into two groups.


Transaction Object have 15 fields: 10 fields identify the database and server and 5 fields return status
information from the database that indicates the success or failure of the database processing.

What is the difference between SetTrans and SetTransObject?


SetTrans - Sets values in the dw’s internal transaction object
SetTransObject - Sets the transaction object for the dw and provides control over the transaction,
including the ability to commit from a script.

When you use SetTrans in a script, the dw_control uses it own transaction object and automatically
performs CONNECT and DISCONNECT as needed, any error that occur cause an automatic
ROLLBACK.

When you use SetTransObject, you have more control of the database processing and are responsible for
managing the database transaction.

What is SQLCA Transaction Object?


When you start executing an application, PowerBuilder creates a global default Transaction Object
named SQLCA. You can use this transaction object or create another transaction object for the
dw_control in a script. Transaction Object have 15 fields: 10 fields identify the database and server and
five fields return status information from the database that indicates the success or failure of database
processing.

How do you create a Transaction Object?


Declare variable (Transaction TransactionObjectName)
Create object (TransactionObjectName=CREATE Transaction)
Assign values to the transaction (‘DBParm’=’ConnectingString=’DSN=Galeria,UID=dba;)
Connect to the DataBase (Connect Using TransactionObjectName;)
Destroy the created transaction (Destroy TransactionObjectName)

Setting the values for the Transaction Object


SQLCA.DBMS = “Sybase”
SQLCA.LOGID = “Jose”
SQLCA.UserId = DBA
SQLCA.Dbpass = SQL
SQLCA..Dbparm =
SQLCA..SQLcode =

Forms of populating the Communication Are


1. Hard Code the information
2. Reading values from an External file
3. Reading values from an .INI file

Assign the Transaction Object to the datawindow control.


dw_control.DataObject = “dw_name”
dw_control.SetTransObject(SQLCA)
dw_control.Retrieve()
Commit or Rollback

12
PowerBuilder - Technical Telephone Interview -
5/2/2011
What is Transaction Management (L.U.W.)?
A logical unit of work consisting of one or more SQL statement

Ex.
Transaction No. 1 (connect,retrieve,insert/delete,makechange,update,commit)
Transaction No. 2 (makechange,update,rollback)
Transaction No. 3 (makechange,update,commit,disconnect)

What is the Error System Object?


Is used to record execution-time errors. You can access the ErrorObject in a script (typically for the
SystemError Event). The ErrorObject contains (number,text,window-menu,object,objectevent,line)

What is the Message System Object?


Is used to process events that are not PowerBuilder-defined events, to communicate parameters between
windows when you open and close (OpenWithParm,OpenSheetWithParn and CloseWithReturn
functions), and if optional parameters are used in TriggerEvent or PostEvent functions.

There are 3 main attributes that make it-extremely attractive for allowing easy retrieval of parameters
passed between objects:
1. Message.StringParm A string or string variable
2. Message.DoubleParm A numeric or numeric variable
3. Message. PowerObjectParm Any PowerBuilder object type

13
PowerBuilder - Technical Telephone Interview -
5/2/2011

Components of an MDI application.


menubar, a frame, a client area, sheets, and usually a status area, which can be display MicroHelp.

Which two entities have a Resize event?


A Resize event occurs when the user or a script opens a window or resizes a DataWindow control or a
window.

Sizing the client area.


The MDI_1 control it is use to identify the client area of the frame window. In custom frames, you write
a script for the frame’s Resize event to size MDI_1.

How to size the client area of an MDI frame.


// How to size the client area of an MDI frame
// when it's a custom MDI frame (that is,
// one in which you've placed controls).

int li_width, li_height

li_width = w_genapp_frame.WorkSpaceWidth ()
li_height = w_genapp_frame.WorkSpaceHeight ()
li_height = li_height - (p_logo.y + p_logo.height)
li_height = li_height - MDI_1.MicroHelpHeight
li_height = li_height + WorkspaceY ()
mdi_1.Move (WorkspaceX (), p_logo.y + p_logo.height)
mdi_1.Resize (li_width, li_height)

Places where you can use MicroHelp.


(in controls, menu items, toolbars)

Describe the Window Painter.


Components of a window (attributes, events, controls, functions, control buttons, variables, pictures,
menu, scripts)

WindowType Attribute
Child! A window that is dependent on a main window and can only exist within the main
(parent) window.
Main! A standalone overlapped window that can be independent of all other windows.
MDI! An MDI frame without automatic MicroHelp.
MDIHelp! An MDI frame with automatic MicroHelp.
Popup! A window that displays usually in response to an event within a window, but can exist
outside of the window and, in some cases, after the window that opened it is
closed.
Response! A window that displays to obtain information from the user and cannot lose focus or be
closed until the user responds.

14
PowerBuilder - Technical Telephone Interview -
5/2/2011
Where are all PowerBuilder objects stored?
In PowerBuilder Libraries. (PBL’s)

Optimizing PBL’s (libraries) will do the following.


1. Unfragment the library.
2. Affects the layout of the library on the hard disk.
3. Unfragments the storage objects in the library.

What is the difference between Optimize and Regen?


Optimize = (defrag) to reorganize the library structure to optimize object and data storage and index
locations.

Regen = to update descendants with latest change or to correct corrupted objects.

What is the difference between PBD and PBL?


PBD = binary information been used by the exec
PBL = Source Code

15
PowerBuilder - Technical Telephone Interview -
5/2/2011
Creating an Executable:
What is a PowerBuilder Dynamic Library (.PBD)?
PowerBuilder automatically includes only directly referenced objects. Some of the objects that you use in
your application may be referenced dynamically.

What is a PowerBuilder Resource File (.PBR)?


Use your favorite ASCII text editor to create the .PBR file
The PowerBuilder Resource file (.PBR) allows you to include in the .EXE file or the .PBD file any object
that is dynamically referenced, and any object that PowerBuilder does not automatically include.
You create the .PBR file by listing the filename for each resource on a separate line in an ASCII file. Be
sure to include the filename (to include resources assigned by attribute reference) for:
Each resource that is not a PowerBuilder object, and is not declared as an attribute of an object or
control, such as:

Bitmaps (.BMP)
Compressed bitmaps (.RLE)
Icons (.ICO)
Cursors (.CUR)

Any resources that you assigned dynamically in scripts for the application
Any resources that are conditionally referenced in a script
The filename for the resource can include the drive and pathname.

p_1.picturename = "OCEAN.BMP"
p_1.picturename = "c:\bitmaps\BEACH.BMP"
p_1.picturename = "c:\bitmaps\MOUNTAIN.BMP"

PB Deployment Kit
-Powersoft DLL files (Which provide the engine needed to run executables)
-Database Interface files
-Executable files
EXEC file, PBD files, PBR files, INI files, ODBC files

16
PowerBuilder - Technical Telephone Interview -
5/2/2011
How do you pass parameters to a window?
(message.wordparm, longparm, structure, objects, variable)

Syntax 1
OpenWithParm (windowvar, parameter {, parent })

Syntax 2
OpenWithParm (windowvar, parameter , windowtype {, parent })

Usage
The system Message object has three attributes for storing data. Depending on the data type of the
parameter specified for OpenWithParm, your scripts for the opened window would check one of the
following attributes.

Message object attribute Parameter data type


Message.DoubleParm Numeric
Message.PowerObjectParm PowerObject (PowerBuilder objects, including user-defined
structures)
Message.StringParm String

OpenWithParm(w_employee, "James Newton")

The window's Open event script has the following statement:


st_empname.Text = Message.StringParm

The following statements open an instance of a window of the type w_to_open. Since the parameter is a
number it is stored in Message.DoubleParm:

w_employee w_to_open

integer age = 50
OpenWithParm(w_to_open, age)

Where the parameter information is stored? (in the system MessageObject)


The system Message object has three attributes for storing data. Depending on the data type of the
parameter specified for OpenWithParm, your scripts for the opened window would check one of the
following attributes.

Message object attribute Parameter data type


Message.DoubleParm Numeric
Message.PowerObjectParm PowerObject (PowerBuilder objects, including user-defined
structures)
Message.StringParm String

Passing structures vs. objects.


Structure
-PowerBuilder applications do not need to explicitly create or destroy the memory associated with a
structured. In this respect structures are like simple datatypes.

Object
-Define a Non-visual user object (custom class) containing instances variables for each of the attributes.
At this point, the object is simply a collection of attributes, like a structure, but you can do so much more
with objects if you wish. You can inherit new custom classes from existing custom classes. You cannot
inherit structures. You can add behavior (methods or functions) to an object. You cannot add behavior to
a structure. You are responsible for managing the memory of your own objects.

17
PowerBuilder - Technical Telephone Interview -
5/2/2011
Name the panels of the Debugger Painter .
1. Debug (Script)
2. Watch (Variables)
3. Variables

Name a Debugger Problem.


Post Events
If you have worked with PostEvent, you know that a PostEvent basically waits until there are no other
triggered events pending.
But the debugger causes a drastic change: it throws the event stack away - that is, all pending PostEvents.
This means that if you PostEvent(“ue_post_event”) and then get to a debug stop before the
(“ue_post_event”) happens, the (“ue_post_event”) won’t happen. It gets removed from the stack.

Running an Application in Debug Mode


When you run an application from the Debug painter, you are running in debug mode. In debug mode,
PowerBuilder suspends execution of the application at stop points in the scripts.

Tip PowerBuilder terminates the application and issues an error message when it encounters an
execution error in debug mode or in regular mode. In debug mode, you can set stops to help you track the
cause of the error.

Tip When you are in Step mode, the Step icon replaces the Start icon in the painter toolbar.

At each stop, you can display the current values of the application variables, set new stops, select another
script to debug, or close Debug. The stops remain set until you remove them or close Debug.

Tip When you close Debug, you suspend the Debug session. If you run Debug again during the same
PowerBuilder session, Debug resumes processing at the point at which you stopped.
See also
Closing Debug
Displaying Variable Values
Opening Debug
Selecting a Script to Debug
Setting Stops in a Script

Places where you can’t place a STOP in Debugger.


1. Variable declaration
2. Blank line
3. Comments only lines
4. End If lines

After encountering a STOP while running the Debugger you can:


1. View the value of variables
2. Set new STOP points
3. Select another script to debug
4. Remove existing STOP

18
PowerBuilder - Technical Telephone Interview -
5/2/2011

Name the three DataWindow Buffers.


An enumerated data type specifying the DataWindow buffer from which you want to get data:
Delete! The data in the delete buffer (data deleted from the DataWindow object).
Filter! The data in the filter buffer (data that was filtered out).
Primary! (Default) The data in the primary buffer (the data that may have been modified but has not
been deleted or filtered out).

Functions that access the buffers.


The following functions use the DataWindow Object buffers:
GetItemDate() GetNextModified()
GetItemDateTime() GetUpdateStatus()
GetItemDecimal() RowsCopy()
GetItemNumber() RowsMove()
GetItemStatus() RowsDiscard()
GetItemString() SetItemStatus()
GetItemTime()

Update Row/Column Status Flags:


The update status flags contains a value of the enumerated type dwItemStatus(row,col,dwbuffer). The
possible values for this enumerated type are:
New! (rows only)
NewModified! (rows only)
NotModified! (rows and columns)
DataModified! (rows and columns)

datawindowname.SetItemStatus (row, column, dwbuffer, status)


Changes the modification status of a row or a column within a row. The modification status determines
the type of SQL statement the Update function will generate for the row.

Specified Status
Original Status New! NewModified! DataModified! NotModified!
New! - Yes Yes No
NewModified! No - Yes New!
DataModified! NewModified! Yes - Yes
NotModified! Yes Yes Yes -

datawindowname.GetItemStatus (row, column, dwbuffer)


Reports the modification status of a row or a column within a row. The modification status determines
the type of SQL statement the Update function will generate for the row or column.

Use GetItemStatus to understand what SQL statements will be generated for new and changed
information when you update the database.

For information in the primary and filter buffers, Update generates an INSERT statement for rows with
NewModified! status. It generates an UPDATE statement for rows with DataModified! status. Only
columns with DataModified! status are included in the UPDATE statement.

For rows in the delete buffer, Update does not generate a DELETE statement for rows with New! or
NewModified! status.

19
PowerBuilder - Technical Telephone Interview -
5/2/2011

Why use an External Data source?


There are situation, where the strong data display and validation capabilities of DataWindows can be
useful, but the target data does not reside in an RDBMS. External data sources are designed for this
purpose. For example, you can:

-Manipulate non-RDBMS data, including (Formatted test files TXT, and dBASE data).
-Provide a formatted display of INI files values.
-Import a tab-deliminated string from a DDE server.

In general, you can use an external source DataWindow in the situations:


Input Output
File DataWindow File
File DataWindow Database
Mainframe DataWindow Database

What activate a script?


TriggerEvent - executes the script for that events immediately.
PostEvent - adds an event to the end of event queue of that object.

RETURN
Use RETURN to end the execution of a script or function immediately. When RETURN is used in a
script, the script stops executing and waits for the next command. When it is used in a function,
RETURN transfers control (returns) to the statement following the calling statement.

Modify/Describe (DWSyntax 4.0)


Modifies a DataWindow object by applying specifications, specified as a list of instructions, that change
the DataWindow object's definition. You can change appearance, behavior, and database information for
the DataWindow object by changing the values of attributes. You can add and remove objects from the
DataWindow object by providing specifications for the objects.

Applies to
DataWindow controls and child DataWindows

Changing color
dwcontrolname.Modify("DataWindow.Color='long'")

To set the text color of a column or a text object, use similar syntax:
dwcontrolname.Modify("objectname.Color='long'")

Places where you can use pictures


toolbar, Icon-minimize window, applications-icon.

20
PowerBuilder - Technical Telephone Interview -
5/2/2011

List PowerBuilder Painters.


Application, Window, Menu, Datawindow, DB/DB Administration, Structure, Pipeline, Query, Function,
Project, Library, UserObject, Debug, Report DatawindowSyntax

Describe the Application object.


To specify application level information.
(application name, it icon, default font, colors, and scripts for the application’s open,close,idle, and
system error events)

Application object attributes


AppName, MicroHelpDefault, ToolbarText, dwMessageTitle,LibSearchPath

What is the difference between a dw_control and a dw_object?


You place dw_controls in a window or user object and then specify the dw_object you want to use within
them to displays and manipulate data in the window.

A dw_object allows, users to display, manipulate, and update database or other information. You build
dw_objects in the DataWindow Painter.

Describe the DataWindow Painter.


Data Source (QuickSelect, SQL Select, Query, External, Stored Procedures)
Presentation Style (Composite, Crosstab, Freeform, Graph, Grid, Group, Label, N-Up, Tabular)

DataWindow attributes
(color,column count,data,selected,retrieve as needed,etc.)

Column attributes
(visible, color, format, height, protect, update)

What is the difference between dw edit style (check box,dddw,ddlb) and display format ($ currency)?
In the edit style window, you can define or modify a line edit style for the current column. The current
settings for the edit style display when you open the edit style window.

In the display formats window, you can define formats from the list for the current database in the listbox
at the bottom of the dialog box or enter a valid format.

Describe the Menu attributes.


Checked ,Enabled, MicroHelp, ParentWindow, Tag, Text, ToolbarItemName, Visible

Table Extended Attributes.


Extended column attributes
(format, initial value, validation rule, comments, header)

21
PowerBuilder - Technical Telephone Interview -
5/2/2011

Totaling Column Values.


1. select the numeric column or computed field for which you want the total.
2. click the Sum icon or select Sum-Computed Field from the objects menu

Creating Computed Columns.


1. click the Compute tab in the Select painter
2. in the Computed Columns box, press the right mouse button to add column names and functions.
3. you can add operators supported by your DBMS using the keyboard.

Creating Group.
In DataWindows, you can group rows for reporting purposes. These groups can be used in the
DataWindow object and in reports to:

Specify page breaks and page numbering


Specify header and trailer information for groupings of information
Report on information in specific groups of rows

For example, if you make the column Dept_Nbr a group, you can force a page break each time the
department number changes and can report on information about each department in the DataWindow
object. You can also specify that you want to renumber starting at one on a group break.

To create a group in a DataWindow object:

1 Select Create Group from the Rows menu. The Specify Group Columns dialog box appears.
2 Click and drag the columns you want to group into the Columns box.
3 Select the New Page on Group Break checkbox to start a new page when a value changes in any
of the group columns. The default; no page breaks for the group. Select the Reset Page Number
on Group Break checkbox to make PowerBuilder reset the page number to 1 each a value in
changes a group column.
4 Click OK to close the Specify Group Columns dialog box. PowerBuilder displays a header and
trailer bar with the level of the group and the names of the columns in the group in the
DataWindow painter workspace.

PowerBuilder assigns the group a number (or level) when you create the group, the first group is level 1,
the next level 2, and so on. The level indicates the order of precedence for the groups. Level 1 is the
primary group and each subsequent level is a sub-level within the previous level. For example, if group
level 1 contains the column named Dept_Nbr and group 2 contains the column named Location and you
specify the new page option for both groups, a new page will occur each time the department number
changes and each time the location changes within a department number.

See also
Deleting a Group
Editing a Group
Using the Specify Group Window

Stored Procedures vs. Triggers.


Store procedures Triggers
1. are called 1. are event driven
2. can be passed arguments 2. like events, cannot be passed
3. are executed as the result of being called in SQL script 3. are executed in response to some action

(insert, update, delete)


What is ODBC?

22
PowerBuilder - Technical Telephone Interview -
5/2/2011
Is a database access standard and hence the development tools PowerBuilder can be utilized against any
DBMS that supports the ODBC standard. ODBC has emerged as the de facto standard for MS Windows
platform and is comment of Microsoft’s Window Open Services Architecture (WOSA).

Working with Cursor.


A cursor is a work space in memory used for processing SQL Commands. It is essentially a pointer to the
current record in a particular answer set. Is a kind of variable that is associated with a Query. The value
of this variable will be each row, in turn of the querey’s output. Like a host variables, cursors must be
declared before they are used. Some databases allow you to FETCH PRIOR, FIRST, LAST and NEXT.
We know when there are no more records by examining the SQLCode which returns 100 for no record.

A cursor allows you to treat the rows in a table similarly to the way a traditional program reads a flat file
-- Line by line. (or in this case, row by row). Because Relational DBMS are essentially
SET_ORIENTED, SQL Server does not have an explicit method or representing a single row within a
table.

Cursor Declaration.
DECLARE acctcur CURSOR FOR
SELECT “account_no”,”acct_id”,etc.
FROM “account_no”
ORDER BY “account_no”.acct_id” ASC;
CONNECT Using SQLCA;
OPEN acctcur
FETCH acctcur INTO: account_id, etc.
DO WHILE SQLCA.SQLCode = 0
..........
LOOP
CLOSE acctcur
DISCONNECT Using SQLCA;

Places where you can change data.


Database Painter - data manipulation (Grid,Tabular,Free Form)
Datawindow Preview (Retrieve,Insert,Delete,Save Changes)

23
PowerBuilder - Technical Telephone Interview -
5/2/2011

Advantages of using inheritance.


save time, uniformity, save coding, standardization of the application

1. When you change the ancestor object, the changes are reflected in all the descendants.
2. The descendant inherits the ancestor’s script.
3. You get consistency in the code and the object in your application.

What is PowerBuilder?
A visual development environment for client/server systems.

Characteristics all PowerBuilder objects have. (AEF)


Attributes,Events,Functions

PowerBuilder Features
Portability across multiple platforms (window,nt,macintosh,unix-motif)
Application migration from version to version (compatibility)

What is a GUI application?


GUI applications have a common look and feel. PowerBuilder makes it easy for you to create these
applications.

What makes PowerBuilder unique?


PowerBuilder applications unique is the DataWindow, which you use to retrieve and display data.

Standard PowerBuilder Data Types.

Decision Structures
If...Then, Do...Loop, For...Next, And, Or, Not, Else, Choose Case, Loops

PowerScript Identifier Names.


1. must start with a letter
2. can have up to 40 characters, but no space
3. are case sensitive
4. can include any combination of letters, numbers and these special characters:
($ Dollar sign, # Number sign, % Percent sign, _ underscore)

Graph Concepts.
1. Graph data is organized into the following components (Series, Categories, Values)
2. Graph controls (A Style, Events, Functions)
3. grColorType enumerated data types (Background!, Foreground!, Shade!, Linecolor!)
4. grLegend enumerated data types (AtBottom!, AtLeft!, AtRight!, AtTop!)
5. Graph data attributes (Object type, Symbol type, Tic Type)

Drag & Drop Concepts.


Any object that has events associated with it can be dragged or have objects dropped on it. These objects
have a base class of DragObject Type. Only the drawing objects, such as rectangles, lines, oval, etc.,
cannot be dragged or have objects dropped on them. However, you can create a custom user object using
the UserObject Painter and place the desired drawing object in the UserObject. By using this technique
you can use drawing objects in drag and drop operations.

Drag & Drop Window Events.


1. DragDrop When a dragged control is dropped on the window. (when the mouse button released)
2. DragEnter When a dragged control enters the window. (‘here I come ‘ event)
3. DragLeave When a dragged control leaves the window. (the undo event)

24
PowerBuilder - Technical Telephone Interview -
5/2/2011
4. DragWithin When a dragged control is within the window. (well, what are you waiting for? event)

Drag & Drop Functions.


Drag(Begin!)
Drag(End!)
Drag(Cancel!)

Drag() = Start or End the dragging of a control


Ex. Drag(control, Dragmode)
Valid Dragmode are (Begin!, Cancel!, End!)

Drag & Drop involves at least two controls


(the drag control and the target)

Drag & Drop Attributes.


Autodrag = boolean (True or False)
DragIcon = The name of either an enumerated icon or a custom-built .Icon iconfile.

Identifying the Dragged Object


To identify the data type of a dragged object (source object) that the user dropped on a target object, use
the DraggedObject function and a variable of the data type DragObject.
Example
The following statements in the script for DragDrop event in a Picture declare Source a data type of
DragObject, Button a CommandButton data type, and Text a StaticText data type and then determine the
type of the object that was dropped.

DragObject Source // Declares Source,

CommandButton Button // Button,


StaticText Text // and Text

Source = DraggedObject()
if TypeOf(Source) = CommandButton! then
Button = Source
Button.Text = "Dropped Button!"
elseif TypeOf(Source) = StaticText! then
Text = Source
Text.Text = "Dropped Text!"
End if

Tip If your window has a large number of controls that the user can drop on a target object, use a
CHOOSE CASE statement.
See also
CHOOSE CASE
DraggedObject Function
TypeOf Function

Reports
A nested report is:
1. A report in another report.
2. Not placeable in a CROSSTAB type report.

Composite Reports
Do not have a data source.

25
PowerBuilder - Technical Telephone Interview -
5/2/2011
Crosstab Report
Static - establishes the rows and columns based on the data in the database when you define the crosstab.

PB System tables
PBCatTbl, PBCatCol, PBCatFmt, PBCatEdit, PBCatVld

Object Oriented Programming (OOP)

1.What is the different between traditional programming and OOP?


Traditionally, programming has made a sharp division between the program and its data. OOP combines
them into reusable units with classes. OOP combines data and process to perform a specialized role in a
system

2. What is encapsulation?
Data Hiding, Data Protection. (UserObjects, Inheritance, Instance Variables) When you combines data
and process to perform a specialized role in a system. The goal of encapsulation is to separate the
implementation of an object from how other objects interact with that object. You provide events and
functions that other’s must go through first. So, how do you actually protect your attributes from being
modified by others? You do so by using access modifiers. In OO systems there are three of them: public,
protected, and private. Private means that only the current object can access the instance variable or
function. Protected means that only the current object and any of its descendants can have access. By far
the most common use is protected.

3. What is Polymorphism?
Polymorphism - Using the same name for different operations in different circumstances is
polymorphism,
which is a Greek term meaning “MANY FORMS”.
. Different Objects respond differently to the same message. When you tell and object to
perform a function that the object know how to do.

Messages: Objects interact through a message-based interface that allows them to


cooperate without having to understand or interfere with each others’ internal process.

The Power of Polymorphism Here is another benefit of using messages. Because


objects are define independently of one another, the same name can be used for
different methods in different objects.

For example consider the message


“ADD” sent to a purchase order, it might mean add a new line.
“ADD” sent to an account object, it could be an instruction to increase the current
balance.
“ADD” sent to a department object, it might means add a new employee.

26
PowerBuilder - Technical Telephone Interview -
5/2/2011

Menu reference.
you need to qualify the name of the instance variable with the name of the object using dot notation as
follows.
object.instance-variablemenu.menu1.

How do you update a window and child window?


Using a Child DataWindow
A child DataWindow object is a DropDownDataWindow in a DataWindow object. A
DropDownDataWindow behaves as a child window of the DataWindow object that contains them.
To use a child DataWindow, use the GetChild function to obtain the child (data type DataWindowChild),
assign it a transaction object, and then populate it.

DataWindowChild dwc
int rtncode

rtncode = dw_emp.GetChild("emp_id",dwc)
// Code to check for errors. The rtncode -1 is an error.

dwc.SetTransObject(SQLCA)
dwc.Retrieve("argument")

Although PowerBuilder retrieves data for the child or report automatically when the main DataWindow is
displayed, you need to explicitly retrieve data when there are retrieval arguments or when conditions
change and you want to retrieve new rows.

Dynamically change of a datawindow attributes. (Describe/Modify ())


Describe ()
Reports the values of attributes of a DataWindow object and objects within the DataWindow object. Each
column and graphic object in the DataWindow has a set of attributes, which are listed in Appendix A.
You specify one or more attributes as a string and Describe returns the values of the attributes.
Describe can also evaluate expressions involving values of a particular row and column. When you
include Describe's Evaluate function in the attribute list, the value of the evaluated expression is included
in the reported information.

Modify ()
Modifies a DataWindow object by applying specifications, specified as a list of instructions, that change
the DataWindow object's definition. You can change appearance, behavior, and database information for
the DataWindow object by changing the values of attributes. You can add and remove objects from the
DataWindow object by providing specifications for the objects.

27
PowerBuilder - Technical Telephone Interview -
5/2/2011

How do you intercept an SQL statement?


SQLPreview Event
A SQLPreview event occurs after a Retrieve, Update, or ReselectRow function call, and immediately
before the function is executed. The event is triggered each time SQL is to be sent to the DBMS. The
event is triggered once following a Retrieve or ReselectRow call; the event is triggered once for each row
updated following an Update call. The SQLPreview event has action codes that specify the action that
takes place when the event occurs after an Update function call. To set the action code, call the
SetActionCode function. The action codes are:

0 - (Default) Continue.
1 - Stop processing.
2 - Skip this request and execute the next request.

Note When the Retrieve function triggers the SQLPreview event, the DataWindow control has already
been reset (unless a SetActionCode has been issued in the RetrieveStart event). When the Update
function triggers the SQLPreview event, the DataWindow control has not been reset.
From this event a developer can call the function dwGetSQLPreview() to inspect the SQL statement that
is about to be sent to the server.

CatchingChanges before the window Closes.


Script for the Window CloseQuery Event.
//Check if anything has changed
If dw_1.ModifiedCount() > 0 OR dw_DeleteCount() > 0 Then

Data Pipeline.
The Data Pipeline allows you to copy tables and their data from one database to another even if the
databases are on different DBMSs. For example, you can copy a database table in a SQL Server database
to a Watcom database. This is useful when you want to copy data to a local database so you can work on
it without needing access to the network. Data is piped from one or many sources to one destination only.
Start() executes a Pipeline object.

How to Communicate: (DDE with PowerBuilder)


Check if the program is running.
If not then RUN() can be called to start the server application

integer iHandle
iHandle = OpenChanel (“EXCEL”, “text.xls”) - begins the conversation
SetRemote (“R1C1”,sData,iHandle) - is used to pass data from the PB-DDE client to the DDE server.
GetRemote(“R1C1:R6C12”,sData,iHandle)
ExecRemote(“[Save()]”,iHandle)

28
PowerBuilder - Technical Telephone Interview -
5/2/2011
1. Please explain the difference between SetTrans and SetTransObject.

In simple terms, SetTrans() gives you no control on the transactions. It


automatically connects to and disconnects from the database after each Retrieve()
and Update() function. It is useful when the number of connections are limited, but,
you can't use this for multi-table update. On the other hand SetTransObject() gives
you full control over the transactions. It is your responsibility to connect to and
disconnect from the database and also, you need to issue COMMIT/ROLLBACK
statements. This method is more efficient since there is no connect/disconnect
overhead for each database operation.

2. Please explain how you would implement a multi-table update from a


single datawindow.

3. Please explain how you would ensure that a multi-datawindow update


was properly managed within a single logical unit of work.

Other than that, I simply ask them how they've used some of the
primary features of the product. (i.e., "Tell me how you've used
dynamic datawindows). You can usually tell when they're bluffing

What objects can you not inherit?

When should you use a global function?

When should you use SetTrans()?

29

Potrebbero piacerti anche