technical telephone interview

Upload: orosado

Post on 08-Apr-2018

229 views

Category:

Documents


0 download

TRANSCRIPT

  • 8/7/2019 Technical Telephone Interview

    1/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 isassociated with the correct table or relationship. There are five tests. In this section, we will talk aboutthe 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 inthe 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 keysBefore 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

  • 8/7/2019 Technical Telephone Interview

    2/29

    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 youknow 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-querystatements.

    Formats 2, 3, and 4 uses the Dynamic Staging Area to provide a connection between a SQL statementand 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 atcompile 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 areunknown

    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 untilruntime, PB uses a Dynamic Description Area (SQLDA) , by default to store information aboutthese 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 transactionobject: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-leveldynamicDescriptionArea named SQLDA that you can use when you need a DynamicDescriptionAreavariable.

    2

  • 8/7/2019 Technical Telephone Interview

    3/29

    PowerBuilder - Technical Telephone Interview -5/2/2011

    SQL Topics:

    SQL Data Definition Language Statements.Create, Alter, Drop

    SQL DataControl Language Commands.

    Grant RevokeLocking 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 currentstate 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 fromIndiana is the predicate. A relation is a predicate with two or more subjects. John and Bob are brothersis an example of a relation. The common way of visualizing a set of relational statements is a table wherethe 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 FROMclause.

    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 thenumber 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 theresult of the previously specified clause.

    A Having clause specifies a restriction on a grouped table by eliminating groups that do not satisfy asearch 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

  • 8/7/2019 Technical Telephone Interview

    4/29

    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, CustomersWHERE Salespeople.city = Customers.city

    UNIONSELECT snum,sname, NO MATCH, commFROM SalespeopleWHERE NOT city = ANY

    (SELECT cityFROM Customers)

    ORDER BY 2 DESC;

    Insert = INSERT INTO SalespeopleVALUES (1001, Peel, London, .12);

    Join = SELECT Customer.cname, Salespeople.sname, Salespeople.cityFROM Salespeople, Customers (joining two tables)

    WHERE Salespeople.city=Customer.city (the predicate) (equijoins =)

    Update = UPDATE CustomersSET rating = 200WHERE 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 Invoicecontains the information from one Customer row and one Invoice row. If a particular customer has noinvoices, there will be no information for that customer.

    A LEFT OUTER JOIN Bincludes 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 willcontain 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

  • 8/7/2019 Technical Telephone Interview

    5/29

    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 withthe same name and the same arguments as the ancestor function. Otherwise, you would simply call thefunction with no qualifiers. This example calls the ancestor function wf_myfunc. Presumably, thedescendant 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'sfunction is being called. Otherwise the compiler will return a syntax error. The example above wouldhave 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 syntaxerror 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 Script2. 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 anancestor of the user object, menu, or window. You can also call scripts for events for controls in anancestor of the user object or window.

    CALL ancestorobject {`controlname}::eventCALL ancestorwindow::eventCALL ancestorwindowcontrol::eventCALL ancestorwindowobject::event

    CALL ancestoruserobject::eventCALL ancestoruserobjectobject::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

  • 8/7/2019 Technical Telephone Interview

    6/29

    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 aSELECT statement:

    The Datawindow was initially set up with update capability against the Department table. Therefore, youupdate 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 Departments columnsdw_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 tabledw_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 tableIF dw_master.Update() = 1 THENCOMMIT Using SQLCA;

    dw_master.ResetUpdate ()ELSEROLLBACK 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 THENIF dw_orderitem.Update(TRUE,FALSE) = 1 THEN

    COMMIT Using SQLCA;// Clear the flags for both windowsdw_orderheader.ResetUpdate()dw_orderitem.ResetUpdate()

    ELSE

    ROLLBACK Using SQLCA:END IF

    ELSE// make sure everything is clearedROLLBACK Using SQLCA;

    END IF

    Variables (Local, Instance Shared, Global)

    6

  • 8/7/2019 Technical Telephone Interview

    7/29

    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 variableretain 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 controlsassociated 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. ArrayStructure (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

  • 8/7/2019 Technical Telephone Interview

    8/29

    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, EditControltries 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 isnt of the correct type, the ItemError Event will betriggered.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 tothe 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 fielddoes not pass the validation rules for its column. ItemError can also occur when a value imported into aDataWindow 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 theDataWindow). ItemChanged can also occur when the AcceptText or Update function is called for aDataWindow 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 dont allow focus to change2 - 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 ControlSetText() = To place a value into the Edit ControlAcceptText() = To ensure or to force the DataWindow to validate and accept the value in the edit

    box.

    8

  • 8/7/2019 Technical Telephone Interview

    9/29

    PowerBuilder - Technical Telephone Interview -5/2/2011

    What is the difference between EditChange event and ItemChangedevent?

    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 toreplace 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 aDropDownListBox 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 thevalue originally in the column.

    9

  • 8/7/2019 Technical Telephone Interview

    10/29

    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 tothe 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 madeto 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 nowchange 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

  • 8/7/2019 Technical Telephone Interview

    11/29

    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 bymaking them private or protected. This means, other objects needing to access attribute values or changetheir values need a mechanism to do so. To give read-only access to a private or protected attribute weimplement 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 theattributes. These public functions become part of the objects public interface.

    11

  • 8/7/2019 Technical Telephone Interview

    12/29

    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 statusinformation 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 dws internal transaction objectSetTransObject - 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 automaticROLLBACK.

    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 Objectnamed SQLCA. You can use this transaction object or create another transaction object for thedw_control in a script. Transaction Object have 15 fields: 10 fields identify the database and server andfive 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 ObjectSQLCA.DBMS = SybaseSQLCA.LOGID = JoseSQLCA.UserId = DBASQLCA.Dbpass = SQLSQLCA..Dbparm =SQLCA..SQLcode =

    Forms of populating the Communication Are1. Hard Code the information

    2. Reading values from an External file3. Reading values from an .INI file

    Assign the Transaction Object to the datawindow control.dw_control.DataObject = dw_namedw_control.SetTransObject(SQLCA)dw_control.Retrieve()Commit or Rollback

    12

  • 8/7/2019 Technical Telephone Interview

    13/29

    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 theSystemError 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 betweenwindows when you open and close (OpenWithParm,OpenSheetWithParn and CloseWithReturnfunctions), 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 variable2. Message.DoubleParm A numeric or numeric variable3. Message. PowerObjectParm Any PowerBuilder object type

    13

  • 8/7/2019 Technical Telephone Interview

    14/29

    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 writea script for the frames 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.MicroHelpHeightli_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 AttributeChild! 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 isclosed.Response! A window that displays to obtain information from the user and cannot lose focus or be

    closed until the user responds.

    14

  • 8/7/2019 Technical Telephone Interview

    15/29

    PowerBuilder - Technical Telephone Interview -5/2/2011

    Where are all PowerBuilder objects stored?In PowerBuilder Libraries. (PBLs)

    Optimizing PBLs (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 indexlocations.

    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 execPBL = Source Code

    15

  • 8/7/2019 Technical Telephone Interview

    16/29

    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 inyour application may be referenced dynamically.

    What is a PowerBuilder Resource File (.PBR)?Use your favorite ASCII text editor to create the .PBR fileThe PowerBuilder Resource file (.PBR) allows you to include in the .EXE file or the .PBD file any objectthat 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. Besure 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 applicationAny resources that are conditionally referenced in a scriptThe 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

  • 8/7/2019 Technical Telephone Interview

    17/29

    PowerBuilder - Technical Telephone Interview -5/2/2011

    How do you pass parameters to a window?(message.wordparm, longparm, structure, objects, variable)

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

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

    UsageThe 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 thefollowing attributes.

    Message object attribute Parameter data typeMessage.DoubleParm NumericMessage.PowerObjectParm PowerObject (PowerBuilder objects, including user-definedstructures)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 anumber it is stored in Message.DoubleParm:

    w_employee w_to_open

    integer age = 50OpenWithParm(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 thefollowing attributes.

    Message object attribute Parameter data typeMessage.DoubleParm NumericMessage.PowerObjectParm PowerObject (PowerBuilder objects, including user-definedstructures)Message.StringParm String

    Passing structures vs. objects.Structure-PowerBuilder applications do not need to explicitly create or destroy the memory associated with astructured. 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 morewith objects if you wish. You can inherit new custom classes from existing custom classes. You cannotinherit structures. You can add behavior (methods or functions) to an object. You cannot add behavior toa structure. You are responsible for managing the memory of your own objects.

    17

  • 8/7/2019 Technical Telephone Interview

    18/29

    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 EventsIf 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) wont happen. It gets removed from the stack.

    Running an Application in Debug ModeWhen 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 anexecution 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 samePowerBuilder session, Debug resumes processing at the point at which you stopped.See alsoClosing DebugDisplaying Variable ValuesOpening DebugSelecting a Script to Debug

    Setting Stops in a Script

    Places where you cant place a STOP in Debugger.1. Variable declaration2. Blank line3. Comments only lines4. End If lines

    After encountering a STOP while running the Debugger you can:1. View the value of variables2. Set new STOP points3. Select another script to debug4. Remove existing STOP

    18

  • 8/7/2019 Technical Telephone Interview

    19/29

    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 determinesthe type of SQL statement the Update function will generate for the row.

    Specified StatusOriginal 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 determinesthe 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 changedinformation 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. Onlycolumns 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

  • 8/7/2019 Technical Telephone Interview

    20/29

    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 beuseful, 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 OutputFile DataWindow FileFile DataWindow DatabaseMainframe 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.

    RETURNUse RETURN to end the execution of a script or function immediately. When RETURN is used in ascript, 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 changethe 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 theDataWindow object by providing specifications for the objects.

    Applies toDataWindow 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 picturestoolbar, Icon-minimize window, applications-icon.

    20

  • 8/7/2019 Technical Telephone Interview

    21/29

    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 applications open,close,idle, andsystem error events)

    Application object attributesAppName, 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 withinthem to displays and manipulate data in the window.

    A dw_object allows, users to display, manipulate, and update database or other information. You builddw_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 currentsettings 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 listboxat 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

  • 8/7/2019 Technical Telephone Interview

    22/29

    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 theDataWindow object and in reports to:

    Specify page breaks and page numberingSpecify header and trailer information for groupings of informationReport 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 thedepartment number changes and can report on information about each department in the DataWindowobject. 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 inchanges 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 theDataWindow 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 grouplevel 1 contains the column named Dept_Nbr and group 2 contains the column named Location and youspecify 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 alsoDeleting a GroupEditing a GroupUsing the Specify Group Window

    Stored Procedures vs. Triggers.Store procedures Triggers1. are called 1. are event driven2. can be passed arguments 2. like events, cannot be passed3. 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

  • 8/7/2019 Technical Telephone Interview

    23/29

    PowerBuilder - Technical Telephone Interview -5/2/2011

    Is a database access standard and hence the development tools PowerBuilder can be utilized against anyDBMS that supports the ODBC standard. ODBC has emerged as the de facto standard for MS Windows

    platform and is comment of Microsofts 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 thecurrent record in a particular answer set. Is a kind of variable that is associated with a Query. The valueof this variable will be each row, in turn of the quereys output. Like a host variables, cursors must bedeclared 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 essentiallySET_ORIENTED, SQL Server does not have an explicit method or representing a single row within atable.

    Cursor Declaration.DECLARE acctcur CURSOR FOR SELECT account_no,acct_id,etc.

    FROM account_noORDER BY account_no.acct_id ASC;CONNECT Using SQLCA;OPEN acctcur FETCH acctcur INTO: account_id, etc.DO WHILE SQLCA.SQLCode = 0..........LOOPCLOSE 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

  • 8/7/2019 Technical Telephone Interview

    24/29

    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 ancestors 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 FeaturesPortability 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 StructuresIf...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 space3. 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 objectshave 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 usingthe UserObject Painter and place the desired drawing object in the UserObject. By using this techniqueyou 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

  • 8/7/2019 Technical Telephone Interview

    25/29

    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 controlEx. 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 ObjectTo identify the data type of a dragged object (source object) that the user dropped on a target object, usethe DraggedObject function and a variable of the data type DragObject.ExampleThe 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 thetype 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! thenText = SourceText.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 aCHOOSE CASE statement.See alsoCHOOSE CASEDraggedObject FunctionTypeOf Function

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

    Composite ReportsDo not have a data source.

    25

  • 8/7/2019 Technical Telephone Interview

    26/29

    PowerBuilder - Technical Telephone Interview -5/2/2011

    Crosstab ReportStatic - establishes the rows and columns based on the data in the database when you define the crosstab.

    PB System tablesPBCatTbl, 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 combinesthem into reusable units with classes. OOP combines data and process to perform a specialized role in asystem

    2. What is encapsulation?Data Hiding, Data Protection. (UserObjects, Inheritance, Instance Variables) When you combines dataand process to perform a specialized role in a system. The goal of encapsulation is to separate theimplementation of an object from how other objects interact with that object. You provide events andfunctions that others must go through first. So, how do you actually protect your attributes from beingmodified 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 tocooperate without having to understand or interfere with each others internal process.

    The Power of Polymorphism Here is another benefit of using messages. Becauseobjects are define independently of one another, the same name can be used for different methods in different objects.

    For example consider the messageADD 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

  • 8/7/2019 Technical Telephone Interview

    27/29

    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 asfollows.object.instance-variablemenu.menu1.

    How do you update a window and child window?Using a Child DataWindowA child DataWindow object is a DropDownDataWindow in a DataWindow object. ADropDownDataWindow 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 dwcint 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 isdisplayed, you need to explicitly retrieve data when there are retrieval arguments or when conditionschange 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. Eachcolumn 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 youinclude Describe's Evaluate function in the attribute list, the value of the evaluated expression is includedin the reported information.

    Modify ()Modifies a DataWindow object by applying specifications, specified as a list of instructions, that changethe 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 theDataWindow object by providing specifications for the objects.

    27

  • 8/7/2019 Technical Telephone Interview

    28/29

    PowerBuilder - Technical Telephone Interview -5/2/2011

    How do you intercept an SQL statement?SQLPreview EventA 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. Theevent 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 thattakes place when the event occurs after an Update function call. To set the action code, call theSetActionCode 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 Updatefunction 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 thatis about to be sent to the server.

    CatchingChanges before the window Closes.Script for the Window CloseQuery Event.//Check if anything has changedIf 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 thedatabases are on different DBMSs. For example, you can copy a database table in a SQL Server databaseto a Watcom database. This is useful when you want to copy data to a local database so you can work onit 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 iHandleiHandle = OpenChanel (EXCEL, text.xls) - begins the conversationSetRemote (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

  • 8/7/2019 Technical Telephone Interview

    29/29

    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. Itautomatically 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() givesyou full control over the transactions. It is your responsibility to connect to anddisconnect from the database and also, you need to issue COMMIT/ROLLBACK statements. This method is more efficient since there is no connect/disconnectoverhead for each database operation.

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

    3. Please explain how you would ensure that a multi-datawindow updatewas properly managed within a single logical unit of work.

    Other than that, I simply ask them how they've used some of theprimary features of the product. (i.e., "Tell me how you've useddynamic 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()?