Powerbuilder Interview Questions Part 1

1

Ans.

How can you generate runtime datawindow object? 

 

Using syntaxfromsql function to get sqlsyntaxt for the passed sql string and then calling function create

 

SyntaxFromSQL:

transaction.SyntaxFromSQL ( sqlselect, presentation, err )

 

Argument Description

 

Transaction.     The name of a connected transaction object

 

Sqlselect.         A string whose value is a valid SQL SELECT statement

 

Presentation.    A string whose value is the default presentation style you want for the DataWindow. The        

                          simple format is: Style(Type=presentationstyle)Values for presentationstyle correspond to 

                          the styles in the New DataWindow dialog box in the DataWindow painter. Keywords are: 

                          (Default) TabularGridForm (for freeform)GraphGroupLabelNup. The Usage section lists the

                          keywords you can use in  presentation.

 

err                     A string variable to which PowerBuilder will assign any error messages that occur Return

                          value String. Returns the empty string (“”) if an error occurs. If SyntaxFromSQL fails, err may

                          contain error messages if warnings or soft errors occur (for example, a syntax error). If any

                          argument’s value is NULL, SyntaxFromSQL returns NULL.

 

Syntax of Create:

dwcontrol.Create ( syntax {, errorbuffer } )

 

Argument Description

Dwcontrol        The name of the DataWindow control or DataStore in which PowerBuilder will create the new

                          DataWindow object

syntax               A string whose value is the DataWindow source code that will be used to create the

                          DataWindow object

errorbuffer  (optional)   The name of a string that will hold any error messages that occur. If you do not

                          specify an error buffer, a message box will display the error messages

Return value

Integer.          Returns 1 if it succeeds and -1 if an error occurs. If any argument’s value is NULL, Create

                       returns NULL.

2

 

Ans.

How can you open a userobject or tabcontrol in a window?

 

tabcontrolname.OpenTab ( userobjectvar, index )

 

Argument          Description

Tabcontrolname    The name of the Tab control in which you want to open the user object as a tab page

Userobjectvar         The name of the custom visual user object you want to open as a tab page. You can

                                specify a custom visual user object defined in the User Object painter (which is a user

                                object data type) or a variable of the desired user object data type. Open places a             

                                reference to the opened custom visual user object in userobjectvar.

Index                      The number of the tab before which you want to insert the new tab. If index is 0 or greater

                               than the number of tabs, the tab page is inserted at the end

Return value

Integer. Returns 1 if it succeeds and -1 if an error occurs. If any argument’s value is NULL, OpenTab returns NULL.

 

windowname.OpenUserObject ( userobjectvar {, x, y } )

Argumen Description

windowname    The name of the window in which you want to open the user object

userobjectvar   The name of the user object you want to display. You can specify a user object defined in the

                          User Object painter (which is a user object data type) or a variable of the desired user object

                          data type. Open places a reference to the opened user object in userobjectvar

x (optional)       The x coordinate in PowerBuilder units of the user object within the window’s frame. The

                          default is 0

y (optional)       The y coordinate in PowerBuilder units of the user object within the window’s frame. The

                          default is 0

 

3

 

Ans.

What is garbage collection and what are the functions to set and get garbage time limit?

What garbage collection does

The PowerBuilder garbage collection mechanism checks memory automatically for unreferenced and orphaned objects and removes any it finds, thus taking care of most memory leaks. You can use garbage collection to destroy objects instead of explicitly destroying them using the DESTROY statement. This lets you avoid execution-time errors that occur when you destroy an object that was being used by another process or had been passed by reference to a posted event or function.

 

When garbage collection occurs

Garbage collection occurs:

¨           When a reference is removed from an object A reference to an object is any variable whose value is the object. When the variable goes out of scope, or when it is assigned a differenent value, PowerBuilder removes a reference to the object, counts the remaining references, and destroys the object if no references remain.

¨           When the garbage collection interval is exceeded When PowerBuilder completes the execution of a system-triggered event, it makes a garbage collection pass if the set interval between garbage collection passes has been exceeded. The default interval is 0.5 seconds. The garbage collection pass removes any objects and classes that cannot be referenced, including those containing circular references (otherwise unreferenced objects that reference each other).

 

Posting events and functions When you post an event or function and pass an object reference, PowerBuilder adds an internal reference to the object to prevent it from being garbage collected between the time of the post and the actual execution of the event or function. This reference is removed when the event or function is executed.

 

Exceptions to garbage collection

 

There are a few objects that are prevented from being garbage collected:

¨           Visual objects Any object that is visible on your screen is not garbage collected because when the object is created and displayed on your screen an internal reference is added to the object. When any visual object is closed it is explicitly destroyed.

 

¨           Timing objects Any Timing object that is currently running is not garbage collected because the Start function for a Timing object adds an internal reference. The Stop function removes the reference.

 

¨           Shared objects Registered shared objects are not garbage collected because the SharedObjectRegister function adds an internal reference. SharedObjectUnregister removes the internal reference.

 

Controlling when garbage collection occurs

 

Garbage collection occurs automatically in PowerBuilder, but you can use the functions GarbageCollect, GarbageCollectGetTimeLimit, and GarbageCollectSetTimeLimit to force immediate garbage collection or to change the interval between reference count checks. By setting the interval between garbage collection passes to a very large number, you can effectively turn off garbage collection.

 

4

Ans

Give some example of function overloading?

Messagebox(),Open(),opentab(),openuserobject() etc. all these functions are overloaded because there are more than one function with same name in same class with different number of parameter.

 

5

Ans

Can you open a response window with opensheet function?

Yes, we can open a response window with opensheet function but then that window will not work as response.It will work as a main window.So Opening response windows  Do not use the OpenSheet function to open a response window

 

6

Ans

Can you open more that one response window at the same time.and why?

No, you can not open multiple response windows at the same time because when you open one response window It expects some input from user then only it proceed further.

 

7

Ans

You can inherit the user object and window so which one is preferable and why?

User object is preferable because it takes less memory because in memory structure there there are two pool class pool and instance pool. Class pool maintain the class like window ,userobject and instance pool which keeps all instances of the objects. To run a application atleast one window should be open

So always there will be one window class in class pool. But in case of there is no need to keep any user object in class pool when we do not need it.

8

 

Ans

What is the return value of describe and modify function?

 

dwcontrol.Describe ( propertylist )

Argument Description

dwcontrol         The name of the DataWindow control, DataStore, or child DataWindow for which you want

                           information about the structure

propertylist      A string whose value is a blank-separated list of properties or Evaluate functions. For a list of

                          valid properties, see the DataWindow Reference

Return value

 

String. Returns a string that includes a value for each property or Evaluate function. A newline character (~n) separates the value of each item in propertylist.

If the property list contains an invalid item, Describe returns an exclamation point (!) for that item and ignores the rest of the property list. Describe returns a question mark (?) if there is no value for a property.

When the value of a property contains a question mark (?), the value is returned in quotes so that you can distinguish between it and a property with no value.

 

If any argument’s value is NULL, Describe returns NULL.

 

9

 

Ans

Can you copy data from one datawindow to other? And how?

 

Yes, we can copy data from one datawindow to other. To do so we can use function rowscopy.

dwcontrol.RowsCopy (startrow, endrow, copybuffer, targetdw, beforerow, targetbuffer )

 

Argument Description

dwcontrol The name of a DataWindow control, DataStore, or child DataWindow from which you want to copy

                   rows

startrow       A long whose value is the number of the first row you want to copy

endrow         A long whose value is the number of the last row you want to copy

copybuffer   A value of the dwBuffer enumerated data type specifying the buffer from which you want to 

                      copy the rows: ¨Primary!¨Delete!¨Filter!

targetdw       The name of the DataWindow control or DataStore object to which you want to copy the rows.

                      Targetdw can be the same DataWindow (or DataStore) or another DataWindow (or DataStore)

Beforerow    A long specifying the number of the row before which you want to insert the copied rows. To

                      Insert after the last row, use any value that is greater than the number of existing rows

Targetbuffer A value of the dwBuffer enumerated data type specifying the target buffer for the copied rows.

                      Values are: ¨Primary!¨Delete!¨Filter!

Return value

 

Integer. Returns 1 if it succeeds and -1 if an error occurs. If any argument’s value is NULL, RowsCopy returns NULL.

 

Usage

 

When you use the RowsCopy function, the status of the rows that are copied to the primary buffer is NewModified!. If you issue an update request, PowerBuilder will send SQL INSERT statements to the DBMS for the new rows.

 

When you use RowsCopy, data is not automatically retrieved for drop-down DataWindows in the target DataWindow or DataStore, as it is when you call InsertRow. You must explicitly call Retrieve for child DataWindows in the target.

 

Uses for RowsCopy include:

 

¨           Making copies of one or more rows so that the users can create new rows based on existing data

¨           Printing a range of rows by copying selected rows to another DataWindow and printing the second DataWindow

 

Buffer manipulation and query mode  A DataWindow cannot be in query mode when you call the RowsCopy function.

10

 

Ans

Can you copy data from one buffer to other within the same DataWindow and how?

 

Yes, we can copy data from one datawindow to other. To do so we can use function rowscopy.

dwcontrol.RowsCopy (startrow, endrow, copybuffer, targetdw, beforerow, targetbuffer )

Argument Description

 

Dwcontrol  The name of a DataWindow control, DataStore, or child DataWindow from which you want to

                    copy rows

 

startrow     A long whose value is the number of the first row you want to copy endrow. A long whose value

                    is the number of the last row you want to copy

 

copybuffer A value of the dwBuffer enumerated data type specifying the buffer from which you want to copy

                    the rows: ¨Primary!¨           Delete!¨ Filter!

 

Targetdw    The name of the DataWindow control or DataStore object to which you want to copy the rows.

                    Targetdw can be the same DataWindow (or DataStore) or another DataWindow (or DataStore)

 

Beforerow  A long specifying the number of the row before which you want to insert the copied rows. To

                    insert after the last row, use any value that is greater than the number of existing rows.

 

Targetbuffer A value of the dwBuffer enumerated data type specifying the target buffer for the copied rows. Values are: ¨Primary!¨Delete!¨Filter!

 

Return value

 

Integer. Returns 1 if it succeeds and -1 if an error occurs. If any argument’s value is NULL, RowsCopy returns NULL.

 

Usage

 

When you use the RowsCopy function, the status of the rows that are copied to the primary buffer is NewModified!. If you issue an update request, PowerBuilder will send SQL INSERT statements to the DBMS for the new rows.

 

When you use RowsCopy, data is not automatically retrieved for drop-down DataWindows in the target DataWindow or DataStore, as it is when you call InsertRow. You must explicitly call Retrieve for child DataWindows in the target.

 

Uses for RowsCopy include:

 

¨           Making copies of one or more rows so that the users can create new rows based on existing data

¨           Printing a range of rows by copying selected rows to another DataWindow and printing the second

             DataWindow

 

Buffer manipulation and query mode. A DataWindow cannot be in query mode when you call the Rowcopy function.

 

11

 

Ans

 

How can you move record from one datawindow to other and one buffer to other?

 

Yes you can do so using rowsmove function.

 

dwcontrol.RowsMove ( startrow, endrow, movebuffer, targetdw, beforerow, targetbuffer )

 

Argument Description

Dwcontrol   The name of a DataWindow control, DataStore, or child DataWindow from which you want to move rows

startrow            A long whose value is the number of the first row you want to move

 

endrow             A long whose value is the number of the last row you want to move

 

movebuffer       A value of the dwBuffer enumerated data type specifying the buffer from which you want to move the rows. Values are:¨ Primary! ¨Delete! ¨Filter!

 

targetdw           The name of the DataWindow control or DataStore to which you want to move the rows. Targetdw can be the same DataWindow control (or DataStore) or a different DataWindow control (or DataStore), but it cannot be a child DataWindow

 

beforerow         A long specifying the number of the row before which you want to insert the moved rows. To insert after the last row, use any value that is greater than the number of existing rows

 

targetbuffer      A value of the dwBuffer enumerated data type specifying the target buffer for the moved rows. Values are: ¨Primary!¨Delete!¨Filter!

 

Return value

 

Integer. Returns 1 if it succeeds and -1 if an error occurs. If any argument’s value is NULL, RowsMove returns NULL.

 

Usage

When you use RowsMove, the rows have the status NewModified! in the target DataWindow.

 

If you move rows between buffers in a single DataWindow control or DataStore, PowerBuilder retains knowledge of where the rows came from and their status is changed accordingly. For example, if you move unmodified rows from the primary buffer to the delete buffer, they are marked for deletion. If you move the rows back to the primary buffer, their status returns to NotModified!. Note, however, that if you move rows from one DataWindow control (or DataStore) to another and back again, the rows’ status is NewModified! because they came from a different DataWindow.

 

When you use RowsMove, data is not automatically retrieved for drop-down DataWindows in the target DataWindow, as it is when you call InsertRow. You must explicitly call Retrieve for child DataWindows in the target.

 

Uses for RowsMove include:

 

¨           Moving several rows from the primary buffer to the delete buffer, instead of deleting them one at a time

¨           Moving rows from the delete buffer to the primary buffer, to implement an Undo capability in your application

 

Buffer manipulation and query mode  A DataWindow cannot be in query mode when you call the RowsMove function.

 

 

12

 

Ans

 

How can you delete or filter the records with out sending them to buffer?

 

We can do so by using rowsdiscard function.

dwcontrol RowsDiscard (startrow, endrow, buffer )

 

Argument Description

Dwcontrol  The name of a DataWindow control or child DataWindow from which you want to discard rows

 

Startrow  A long whose value is the number of the first row you want to discard

 

Endrow   A long whose value is the number of the last row you want to discard

 

buffer     A value of the dwBuffer enumerated data type specifying the buffer containing the rows to be discarded. Values are: ¨ Primary!¨Delete!¨Filter!

 

Return value

 

Integer. Returns 1 if it succeeds and -1 if an error occurs. If any argument’s value is NULL, RowsDiscard returns NULL.

 

Usage

 

Use RowsDiscard when your application is finished with some of the rows in a DataWindow control and you don’t want an update to affect the rows in the database. For example, you can discard rows in the delete buffer, which prevents the rows from being deleted when you call Update.

To clear all the rows from a DataWindow control, use Reset.

 

13

 

 

Ans

If the datawindow update property is false and you applied a delete function to some records what will happen?

 

In this case deleted rows will not go to the delete buffer. This time delete work as rowsdiscard function

14

 

Ans

How can you make sharing of datawindow off?

 

You can do so using function sharedataoff.

dwcontrol.ShareDataOff ( )

 

Argument Description

 

Dwcontrol    The name of the DataWindow control, DataStore, or child DataWindow for which you want to turn off data sharing

 

Return value

Integer. Returns 1 if it succeeds and -1 if an error occurs. If dwcontrol is NULL, ShareDataOff returns NULL.

 

Usage

Two or more DataWindow controls (or DataStores) can share data. See ShareData for more information about shared data buffers and primary and secondary DataWindows.

When you call ShareDataOff for a secondary DataWindow, that control no longer contains data, but the primary DataWindow and other secondary controls are not affected. When you call ShareDataOff for the primary DataWindow, all secondary DataWindows are disconnected and no longer contain data.

 

15

 

Ans

 

What are the restrictions to share data between to datawindow?

 

dwprimary.ShareData ( dwsecondary )

 

Argument Description

 

Dwprimary       The name of the primary DataWindow. The primary DataWindow is the owner of the data. When you destroy this DataWindow, the data disappears. Dwprimary can be a child DataWindow

 

Dwsecondary   The name of the secondary DataWindow; which is the control  dwprimary will share the data with. The secondary DataWindow cannot be a Crosstab DataWindow. It can be a child DataWindow

 

Return value

Integer. Returns 1 if it succeeds and -1 if an error occurs. If any argument’s value is NULL, ShareData returns NULL.

 

Usage

The columns must be the same for the DataWindow objects in the primary and secondary DataWindow controls, but the SELECT statements may be different. For example, you could share data between DataWindow objects with these SELECT statements:

 

SELECT dept_id from dept

SELECT dept_id from dept where dept_id = 200

SELECT dept_id from employee

 

WHERE clause in secondary has no effect  The WHERE clause in the DataWindow object in the secondary DataWindow control has no effect on the number of rows returned. The number of rows returned to both DataWindow controls is determined by the WHERE clause in the primary DataWindow object.

 

You could also share data with a DataWindow object that has a script data source and a column defined to be like the dept_id column.

 

To share data between a primary DataWindow and more than one secondary DataWindow control, call ShareData for each secondary DataWindow control.

 

To turn off sharing in a primary or secondary DataWindow, call the ShareDataOff function. When sharing is turned off for the primary DataWindow, the secondary DataWindows are disconnected and the data disappears. However, turning off sharing for a secondary DataWindow does not affect the data in the primary DataWindow or other secondary DataWindows.

 

When you call functions in either the primary or secondary DataWindow that change the data, PowerBuilder applies them to the primary DataWindow control and all secondary DataWindow controls are affected. For example, when you call any of the following functions for a secondary DataWindow control, PowerBuilder applies it to the primary DataWindow. Therefore, all messages normally associated with the function go to the primary DataWindow control. Such functions include:

 

DeleteRow

Filter

GetSQLSelect

ImportFile

ImportString

ImportClipboard

InsertRow

ReselectRow

Reset

Retrieve

SetFilter

SetSort

SetSQLSelect

Sort

Update

 

Computed fields in secondary DataWindow controls A secondary DataWindow control can only have data which is in the primary DataWindow control. If you add a computed field to a secondary control, it will not display when you run the application unless you also add it to the primary control.

 

Query mode and secondary DataWindows When you are sharing data, you cannot turn on query mode for a secondary DataWindow. Trying to set the QueryMode or QuerySort properties results in an error.

 

To share data between a DataStore or DataWindow and a RichTextEdit control, use the DataSource function.

 

Crosstab DataWindows  You cannot use ShareData with Crosstab DataWindows.

 

Distributed applications You cannot share data between a DataWindow control in a client application and a DataStore in a server application.

 

16

 

Ans

What are the four methods of dynamic sql? Describe it.

 

Dynamic SQL syntax format 1:

Use this format to execute a SQL statement that does not produce a result set and does not require input parameters. You can use this format to execute all forms of Data Definition Language (DDL).

 

Dynamic SQL Syntax format 2:

Use this format to execute a SQL statement that does not produce a result set but does require input parameters. You can use this format to execute all forms of Data Definition Language (DDL).

 

Syntax

PREPARE DynamicStagingArea FROM SQLStatement             {USING TransactionObject} ;

 

EXECUTE DynamicStagingArea USING {ParameterList} ;

 

Parameter Description

 

DynamicStagingArea    The name of the DynamicStagingArea (usually SQLSA)If you need a DynamicStagingArea variable other than SQLSA, you must declare it and                                         instantiated it with the CREATE statement before using it

 

SQLStatement         A string containing a valid SQL statement. The string can be a string constant or a PowerBuilder variable preceded by a colon (such as :mysql). The string must be contained on one line and cannot contain expressionsEnter a question mark (?) for each parameter in the statement. Value substitution is positional; reserved word substitution is not allowed.

 

TransactionObject (optional)    The name of the transaction object that identifies the database ParameterList (optional). A comma-separated list of PowerScript variables. Note that PowerScript variables are preceded by a colon (:)

 

Usage

To specify a NULL value, use the SetNull function.

 

 

Dynamic SQL syntax format 3: Use this format to execute a SQL statement that produces a result set in which the input parameters and result set columns are known at compile time.

 

Syntax

 

DECLARE Cursor | Procedure    DYNAMIC CURSOR | PROCEDURE       FOR DynamicStagingArea ;

 

PREPARE DynamicStagingArea FROM SQLStatement   {USING TransactionObject} ;

 

OPEN DYNAMIC Cursor            {USING ParameterList} ;

 

EXECUTE DYNAMIC Procedure {USING ParameterList} ;

 

FETCH Cursor | Procedure         INTO HostVariableList ;

 

CLOSE Cursor | Procedure ;

 

Parameter Description

 

Cursor or Procedure    The name of the cursor or procedure you want to use

 

DynamicStagingArea    The name of the DynamicStagingArea (usually SQLSA)If you need a DynamicStagingArea variable other than SQLSA, you must declare it and instantiate it with the CREATE statement before using it.

 

SQLStatement  A string containing a valid SQL SELECT statement The string can be a string constant or a PowerBuilder variable preceded by a colon (such as :mysql). The string must be contained on one line and cannot contain expressions Enter a question mark (?) for each parameter in the statement. Value substitution is positional; reserved word substitution is not allowed.

 

TransactionObject (optional)    The name of the transaction object that identifies the database ParameterList (optional). A comma-separated list of PowerScript variables. Note that PowerScript variables are preceded by a colon (:)

 

HostVariableList The list of PowerScript variables into which the data values will be retrieved.

 

Usage

 

To specify a NULL value, use the SetNull function.

 

The DECLARE statement is not executable and can be declared globally.

 

If your DBMS supports formats of FETCH other than the customary (and default) FETCH NEXT, you can specify FETCH FIRST, FETCH PRIOR, or FETCH LAST.

 

The FETCH and CLOSE statements in Format 3 are the same as in standard embedded SQL.

 

To declare a global, shared, or instance cursor or procedure, select Global Variables, Instance Variables, or Shared Variables on the Declare menu of the PowerScript painter. To declare a local cursor, click the Paint SQL button in the PainterBar.

 

For information about global, instance, shared, and local scope, see “Where to declare variables “.

Accessing attribute information  When a statement is described into a DynamicDescriptionArea, this information is available to you in the attributes of that DynamicDescriptionArea variable:

 

Information Attribute

Number of input parameters       NumInputs

Array of input parameter types   InParmType

Number of output parameters    NumOutputs

Array of output parameter types OutParmType

 

Setting and accessing parameter values  The array of input parameter values and the array of output parameter values are also available. You can use the SetDynamicParm function to set the values of an input parameter and the following functions to obtain the value of an output parameter:

 

GetDynamicDate

GetDynamicDateTime

GetDynamicNumber

GetDynamicString

GetDynamicTime

 

For information about these functions, see GetDynamicDate, GetDynamicDateTime, GetDynamicNumber, GetDynamicString, and GetDynamicTime.

 

Parameter values  The following enumerated data types are the valid values for the input and output parameter types:

 

TypeBoolean!

TypeDate!

TypeDateTime!

TypeDecimal!

TypeDouble!

TypeInteger!

TypeLong!

TypeReal!

TypeString!

TypeTime!

TypeUInt!

TypeULong!

TypeUnknown!

 

Input parameters  You can set the type and value of each input parameter found in the PREPARE statement. PowerBuilder populates the SQLDA attribute NumInputs when the DESCRIBE is executed. You can use this value with the SetDynamicParm function to set the type and value of a specific input parameter. The input parameters are optional; but if you use them, you should fill in all the values before executing the OPEN or EXECUTE statement.

 

Output parameters  You can access the type and value of each output parameter found in the PREPARE statement. If the database supports output parameter description, PowerBuilder populates the SQLDA attribute NumOutputs when the DESCRIBE is executed. If the database does not support output parameter description, PowerBuilder populates the SQLDA attribute NumOutputs when the FETCH statement is executed.

 

You can use the number of output parameters in the NumOutputs attribute in functions to obtain the type of a specific parameter from the output parameter type array in the OutParmType attribute. When you have the type, you can call the appropriate function after the FETCH statement to retrieve the

output value.

 

17

Ans

 

What is the SQLSA?

DynamicStagingArea is a PowerBuilder data type. PowerBuilder uses a variable of this type to store information for use in subsequent statements.

 

The DynamicStagingArea is the only connection between the execution of a statement and a transaction object and is used internally by PowerBuilder; you cannot access information in the DynamicStagingArea.

 

PowerBuilder provides a global DynamicStagingArea variable named SQLSA that you can use when you need a DynamicStagingArea variable.

 

If necessary, you can declare and create additional object variables of the type DynamicStagingArea. These statements declare and create the variable, which must be done before referring to it in a dynamic SQL statement:

 

DynamicStagingArea dsa_stage1

 

dsa_stage1 = CREATE DynamicStagingArea

 

18

Ans

 

What is the SQLDA?

DynamicDescriptionArea is a PowerBuilder data type. PowerBuilder uses a variable of this type to store information about the input and output parameters used in Format 4 of dynamic SQL.

 

PowerBuilder provides a global DynamicDescriptionArea named SQLDA that you can use when you need a DynamicDescriptionArea variable.

 

If necessary, you can declare and create additional object variables of the type DynamicDescriptionArea. These statements declare and create the variable, which must be done before referring to it in a dynamic SQL statement:

 

DynamicDescriptionArea dda_desc1

 

dsa_desc1 = CREATE DynamicDescriptionArea

 

19

 

Ans

 

What is the deligation?

 

In service type application architecture we will have requester and service providers in delegation we have association and aggregation . aggregation means the service object can work in association with requester only they can not work independently exa. Sort service, filter service,serch service etc. and Association means service provider can  work independently. Exa. String and date objects

 

20

 

Ans

 

What is the difference between computed column and computed field?

 

Computed column means the column defined at sql mode through compute option. And computed field means we add control in to your datwindow object from control list.

 

 

21

 

Ans

 

How importstring function works what is the argument to it?

 

Inserts data into a DataWindow control or DataStore from tab-delimited data in a string.

 

Controls

DataWindow controls, DataStore objects, and child DataWindows

 

Syntax

dwcontrol.ImportString ( string {, startrow {, endrow {, startcolumn  {, endcolumn {, dwstartcolumn } } } } } )

 

Argument Description

 

Dwcontrol        The name of the DataWindow control or DataStore to which you want to copy data from the specified string

 

String   A string from which you want to copy the data. The string should contain tab-delimited columns with one row per line (see Usage)

 

startrow (optional)        The number of the starting row of data in the string you want to import. If the first row contains headings that you want to skip, set startrow to 2. The default is 1

 

endrow (optional)         The number of the last row of data in the string that you want to import. The default is all rows

 

startcolumn (optional)  The number of the first column in the string that you want to import. The default is 1

 

endcolumn (optional)   The number of the last column in the string that you want to import. The default is the rest of the columns

 

dwstartcolumn (optional)         The number of the first column in the DataWindow control or DataStore object that you want to receive data. The default is 1

 

ImportString may trigger an ItemError event.

 

Return value

Long. Returns the number of rows that were imported if it succeeds and one of the following negative integers if an error occurs:

 

-1  startrow value supplied is greater than the number of rows in the string

-3  Invalid argument

-4  Invalid input

-9  PowerBuilder or the user canceled import because data failed     validation

 

If any argument’s value is NULL, ImportString returns NULL.

 

Usage

The format of the string is the same as if the data came from an ASCII file. The string must be formatted in tab-delimited columns and each line must end with a carriage return and a newline character (~r~n). If the string has four tab-delimited columns, one line might look like:

 

col1_data~t col2_data~t col3_data~t col4_data~r~n

 

For a DataWindow control or DataStore, the string should consist of rows of data. If the data includes column headings or row labels, set the startrow and  startcolumn arguments to skip them. The data types and order of the DataWindow object’s columns must match the columns of data in the string.

 

The startcolumn and endcolumn arguments control the number of columns imported from the string and the number of columns in the DataWindow that are affected. The dwstartcolumn argument specifies the first DataWindow column to be affected. The following formula calculates the last DataWindow to be affected.

 

dwstartcolumn + ( endcolumn – startcolumn )

 

If string data to be assigned to a single row and column has multiple lines (indicated by line ending characters in the import string), you must quote the string data using ~”. Do not use single quotes.

 

This example of a valid import string assigns multiline values to each row in column 2:

 

ls_s = &

 

“1~t~”Mickey~r~nMinnie~r~nGoofy~” ~r~n” + &

            “2~t~”Susan~r~nMary~r~nMarie~” ~r~n” + &

            “3~t~”Chris~r~nBen~r~nMike~” ~r~n” + &

            “4~t~”Mott~r~nBarber~r~nPicard~” “

 

22

 

Ans

 

What is the import file functions and tell other functions related to it?

 

Inserts data into a DataWindow control or DataStore from a file. The data can be tab-delimited text or dBase format 2 or 3.

 

Controls

DataWindow controls, DataStore objects, and child DataWindows

 

Syntax

Dwcontrol.ImportFile ( filename {, startrow {, endrow {, startcolumn {, endcolumn {, dwstartcolumn } } } } } )

Argument Description

 

Dwcontrol    The name of the DataWindow control or DataStore to which you want to copy data from the specified file.

 

Filename       A string whose value is the name of the file from which you want to copy data. The file must be an ASCII, tab-delimited file (TXT) or a dBase format 2 or 3 file (DBF). Specify the file’s full name, which must end in the appropriate extension.If filename is NULL, ImportFile displays the File Open dialog box and allows the user to select a file.

 

startrow (optional)        The number of the first row in the file that you want to copy. If the first row contains headings that you want to skip, set startrow to 2. The default is 1

 

endrow (optional)         The number of the last row in the file that you want to copy. The default is the rest of the rows

 

startcolumn (optional)  The number of the first column in the file that you want to copy. The default is 1

 

endcolumn (optional)   The number of the last column in the file that you want to copy. The default is the rest of the columns

 

dwstartcolumn (optional)  The number of the first column in the DataWindow control or DataStore that you want to receive data. The default is 1

 

ImportFile may trigger an ItemError event.

 

Return value

Long. Returns the number of rows that were imported if it succeeds and one of the following negative integers if an error occurs:

 

 0  End of file; too many rows

-1  No rows

-2  Empty file

-3  Invalid argument

-4  Invalid input

-5  Could not open the file

-6  Could not close the file

-7  Error reading the text

-8  Not a TXT file

-9  The user canceled the import

-10 Unsupported dBase file format (not version 2 or 3)

 

Usage

The file should consist of rows of data. If the file includes column headings or row labels, set the startrow and startcolumn arguments to skip them. The data types and order of the DataWindow object’s columns must match the columns of data in the file.

 

The startcolumn and endcolumn arguments control the number of columns imported from the file and the number of columns in the DataWindow that are affected. The dwstartcolumn argument specifies the first DataWindow column to be affected. The following formula calculates the last DataWindow to be affected.

 

Dwstartcolumn + (endcolumn – startcolumn)

 

To let users select the file to import, specify a NULL string for filename. PowerBuilder displays the Select Import File dialog box. A dropdown listbox lets the user select the type of file to import.

 

Importing files into the ANSI and Unicode versions of PowerBuilder 

 

The type of file that can be imported using the ImportFile function varies depending on the file’s format and the version of PowerBuilder you are running.

 

File type File format that can be imported

 

.TXT     Only Unicode files can be imported into the Unicode version of PowerBuilder. Unicode files cannot be imported into the ANSI version of PowerBuilder

.DBF     Files created using either the ANSI or Unicode version of PowerBuilder can be imported into both versions

 

Other file related functions are file exist, file open, file length, file close, file seek, file write, file delete, getfileopenname, getfilesavename.

 

 

23

 

Ans

 

What are the arguments in sqlpreview event. When does it get triggered?

 

Occurs immediately before a SQL statement is submitted to the DBMS. Functions that trigger DBMS activity are Retrieve, Update, and ReselectRow.

 

Arguments:-

Request SQLPreviewFunction by value (the function that initiated the database activity)Values are:¨

 

            PreviewFunctionReselectRow! — ReselectRow function

            PreviewFunctionRetrieve! — Retrieve function¨   

              PreviewFunctionUpdate! — Update function

 

 

sqltype SQLPreviewType by value (the type of SQL statement being sent to the DBMS)Values are:¨

 

            PreviewDelete! — A DELETE statement¨           

             PreviewInsert! — An INSERT statement¨           

             PreviewSelect! — A SELECT statement¨           

             PreviewUpdate! — An UPDATE statement

 

sqlsyntax         String by value (the full text of the SQL statement)

 

buffer   DWBuffer by value (the buffer containing the row involved in the database activity) Values are:¨            Delete! — The delete buffer (data that has been deleted from the DataWindow)¨  Filter! — The filter buffer (data that has been filtered out)¨   Primary! — The primary buffer (data that has not been deleted or filtered out)

row       Long by value (the number of the row involved in the database activity, that is, the row being updated, selected, inserted, or deleted)

 

Return value

Long. Return code choices (specify in a RETURN statement):

 

0  Continue processing

1  Stop processing

2  Skip this request and execute the next request

 

Usage

 

Obsolete functions  Information formerly provided by GetSQLPreview and GetUpdateStatus is available in the arguments sqlsyntax , row, and buffer.

 

Some uses for the sqlsyntax argument are:

 

¨           Changing the SQL to be executed (you can get the value of sqlsyntax, modify it, and call SetSQLPreview)

 

¨           Keeping a record (you can write the SQL statement to a log file)

 

GetSQLPreview and binding  When binding is enabled for your database, the SQL returned in the GetSQLPreview event may not be complete—the input arguments are not replaced with the actual values. For example, when binding is enabled, GetSQLPreview might return the following SQL statement:

 

INSERT INTO “cust_order” ( “ordnum”, “custnum”,”duedate”, “balance” ) VALUES ( ?, ?, ?, ? )

 

When binding is disabled, it returns:

 

INSERT INTO “cust_order” ( “ordnum”, “balance”,”duedate”, “custnum” ) VALUES ( ‘12345’, 900,’3/1/94′, ‘111’ )

 

If you require the complete SQL statement for logging purposes, you should disable binding in your DBMS.

 

For more information about binding, see Connecting to Your Database.

 

If the row that caused the error is in the Filter buffer, you must unfilter it if you want the user to correct the problem.

Reported row number  The row number stored in row is the number of the row in the buffer, not the number the row had when it was retrieved into the DataWindow object

 

24

Ans

 

How many triggers are there in oracle and what they are?

There are 11 triggers used in oracle and they are –

1.       On insert,update,delete

 

2.       Before insert,update,delete

 

3.       After insert,update,delete

 

4.       On statement and on row.

 

25

 

Ans

What setposition function does?

 

For controls in a window, specifies the position of a control in the front-to-back order within a window. For a window, specifies whether it always displays on top of other open windows.

 

Controls

A control within a window or a window

Syntax

Objectname.SetPosition ( position {, precedingobject } )

 

Argument Description

 

Objectname      The name of a control for which you want to specify a location in the front-to-back order within the window, or the name of a window for which you want to specify whether it will always display on top. Objectname cannot be a child window or a sheet.

 

Position     A SetPosType enumerated data type. The values you can specify depend on whether objectname is a control or a window.

 

For controls, values are:

¨Behind! — Position objectname behind  precedingobject in the order¨   

ToTop! — Position objectname on top of all other controls¨       

ToBottom! — Position objectname behind all other controls

 

For windows, values are:¨          

TopMost! — Always display objectname on top of all other open windows¨        

NoTopMost! — Do not always display objectname on top of all other open windows

 

precedingobject (optional)       The name of the object you want to position objectname behind. Precedingobject is required if position is Behind!

 

Return value

Integer. Returns 1 when it succeeds and -1 if an error occurs. If any argument’s value is NULL, Set Position returns NULL.

 

Usage

The front-to-back order for controls determines which control covers another when they overlap. If a control completely covers another control, the control that is in back becomes inaccessible to the user.

When you specify TopMost! for more than one window, the most recently executed SetPosition function controls which window displays on top.

 

26

 

Ans

What are the painters provided in the Power builder?

 

There are 14 painter in pb. They are –

Application, window, userobject, menu, functions, structure, datawindow, library, project, report, database, table, query, pipeline.

27

 

Ans

If the page size is go down or is less what error does Sybase gives?

 

Low pges size error will come.

 

28

 

Ans

Why the user events are not given on menu?

 

Events of menu are mapped with windows menu event, which we can not modify through the power builder.

 

29

 

Ans

 

How the package function in oracle calls in pb?

 

Through RPC call.

30

 

Ans

What is the object coupling?

 

This is nothing but delegation, which includes aggregation & association.

31

 

Ans

What functions we generally used in closequery event and what does it triggers?

 

Closequery occurs before the close event, so we can give an overriding message whether the user wants to save before closing.

32

 

Ans

What is the lookupdisplay function?

 

 Obtains the display value in the code table associated with the data value in the specified column.

 

Syntax

LookUpDisplay ( column )

 

Argument Description

column            The column for which you want the code table display value

 

Return value

String. Returns the display value when it succeeds and the empty string (“”) if an error occurs.

 

Usage

If a column has a code table, a buffer stores a value from the data column of the code table, but the user sees a value from the display column. Use LookUpDisplay to get the value the user sees.

Code tables and data values and graphs When a column that is displayed in a graph has a code table, the graph displays the data values of the code table by default. To display the display values, call this function when you define the graph data.

 

33

 

Ans

What the pb.ini does?

 

When you run power builder it goes through the pb.ini which contains information about the various painters, database profiles and many things and set the properties accordingly . If you make any changes like created new profile the entry for that will be done in pb.ini.

 

34

 

Ans

What for the open event of application object is used.

 

This event is getting called when the application starts so we can use this event to open first frame window as well as making connection with the database or whatever operations you want to do when the application starts.

35

 

Ans

How many events are there in application object and what they are?

 

There are six event for the application object. They are –

Open, Close, System Error, Idle, Connection Begin, and Connection End.

 

36

 

Ans

From which pb object error and message object are inherited?

 

PowerObject is the base object for all powerbuilder objects.

 

37

 

Ans

What are the global variables and objects in pb?

 

Error, Message, SQLCA, SQLSA, SQLDA.

 

38

 

Ans

What all are the graph styles?

 

Area, Bar, Column, Line, Pie, Scatter, 3D area, 3D Bar,  3D Column, 3D Line,  3D Pie, Stacked Bar, Stacked Column, Solid Bar, Solid Column, Solid Stacked Column, Solid Stacked Bar.

 

39

 

Ans

What all datawindow styles are provided with pb?

 

Composite, Freeform, N-Up, Tabular, Grid, Group, Label, CrossTab, Graph, OLE, RichText.

 

40

 

Ans

Difference between datawindow and datastores?

 

A datawindow is a visual object whereas a datastore is a non-visual object.  A datawindow cannot be explicitly destroyed while a datastore can be destroyed. A datastore is basically used for background processing in place of cursors.

 

41

 

Ans

What are the difference between datasource and datastores?

 

A datasource is the method used to populate data into a datawindow. While a datastore is a non visual datawindow.

 

42

 

Ans

How can you get column level and row level item status?

 

The second parameter to the getItemStatus function decides which status is being asked for. If the second parameter is 0 then a row status is returned whereas if a no .(1,2,3 ..) is given then the status for that column is returned.

 

Syntax

dwcontrol.GetItemStatus ( row, column, dwbuffer )

 

Argument Description

 

dwcontrol         The name of the DataWindow control, DataStore, or child DataWindow in which you want to obtain the status of a row or a column in a row

 

row      A long identifying the row for which you want the status

 

column            The column for which you want the status. Column can be a column number (integer) or a column name (string). Specify 0 to get the status of the whole row.

 

Dwbuffer          A value of the dwBuffer enumerated data type identifying the DataWindow buffer that contains the row:

¨Primary! — The data in the primary buffer (data that has not been deleted or filtered out)

¨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)

 

Return value

A value of the dwItemStatus enumerated data type. Returns the status of the item at row, column of dwcontrol in dwbuffer. If column is 0, GetItemStatus returns the status of row. If any argument’s value is NULL, GetItemStatus returns NULL.

 

Usage

The values of the dwItemStatus enumerated data type are:

 

¨NotModified! — The information in the row or column is unchanged from what was retrieved.

 

¨DataModified! — The information in the column or one of the columns in the row has changed since it was retrieved.

 

¨New! — The row is new but no values have been specified for its columns. (Applies to rows only, not to individual columns.)

 

¨NewModified! — The row is new, and values have been assigned to its columns. In addition to changes caused by user entry or the SetItem function, a new row gets the status NewModified! when one of its columns has a default value. (Applies to rows only, not to individual columns.)

 

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

 

For rows 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 whose status was New! or NewModified! Before being moved to the delete buffer.

 

43

 

Ans

What are the item status provided with pb?

 

There are four ItemStatus. – NotModified!, DataModified!, New!, NewModified!.

 

44

 

Ans

 

 

 

What item status generate update statements?

 

NewModified & DataModified.

45

 

Ans

How can you trap errors in pb?

 

In the SystemError event, DB Error Event, ItemError Event.

 

46

 

Ans

What is the difference between post event and triggerevent?

 

Post event is placed at the end of the windows message object queue where as a triggerevent is executed immediately.

TriggerEvent and PostEvent are useful for preventing duplication of code. If two controls perform the same task, you can use PostEvent in one control’s event script to execute the other’s script, instead of repeating the code in two places. For example, if both a button and a menu delete data, the button’s Clicked script can perform the deletion and the menu’s Clicked event script can post an event that runs the button’s Clicked event script.

 

47

 

Ans

What are the difference between event and functions?

 

A event can be extended but not overrided & overloaded whereas a function can be. 

If a event is called dynamically then even if the event is not there at runtime it only returns a –1 while in similar case a function will fire an error.

 

48

 

Ans

 

What are the scope of variables and in which sequence pb search for the variables?

 

There are four scopes local, shared, global and instance and pb search variables  in the same order

49

 

Ans

What is the sequence for searching the files in pb applications?

 

While running application from which directory application is running it will search in that folder and then it follows windows sequence.

 

50

 

Ans

 

What all functions you can not call in itemchange event and why?

 

If you call any of the following function in item change event it will go in indefinite loop because these functions call the item change event again. These events are –

Accept text all scroll functions, set row, set column

51

 

Ans

What are the return values of item change event?

 

There are three return values in this 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.

Event ID

Event ID           Objects

pbm_dwnitemchange     DataWindow control or DataStore

Arguments

Argument Description

row      Long by value (the number of the row containing the item whose value has been changed)

dwo      DWObject by value (a reference to the column containing the item whose value has been changed.   

              Dwo is a reference to the column object, not the name of the column)

data      String by value (the new data the user has specified for the item)

 

Return value

Long. Return code choices (specify in a RETURN statement):

0  (Default) Accept the data value

1  Reject the data value and don’t allow focus to change

2  Reject the data value but allow the focus to change

 

Usage

 

The ItemChanged event does not occur when the DataWindow control itself loses focus. If the user clicks on an Update or Close button, you will need to write a script that calls AcceptText to see if a changed value should be accepted before the button’s action occurs.

Obsolete techniques Information formerly provided by the GetText function is available in the data argument.

Instead of calling SetActionCode, use a RETURN statement with a return code.

 

52

 

Ans

If you want to call update function in itemchange event what cares you need to take?

 

When you call the update function in item change event we need to accept the value of lastly modified column.but we can not call the accept text function in the item change event so we need to set the value to that column using set text function.

 

53

 

Ans

How can you get values from original buffer?

 

Gets data whose type is String from the specified buffer of a DataWindow control or DataStore object. You can obtain the data that was originally retrieved and stored in the database from the original buffer, as well as the current value in the primary, delete, or filter buffers.

 

Controls

 

DataWindow controls, DataStore objects, and child DataWindows

 

Syntax

dwcontrol.GetItemString ( row, column {, dwbuffer, originalvalue } )

 

Argument Description

 

Dwcontrol The name of the DataWindow control, DataStore, or child DataWindow in which you want to obtain the string data contained in a specific row and column

 

Row:    A long identifying the row location of the data

 

Column: The column location of the data. The data type of the column must String. Column can be a column number (integer) or a column name (string). To get the contents of a computed field, specify the name of the computed field for column. Computed fields do not have numbers

 

Dwbuffer: (optional)  A value of the dwBuffer enumerated data type identifying the DataWindow buffer from which you want to get the data: 

Primary! — (Default) The data in the primary buffer (data that has not been deleted or filtered out)¨

Delete! — The data in the delete buffer (data deleted from the DataWindow)¨      

Filter! — The data in the filter buffer (data that was filtered out)

 

originalvalue (optional) A Boolean indicating whether you want the original or current values for row and column:

¨True — Return the original values (the values initially retrieved from the database)

¨False — (Default) Return the current valuesIf you specify dwbuffer, you must also specify originalvalue

 

Return value

String. Returns NULL if the column value is NULL. Returns the empty string (“”) if an error occurs. If any argument’s value is NULL, GetItemString returns NULL.

 

Usage

Use GetItemString to get information from the DataWindow’s buffers. To find out what the user entered in the current column before that data is accepted, use GetText. In the ItemChanged or ItemError events, use the data argument.

To access a row in the original buffer, specify the buffer that the row currently occupies (primary, delete, or filter) and the number of the row in that buffer. When you specify TRUE for originalvalue, the function gets the original data for that row from the original buffer.

 

Mismatched data types  An execution error occurs when the data type of the DataWindow column does not match the data type of the function, in this case String.

 

54

 

Ans

What all buffers are present in pb?

 

Basically there are three buffers provided with the pb DataWindows. They are given below –

Primaries buffer, delete buffer, filter buffer. There is one more buffer called as original buffer that is when we retrieve the datawindow data will be in original buffer.

 

55

 

Ans

What are the disadvantages of the triggers?

 

First major disadvantage is that user will not have any control over process as the trigger fire automatically on

certain operations. Also user can not come to know that some thing has happen on his operation as trigger fire in the background automatically.

 

56

 

Ans

What all are the ddl (data definition language) statements?

 

All create statement are the ddl. As well as all grant and revoke statements are ddl.

 

57

 

Ans

Can you write commit in triggers and why?

 

No we can not write commit in trigger because in triggers fire automatically on certain operation. And if two users are using the same application and doing same operation on the operation of one user commit will fire and some invalid data may get save.

 

58

 

Ans

Can you write create statement in procedure?

 

Yes

59

 

Ans

How can you call procedure in pb?

 

There is a three ways from which you can call procedure in PB.

First is through the embedded sql , second is through the procedure datasource for making datawindow objects and last is using RPC call through the transaction object.

 

60

 

Ans

How can you make datawindow from procedure?

 

You can do so by using procedure type datasource for creating new datawindow object.

 

Get From The Internet

Good Luck!

PassWords

About The Author

Leave A Comment?