Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
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
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.
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
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.
A Having clause specifies a restriction on a grouped table by eliminating groups that do not satisfy a
search condition.
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;
4
PowerBuilder - Technical Telephone Interview -
5/2/2011
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.
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”)
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
6
PowerBuilder - Technical Telephone Interview -
5/2/2011
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.
Array (a group of variables of the same type grouped under one name)
7
PowerBuilder - Technical Telephone Interview -
5/2/2011
If the value is accepted, PowerBuilder will move the data from the edit control to the DataWindow buffer
and enable the focus to change.
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.
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.
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.
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:
9
PowerBuilder - Technical Telephone Interview -
5/2/2011
Function Declaration
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 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.
11
PowerBuilder - Technical Telephone Interview -
5/2/2011
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.
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)
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
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)
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)
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.
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.
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)
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
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
18
PowerBuilder - Technical Telephone Interview -
5/2/2011
Specified Status
Original Status New! NewModified! DataModified! NotModified!
New! - Yes Yes No
NewModified! No - Yes New!
DataModified! NewModified! Yes - Yes
NotModified! Yes Yes Yes -
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
-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.
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.
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'")
20
PowerBuilder - Technical Telephone Interview -
5/2/2011
A dw_object allows, users to display, manipulate, and update database or other information. You build
dw_objects in the DataWindow Painter.
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.
21
PowerBuilder - Technical Telephone Interview -
5/2/2011
Creating Group.
In DataWindows, you can group rows for reporting purposes. These groups can be used in the
DataWindow object and in reports to:
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.
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
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).
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;
23
PowerBuilder - Technical Telephone Interview -
5/2/2011
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.
PowerBuilder Features
Portability across multiple platforms (window,nt,macintosh,unix-motif)
Application migration from version to version (compatibility)
Decision Structures
If...Then, Do...Loop, For...Next, And, Or, Not, Else, Choose Case, Loops
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)
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)
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
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.
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.
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.
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
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.
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.
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.
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
29