You are on page 1of 52

How PowerBuilder looks for variables?

When PowerBuilder executes a script and fnds an unqualifed reference to a variable, it searches for the
variable in the following order:
! local variable
" ! shared variable
# ! global variable
$ !n instance variable
!s soon as PowerBuilder fnds a variable with the specifed na%e, it uses the variable&s value'
' What events do (ou know for the application ob)ect?
*P+, - the user starts application'
./0+ - no %ouse or ke(board activit( happens in a specifed nu%ber of seconds
1(ste%+rror - ! serious error occurred during execution
20*1+ - the user closes the application
2onnectionBegin --in a distributed co%puting environ%ent, occurs on the server when a client establishes a
connection to the server b( calling the 2onnect3o1erver function'
2*,,+23.*,+,/ -- .n a distributed co%puting environ%ent, occurs on the server when a client disconnects
fro% the server b( calling the /isconnect1erver function'
"' How can (ou run another application fro% within PowerBuilder?
We could do it using PB function 4un5 6' 4un 5string 7, Window1tate86, where string is a string whose value is the
flena%e of the progra% we want to execute' *ptionall(, the string can contain one or %ore para%eters of the
progra%9 Window1tate 5optional6 is a value of the Window1tate enu%erated data t(pe indicating the state in
which we want to run the progra%' +'g', 4un5:c:;winword'exeleter'doc<, =axi%i>ed?6
#' How do (ou know that the application is alread( running?
5How do (ou avoid =essageBox :!pplication is alread( running<?6
@se Handle5 6 function' Handle5 6 returns the ob)ectAs na%e if the ob)ect exists'
$' What are the two structures ever( application has?
+ver( PowerBuilder application has the =essage*b)ect and the +rror*b)ect' +rror*b)ect is used to report errors
during execution' =essage*b)ect--to process %essages that are not PowerBuilder-defned events, and pass
para%eters between windows'
B' What are the wa(s to close (our application?
H!0356, H!03 20*1+56, 20*1+56
C'What is H!03? H!03 20*1+? What is the diDerence between the%?
3he H!03 state%ent forces the application to ter%inate i%%ediatel(' 3his is %ost often used to shut down the
application after a serious error occurred'
H!03 20*1+ Halt 2lose does the sa%e thing but triggers the application ob)ectAs 2lose event before ter%inating'
E' What do (ou do to fnd out how fast (our select is being executed on a client site?
Put 34!2+ option in the '.,. fle 5 1F0G*P3G34!2+H2onnect *ption /BPar% para%eter6 Purpose - 3urns onIoD
the */B2 /river =anager 3race in PB to troubleshoot a connection to an */B2 data source' .t provides detailed
infor%ation about the */B2 !P. function calls %ade b( PB when connected to an */B2 data source' Jalues -
3he values (ou can specif( are:
1F0G*P3G34!2+G*KK 5/efault6 - 3urns oD the */B2 /river =anager 3race' 1F0G*P3G34!2+G*, - 3urns on the
*/B2 /river =anager 3race'
L' What are the wa(s to test correctness of (our 1F0? 1F0 3i%e?
Put 34!2+ option in the '.,. fle'
M' What is the purpose of the PB'.,. fles?
.,. stands for :initiali>ation<' 3he( are pri%aril( intended to be a standard for%at that applications can %ake
use of to hold info fro% one run to the next' 4ather than hard-coding the values of transaction properties in
scripts, which is too inNexible for %ost real-world applications, (ouAll want (our scripts to read so%e or all of
the% fro% an '.,. fle' Oou could use PB'.,.
'.,.s are alwa(s in the sa%e for%at:
P/atabaseQ
/B=1 R 1(base
/atabase R Jideo 1tore /B
@ser .d R
/B Password R
0og Password R
1erver ,a%e R
0og .dR
0ock R
/BPar%R2onnect1tringRA/1,RJideo1tore /B9@./RdbaA
S' How do (ou %anipulate '.,. fle through PowerBuilder functions?
1et Profle 1tring5 6
Profle1tring5 6
Profle .nt5 6
' How do (ou set calculator in PB application?
4un 5:c:; calculator< 6
What is 1F0?
1F0 is ! 1tructure Fuer( 0anguage'
' .s a standard wa( of specif(ing data sets'
"' .s a wa( to retrieve and %anipulate data in /ataBase'
#' .s used for all /ataBase functions'
$' 2an be used in the for% of :e%bedded 1F0< fro% an application progra%'
1
' Which attributes of a 3ransaction ob)ect in PowerBuilder are required to be set for a 1(baseI1F01erver
connection?
/B=1
/atabase
@ser./
/BPass
0ock
0og./
0ogPass
1erver,a%e
!uto2o%%it
/BPar%
"' What is a te%porar( table?
! te%porar( table exists onl( during the current work session'
"a' How do we create te%porar( tables in 1(base?
We use the pound sign5 T 6 before the na%e of the table in the 2reate 3able co%%and, the new table will be
te%porar(' 3he new table will be created in the 3e%porar( /B, no %atter what /B (ou use when (ou create it' .t
exists onl( during the current work session' .f (ou do not use the pound sign before the table, the table is
created as a per%anent'
2reate table Tte%ppubs
5pubGid pid,
pubGna%e varchar5#S6 null6
select titleGid, totalGorders R su%5qt(6
into Tqt(Gtable
fro% salesdetail
group b( titleGid
#'What is usage of the te%porar( tables?
3e%porar( tables are used to hold a set of inter%ediate results and hold results of queries that are too co%plex
for a single quer('
M' What is a /ataBase referential integrit(?
4eferential integrit( ensures that data between Pri%ar( U Koreign ke(s is kept consistent'
#' What is an .ndex?
.ndex is a pointer which is used to i%prove perfor%ance'
*4
.ndex is a separate storage structure created for a table to allow direct access to specifc data row5s6' 50ogical
pointer to allow faster retrieval of ph(sical data6
"' What is the diDerence between indexes and ke(s?
Ve(s are not the sa%e as indexes' Ve(s are defned at logical design ti%e while indexes are defned at ph(sical
design ti%e for perfor%ance and other reasons'
""' What is a 3ransaction?
3ransaction is a logical unit of work' We %a( sa( it is a set of 1F0 state%ents'
#S' 2an (ou call 1tored Procedures fro% 3riggers?
Oes'
#' 2an (ou create te%porar( tables in 3riggers?
,o, we cannot'
#$' What is /ata /ictionar(? How is it used?
/ata /ictionar( is stored in each database' 3he info regarding the database5s6 structure and co%ponents is
contained in the data dictionar( for the database' 3he data dictionar(, also called the :s(ste% catalog<, is
stored as data in the :s(ste% tables< in each database'
#B' What is the na%e of the /ataBase in which s(ste%-related infor%ation is stored?
=aster /atabase which has s(ste% catalog, s(ste% procedure ' '
#L' How do (ou displa( infor%ation about the /ataBase?
spGhelpdb
#M' How can (ou switch to another database?
2onnect using dbGna%e
$' What is a /efault? How do (ou use it?
! /efault is a value that is applied on an insert if no value is supplied'
/efaults specif( the data to be entered into a colu%n if user does not specif( it on input'
*r
/efault is the data to be entered in a colu%n if none is provided b( user'
$M' What is a 2ursor?
! 2ursor is a s(%bolic na%e that is associated with a 3ransact-1F0 state%ent' ! 2ursor provides the abilit( to
step through the result set row b( row' 3he application progra% can perfor% processing on each row'
BS' What is the purpose of 2@41*4? How and when can (ou declare a 2@41*4?
3he purpose of 2ursor is to allow a progra% to take action on each row of a quer( result set rather than on the
entire set of rows returned b( select state%ent' ! 2ursor %ust be declared before it is used' 3he s(ntax to
declare a 2ursor can be included in a stored procedure or an application' Provides the abilit( to delete or update
a row in a table based on the cursor position' !cts as a bridge between the set orientation of an 4/B=1 and
row-oriented progra%%ing'
B#' How do we )oin two or %ore tables?
We use 1elect state%ent with Where clause, where we specif( the condition of )oin'
BE' How do (ou get a 2ount of non null values in a colu%n?
2ount 5colu%nGna%e6 returns nu%ber of non null values in the colu%n'
BE' What are the aggregate functions? ,a%e so%e'
2
!ggregate functions are functions that work on groups of infor%ation and return su%%ar( value'
2ount5W6 nu%ber of selected rows9
count5na%eGcolu%n6 nu%ber of non-null values in a colu%n9
%ax5 6 highest value in a colu%n9
su%5 6 total of values in a colu%n9
%in5 6 lowest value in a colu%n
avg5 6 average of values in a colu%n'
!ggregates ignore ,ull value 5except count5W66'
1u%56 and avg56 work with nu%eric values'
*nl( one row is returned 5if a X4*@P BO is not used6'
!ggregates %a( not be used in WH+4+ clause unless it is contained in subquer(:
5select titleGid, price
fro% titles
where price Y5select avg5price6 fro% titles6'
BM' What is a 4ow?
! 4ow contains data relating to one instance of the tableAs sub)ect' !ll rows of a table have the sa%e set of
colu%ns'
CS' What is a 2olu%n?
! 2olu%n contains data of a single data t(pe 5integer, character, string6, contains data about one aspect of the
tableAs sub)ect'
C$' What are restrictions on a 1ubquer(?
1ubqueries cannot be used with :
' Ve(word .,3*:
"' With *4/+4 BO
#' With co%puted clauses'
3he /.13.,23 ke(word cannot be used with 1ubqueries that include a X4*@P BO clause'
CL' How do (ou eli%inate /uplicates?
/.13.,23 eli%inates duplicate in the output'
LS' How can (ou convert data fro% one data t(pe to another using 3ransact-1F0 in 1(base?
3here is a function 2onvert5 6 in 3ransact 1F0 which is used for data conversion'
Kor exa%ple, to convert /ata3i%e colu%n into string (ou could write so%ething like
1+0+23 2*,J+435char5L6,birthdate,6
in this case third para%eter specifes for%at of returned string5:%%IddI((<6
L#' How can (ou handle ,ulls values in /ataBase?
We have to %ake sure that colu%ns that are part of the pri%ar( ke(5 or )ust an i%portant colu%n6 are not nulls
in table defnition'
.f .s,ull 5colu%n6
if not .s,ull5colu%n6
L$' How can (ou generate unique nu%bers in /ataBase?
/ataBase has special s(ste% colu%n that keeps all used unique nu%bers' 1pecial s(ste% function reads last
used nu%ber and return next to use'
LB' WhatAs the %ini%al data ite% that can be locked in a /ataBase?
/ata page'
LC' How %an( t(pes of /(na%ic 1F0 do (ou know in PowerBuilder?
3here are $ t(pes of /(na%ic 1F0 in PowerBuilder:
Kor%at ,on-result set state%ents with no input para%eters
Kor%at " ,on-result set state%ent with input para%eters
Kor%at # 4esult set state%ents in which the input para%eters and result-set colu%ns are known at
co%pile ti%e
Kor%at $ 4esult set state%ents in which the input para%eters, the result-set colu%ns, or both, are
unknown at co%pile ti%e
LE' When and wh( do we need /(na%ic 1F0?
3o perfor% so%e execution of the 1F0 state%ents at runti%e'
2*==*, 3+2H,.2!0 F@+13.*,1
' /eleting a row that is a foreign ke( in another table violates what kind of /B rule? 4eferential integrit(
"' Wh( would (ou code a co%%it?
3o co%plete a unit of work
#' What is a /atabase transaction?
0ogical unit of work
$' What is the language for creating and %anipulating /atabase?
/=0
//0
/00
B' @ser defned function for a window can onl( be called if the window is active?
C' .n the script painter for an inherited window, (ou can either +xtended or ------------ the ancestor script?
E' What is the %ethod to validate a nu%eric colu%n in a /W?
L' When a *4/+4G,@= is selected b( user, how do (ou highlight the details of the specifc *4/+4?
M' What does the :pass b( value< in the function defnition %ean?
S' 3he database-specifc error codes for connectIupdateIretrieve are stored in what attribute of the transaction
ob)ect?
' Wh( would (ou use 3H.1 or ParentWindow? 5pick all correct answers6
3
-pol(%orphis%
-inheritance
-instance
"' Which are valid for a %enu?
-ParentWindow'3itle R :3itle<
-2lose5ParentWindow6
-ParentWindow'stGtitle R :title<
#' What do a Pop-up and 4esponse windows have in co%%on?
-the( both open on top
$' What t(pe of a window is %odal?
-response
B' What is a class?
-defnition of an ob)ect
-instance of an ob)ect
/ata Pipeline
What is the /ata Pipeline?
3he /ata Pipeline lets us cop( tables and their data fro% one /atabase to another even if the /atabases are on
diDerent /B=1' We can also use the /ata Pipeline to cop( data within the sa%e database 5several tables into a
single table6'
What is the data sources for a data pipeline?
Fuick 1elect
1F0 1elect
Fuer(
1tored Procedure
#' What can (ou do with the /ata Pipeline ?
We can use the /ata Pipeline to:
2reate 5add6 a table in the destination 5target6 database
4eplace 5dropIadd6 an existing table in the destination database
4efresh 5deleteIinsert6 rows in the destination database
.nsert rows in the destination database
@pdate rows in the destination database
$' What happens if an error occurs when piping data ?
When errors occurs in a /ata Pipeline, an +rror =essage window appears' .t shows:
the na%e of the table in the destination database where the error occurred
the option that was selected in the /ata Pipeline dialog box
each error %essage
the values in the row in which each error occurred'
B' How do (ou create a Pipeline as a part of an application?
.ncluding data pipeline in an application involves Window Painter, /ata Pipeline Painter, @ser *b)ect Painter and
scripts' ! nu%ber of ob)ects are involved in setting up a pipeline in an application:
two transaction ob)ects
pipeline ob)ect
standard class pipeline user ob)ect
/ataWindow control 5to displa( row errors6'
C' .n what event can (ou access the current nu%ber of row errors ?
.n Pipe=eter event using 4ows.n+rror attribute'
! pipeline has the following events:
Pipe1tart, when a Pipeline or Pipe 4epair operation starts
Pipe=eter, when a block of rows has been read or written
Pipe+nd, when a Pipeline or Pipe 4epair operation ends
!ttributes:
4ows4ead
4owsWritten
4ows.n+rror
' What is a /ata1tore?
! /ata1tore is a nonvisual /ataWindow control'
! /ata1tore acts )ust like a /ataWindow control except that %an( of the visual properties associated with
/ataWindow controls do not appl( to a /ata1tore' However, because (ou can print a /ata1tore, PowerBuilder
provides so%e events and functions for a /ata1tore that pertain to the visual presentation of the data'
"' When do (ou use a /ata1tore?
.f . have so%e data which need to be displa(ed in %ore than one window of %( application, . would use a
/ata1tore instead of the 4etrieve5 6 function'
/!3!B!1+ P!.,3+4
' What is the 4elational /ataBase %odel?
/ata in a relational /B is stored in tables9 tables are co%posed of rows and colu%ns9 each row describes
occurrence of entit(9 each colu%n describes characteristic of an entit('
"' What is the /ataBase?
/ataBase is a bod( of data in which there are relationships a%ong the data ele%ents'
#' What is /ataBase =anage%ent 1(ste%?
/B=1 is 1oftware that facilitates the function of /ataBase structures and the storage and retrieval of data fro%
those structures'
B' What is a 3able?
4
! 3able is 4elational =odel' .n a relational /ataBase, all data is in tables' ! table holds data relating to particular
class of ob)ects 5an entit(6'
E'What is the diDerence between an edit st(le and a displa( for%at?
/o these attributes depend on the /atabase being used?
K*4=!3 is used to displa( data in the colu%n'
+/.3 is used to enter data in the colu%n
,o' 3he( do not depend on /atabase being used'
"' What are validation rules? What are the( useful for?
Jalidation rules are expressions that PowerBuilder uses to validate user-entered data' Jalidation rules are
auto%aticall( checked b( the /ataWindow ob)ect when data are entered in the colu%n' /B=1 has no
knowledge of it'
#' What is the diDerence between an edit st(le and a displa( for%at?
+dit st(le is for%at of a colu%n during user input'
/ispla( for%at is for%at of the data when it is displa(ed'
L' How do (ou obtain infor%ation about a specifc /atabase?
@sing 1(ste% 1tored procedure 1PGHelpdb
M' How can we %odif( the existing tables?
We can add one or %ore colu%ns 5alwa(s allow ,@006 but we cannot re%ove colu%ns fro% the table' 3he table
%ust be
#' /o we have to execute the 3rigger?
,o, if the triggers are defned for a specifc table for a specifc process 5insert, delete, update6 and if we have a
trigger for, sa(, the delete process for a specifc table /+0+3+ trigger will be executed auto%aticall('
$' .f there is a proble% with the /!3!B!1+ during data retrieval, which /W event will be triggered? Where will
the error code be stored?
/B +rror +vent
/B +rror 2ode
2onnecting to a /atabase
B' What is a transaction?
! transaction is a sequence of one or %ore 1F0 state%ents that together for% a logical unit of work' !
transaction is a sequence of operations or events in the /B' 3he beginning of a 3ransaction is the frst 1F0
state%ent in the logical unit of work9 the end of the 3ransaction is %arked b( a 2o%%it or 4ollback or their
equivalents' 3he 1F0 state%ents we use to %ake and break /atabase connections and %anage database
transactions are:
2onnectHestablishes the connection to the database
2o%%itHapplies all changes %ade to the /atabase since the last point of /atabase integrit( 2o%%it executes
all changes to the database since the start of transaction 5or since the last 2o%%it or 4ollback6 beco%e
per%anent'
4ollbackHrolls out all changes %ade to the /B since the last point of /B integrit(
/isconnectHbreaks the connection to the /atabase'
4ollback executes all changes since the start of the current transaction are undone'
C' What transactions do (ou know?
2o%%it, 4ollback, 2onnect, /isconnect
E' Wh( is the concept of transaction i%portant?
We need to %anage /atabase connections and transactions through the use of e%bedded 1F0 state%ents
2onnect, 2o%%it, 4ollback, and /isconnect, especiall( for transactions involving updates to the /atabase'
L' What is a PB 3ransaction ob)ect?
PB transaction ob)ect is a co%%unication area between P2 and the database' Kor each database that we use in
our pro)ect there has to be a separate transaction ob)ect'
3he 3ransaction ob)ect specifes the para%eters that PB uses to connect to a /B'6
M' What is a 3ransaction *b)ect?
! 3ransaction ob)ect is a global nonvisual PowerBuider ob)ect used to store connection infor%ation for a
particular server and provide error checking' .t is a structure used to specif( /B info and provide error checking'
5.nfo in the ob)ect is used for the initial connection, and the %essages fro% the server are returned to the
application through the ob)ect' 3his ob)ect is funda%ental to %aintaining connections to %ultiple data sources'
"S' What do (ou have to do to connect to the database in (our pro)ect?
We have to assign values to the attributes of our transaction ob)ect such as /B=1, 1erver na%e' ' ' We usuall(
keep these values in the application '.,. fle, and in the *pen event for our !pplication ob)ect we use
Profle1tring56 function to get these values and assign the% to the attributes of the transaction ob)ect'
"' What is a logical unit of work?
.t is a transaction'
""' What state%ent inside PB deals with a transaction?
2onnect starts the transaction 5establishes connection to /B6
/isconnect ter%inates a transaction'
2o%%it executes all changes to the /B since the start of transaction 5or since the last 2o%%it or 4ollback6
beco%e per%anent'
4ollback cancels all database operations in the specifed database since the last 2*==.3, 4*00B!2V, or
2*,,+23
"#' What is 1F02!?
.t is a default transaction ob)ect that PB provides for us to co%%unicate with one /atabase' We donAt have to
create this transaction ob)ect and destro( it'
5
"$' What is 1F02ode?
1F02ode is an attribute of the transaction ob)ect that we check after an( 1F0 state%ent to fnd out if the
transaction was successful or failed'
"B' 3o use %ultiple databases in (our application, what do (ou do?
We use the default 3ransaction ob)ect for one and for the others we have to create the
3ransaction ob)ect with 24+!3+ transaction state%ent and at the end /.12*,,+23 to destro( this transaction
with /+134*O state%ent'
"C' How do we handle errors in the script?
We test the success or failure of an( 1F0 state%ent, checking 1F02ode attribute' .f it fails 5-6, we give the
%essage using =essageBox56 and displa( 1F0+rror3ext attribute'
"E' What is the purpose of a transaction ob)ect ?
3he purpose of a transaction ob)ect is to identif( a specifc /atabase connection within a PowerBuilder
application'
"L' How can (ou do 3ransaction =anage%ent in PowerBuilder?
We can do it using the !uto2o%%it attribute of the 3ransaction ob)ect' .f the value of !uto2o%%it is 34@+,
PowerBuilder )ust passes our 1F0 state%ents directl( to server and each state%ent is then auto%aticall(
co%%itted to the /atabase as soon as it is executed' .f we set the value of !uto2o%%it to K!01+ 5default
value6, PowerBuilder requires that we use the 2o%%it and 4ollBack ke( words to co%%it and rollback our
transaction when we are fnished with it' .n this case PowerBuilder begins the new transaction auto%aticall( as
soon as we 2onnect, 2o%%it or 4ollBack, /isconnect'
"M' How can (ou provide 3ransaction =anage%ent in PowerBuilder?
B( using state%ents 2*,,+239 /.12*,,+239 2*==.39 4*00B!2V' We can i%prove perfor%ance b( li%iting
the nu%ber of 2onnects and /isconnects'
#S' 3he attributes of a transaction ob)ect can be divided into two groups'
/escribe the purpose of those two groups'
1o%e attributes are used to %ake the connection to the database' 3he( are:
/B=1
/atabase
@ser./
/BPass
0ock
0og./
0ogPass
1erver,a%e
!uto2o%%it
/BPar%
1o%e attributes return status info to the application, returned b( /B=1' 3he( are :
1F0/B2ode
1F0+rr3ext
1F04eturn/ata
1F02ode
1F0,4ows
##' What %ust (ou code at the end of ever( e%bedded 1F0 state%ent?
!ll e%bedded 1F0 state%ents %ust end with a se%icolon 596'
#$' What is e%bedded 1F0 ?
+%bedded 1F0 refers to the use of 1F0 state%ents in our Power1cript code' !ll e%bedded 1F0 state%ents
begin with an 1F0 verb and end with a se%icolon 596'
When we need a reference to PowerBuilder variables in e%bedded 1F0 state%ents, we put a colon 5:6 before the
PB variable'
#B' What s(ntax do we use to connect with our own transaction ob)ect?
.f we are using a 3ransaction ob)ect we have defned, we %ust use the full state%ent:
2*,,+23 using transGna%e9
#C' How can (ou defne an additional 3ransaction ob)ect? When %ight (ou need it?
3o create an additional transaction ob)ect, we frst declare a variable of t(pe transaction, then we create the
ob)ect and then defne the attributes that will be used' /eclare a variable of a transaction ob)ect t(pe and then
specif( para%eters to connect to the database'
/efne 5declare6 -- 3ransaction 3oG1(base
.nstantiate a 3ransaction ob)ect9 3oG1(base R 2reate transaction
!ssign values to the attributes of the 3ransaction ob)ect
3oG1(base'/B=1 R :1(base<
3oG1(base'/ataBase R :Personnel<
3oG1(base'0og.d R ://"B<
/o 2*,,+239
connect using 3oG1(base9
2heck the success or failure of the /atabase connection'
.f 1F02!'1F02ode identifer'
6
/BPar% 51tring6H/B=1-specifc para%eters'
/BPass 51tring6H3he password that will be used to connect to the database'
0ock 51tring6H3he isolation level'
0og./ 51tring6H3he na%e or ./ of the user who will log on to the server'
@ser./ 51tring6H3he na%e or ./ of the user who will connect to the database'
0ogPass 51tring6H3he password that will be used to log on to the server'
1erver ,a%e 51tring6H3he na%e of the server on which the database resides'
1F02ode 50ong6H3he success or failure code of the %ost recent operation'
4eturn codes: SH1uccess9 SSH,ot Kound9 -H+rror 5use 1F0/B2ode or 1F0+rr3ext to obtain the
details6
1F0/B2ode 50ong6H3he database vendor&s error code'
1F0+rr3ext 51tring6H3he database vendor&s error %essage'
1F0,4ows 50ong6H3he nu%ber of rows aDected 5the /B vendor supplies this nu%ber, so the %eaning %a( not
be the sa%e in ever( /B=16'
1F04eturn/ata 51tring6H/B=1-specifc infor%ation'
!uto2o%%it 5Boolean6H3he auto%atic co%%it indicator 51F0 1erver onl(6'
Jalues are: 3rue H 2o%%it auto%aticall( after ever( database activit(
Kalse H /o not co%%it auto%aticall( after ever( database activit('
#L' 3he end user cannot connect to the /atabase wIo a PB'.,.?
true
.n 2lientI1erver the /atabase engine %ust be on a dedicated server
false
7
/!3!W.,/*W *BZ+23
"' /ataWindow ob)ects %ost often obtain their data fro% relational /atabases'
,a%e three other sources of their data'
@ser .nput
'3[3 or '/BK fles
//+ with another Windows application
#' Which /ata 1ource in the /ataWindow painter is itself an ob)ect?
Fuer(
$' What /ata 1ources do (ou know and how do (ou use the%?
3he /ata 1ource deter%ines how we select the data that will be used in the /W ob)ect'
.f the data for the /ataWindow ob)ect is retrieved fro% a database, we %a( choose one of the following /ata
1ources:
Fuick 1elect is a select fro% one or %ultiple tables that are )oined through foreign ke(s and %a( include si%ple
selection criteria which appear on the WH+4+ clause' We can onl( choose colu%ns, selection criteria, and
sorting' We cannot specif( grouping before rows retrieved, include co%puted colu%ns, or specif( retrieval
argu%ents'
1F0 1elect is an 1F0 1elect state%ent fro% one or %ore tables in a relational database
and %a( include selection criteria that appear on an( of the possible 1elect state%ent clauses 5can include
selection criteria 5WH+4+ clause6, sorting criteria 5*4/+4 BO clause6, grouping criteria 5X4*@P BO and H!J.,X
clauses6, co%puted colu%ns, one or %ore argu%ents to be supplied during execution'
Fuer( is a predefned 1F0 1elect state%ent, which %ust be previousl( constructed and saved as a Fuer(
ob)ect'
1tored Procedure indicates that the /ataWindow will execute a 1tored Procedure and displa( the data in the frst
result set' 3his /ata 1ource onl( appears if the /B=1 to which PowerBuilder is connected and which supports
1tored Procedures' We can specif( that the data for a /ataWindow ob)ect is retrieved through a stored
procedure if our /B=1 supports 1tored Procedures'
+xternal is used when the data is not in the database and the /ataWindow ob)ect will be populated fro% a script
or data will be i%ported fro% a //+ application' .f the data is not in the /B, we select +xternal as the /ata
1ource' 3his includes the following situations:
.f the /ataWindow ob)ect is populated fro% a script
.f data is i%ported fro% a //+ application
.f data is i%ported fro% an external fle, such as a tab-separated text fle 5'3[3 fle6 or a dB!1+ fle 5'/BK fle6'
+xternal indicates that we have coded a script that supplies the /ataWindow ob)ect with
its data' We use this /ata 1ource when the data is in a '3[3 or '/BK fle or obtained through //+' We %a( also
use it when we plan to obtain the data b( e%bedding our own 1F0 1elect state%ent in a script' With this /ata
1ource the /ataWindow ob)ect does not issue its own 1F0 state%ent' We specif( the data colu%ns and their
t(pes so that PB can build an appropriate /ataWindow ob)ect to hold the data' 3hese colu%ns %ake up the
result set' .n a script, we will need to tell PowerBuilder how to get data into the /ataWindow in our application'
3(picall(, we will i%port data during execution using a Power1cript .%port function 5such as .%portKile56 and
.%port1tring56 or do so%e data %anipulation and use the 1et.te%5 6 function to populate the /ataWindow'
E' /escribe the diDerence between the grid and tabular presentation st(les'
.n the Xrid presentation st(le, we cannot %ove colu%ns and headings around as we can in the 3abular
presentation st(le but in Xrid presentation st(le users can reorder and resi>e colu%ns with the %ouse during
execution'
L' /escribe the diDerence between the labels and ,-up presentation st(les'
.n ,-up st(le, we can also have infor%ation fro% several rows in the database across the page, but the
infor%ation is not printed on labels'
M' How often %ust (ou set the 3ransaction ob)ect ?
Zust once when we defne the /W control' .f we change the association of a /ataWindow ob)ect with a
/ataWindow control in a script, we %ust re-issue the 1et3rans*b)ect 56 before the next retrieval or update'
S' What function changes the current row?
1croll3o4ow5 6
' .f (ou need to highlight a row and bring it into view, which function would (ou
issue frst: 1elect4ow56 or 1croll3o4ow56? Wh( ?
' 1elect4ow5 6
"' 1croll3o4ow5 6
Because the row %a( alread( be displa(ed'
"' ,a%e the three /ataWindow buDers'
3here are o\ciall( # buDers:
Pri%ar(--contains all data that have been %odifed but has not been deleted or fltered out'
Kilter - data that was fltered out'
/elete - contains all deleted data fro% the /ataWindow ob)ect'
8
3herefore we know $th- *riginal that keeps original data fro% /atabase'
#' When do the four levels of validation for /ataWindow occur?
!s a user tabs fro% one ite% to the next, PowerBuilder perfor%s four levels of validation
when user %odifes colu%n
when user tabs or clicks elsewhere in the /ataWindow
when ite% loses focus
$'Which two events %a( be involved in the four levels of validation ?
!n .te%2hanged +vent occurs when an ite% in a /ataWindow has been %odifed and loses focus'
!n .te%+rror +vent occurs when a user has entered or %odifed data in an ite% in a /ataWindow control and
one of the following occurs:
- the data t(pe of the input does not %atch the data t(pe of the colu%n 5T"6
- the input does not %eet the validation criteria defned for the colu%n 5T#6
- the input does not satisf( the processing in the script for the .te%2hanged event 5T$6
B' How would (ou defne validation rules for the /atawindow ob)ect?
We can defne validation rules in the /ataWindow painter' We can use the 1etJalidate5 6 function in a script to
set validation rules d(na%icall( 5at run ti%e6 in a script for /W'
C' What is the diDerence between a /ataWindow control and ob)ect?
/atawindow control is a container for a /W ob)ect and is placed on the window'
/W control has attribute and functions'
/atawindow ob)ect is a PB ob)ect which has connection to database and X@.'
/W ob)ect has attributes' /atawindow ob)ect represents the data source' .t encapsulates (our database access
into a high level ob)ect that handles the retrieval and %anipulation of data use for displa(ing data and
capturing user input' /atawindow ob)ect consist of :
data intelligence 5perfor% test validation rules6
user interface 5presentation st(le6
.t is used to displa( data or capture user input' /W is an ob)ect that we use to retrieve, present and %anipulate
data fro% a relational /B or other data source in an intelligent wa(' 53he /W control is the container for the /W
ob)ect' 3he /W ob)ect is created using the /W painter9 a /W control is placed on the window' ! /W ob)ect has
attributes' ! /W control has attributes and functions' ! /W ob)ect represents the data source' .t encapsulates
(our database access into a high level ob)ect that handles the retrieval and %anipulation of data' .t is used for
displa(ing data and capturing the user input' ! /W ob)ect consists of data intelligence 5perfor%s test validation
rules6 and user interface 5presentation st(le6
E' What are the strongest points of using the /ataWindow control?
/ispla(ing data'
+ntering data'
1crolling'
4eporting'
5true or false6 3he events for all PowerBuilder ob)ects have action codes that can
be used to change PowerBuilder default processing for that event'
Kalse? !ction codes are a feature unique to the events for /W controls' /iDerent events have a diDerent
nu%ber of action codes and diDerent %eanings for the sa%e nu%bers'
.te%2hanged event S -- 5/efault6 !ccept the data
-- 4e)ect the data value
" -- 4e)ect the data value but allow the focus to change
.te%+rror event S -- 5/efault6 4e)ect the data value and show a s(ste% error %essage
-- 4e)ect the data value but do not show a s(ste% error %essage
" -- !ccept the data value
# -- 4e)ect the data value but allow the focus to change
M' 5true or false6 PowerBuilder sends a request to the /B=1 to perfor% an insert or delete operation following
the call to the .nsert4ow5 6 or /elete4ow5 6 function
Kalse? *nl( when a script issues the /ataWindow function @pdate5 6 and 4etrieve56 for the /ataWindow control
are the changes sent to the /B=1 in order to update the /B'
"S' What is the diDerence between 1F02!'1F02ode and the value returned b( the /B+rror2ode56 function?
3he /B+rror2ode56 function 5not 1F02!'1F02ode6 checks the results of /atabase access perfor%ed b( a
/ataWindow' We check 1F02!'1F02ode after explicitl( issuing e%bedded 1F0 state%ents, such as 2o%%it'
"' Which feature of the /ataWindow painter greatl( si%plifes the creation of a report having onl( one group?
3he easiest wa( to create a report that has a single group is to select the Xroup presentation st(le fro% the ,ew
/ataWindow dialog box'
""' What can (ou do with a Fuer(?
We can use queries as a /ata 1ource for /ataWindow ob)ects' Fueries provide reusable ob)ects or seg%ents of
code'
3he( enhance developer productivit( since the( can be coded once and reused as often as necessar('
3he( provide Nexibilit( in the develop%ent of /ataWindow ob)ects'
"#' When do (ou need to create a Fuer(?
9
! quer( ob)ect is an 1F0 1elect state%ent that we construct using the Fuer( painter when we need to use this
1elect frequentl('
"$' Where is a Fuer( stored ?
.n a 'PB0 fle'
"B' How do (ou create a /ataWindow ob)ect d(na%icall(?
We use 1(ntaxKro%1F056 and 2reate56 functions:
1F02!'1(ntaxKro%1F0 5select string, presentation string, +rror string6
dwG'2reate5s(ntax, +rror string6
dwG'1et3rans*b)ect51F02!6
dwG'4erieve5 6
3o create a /ataWindow d(na%icall( we have to:
' build a string to hold a 1F0 1elect state%ent9
"' build a string to specif( the presentation characteristics of the /ataWindow ob)ect9
#' associate the s(ntax and description with an existing /ataWindow control9
$' associate the /ataWindow control with a transaction ob)ect, and perfor% a retrieval'
3he /ataWindow that is created exists onl( for the life of the /ataWindow control, unless we use the
0ibrar(.%port5 6 function to save it in a librar(' /(na%ic /W ob)ects allow us to create and %odif( /W ob)ects on
the N(' 3o create a /W d(na%icall(, use the 2reate5 6 function' 2reating takes two argu%ents: the na%e of the
/ataWindow ob)ect that will be replaced b( the new /W ob)ect, and the s(ntax for creating the new /W ob)ect'
We can create the /W ob)ect s(ntax in a script, but it is easier to use the 1(ntaxKro%1F056 to generate the
s(ntax fro% a 1+0+23 state%ent'
"E' What is the purpose of the presentation string?
3he presentation string holds infor%ation about the appearance of the /ataWindow'
"L' What kind of infor%ation can be specifed in the presentation string?
We can specif( six /ataWindow properties in the presentation string:
/ataWindow ob)ect, Presentation 1t(le, 2olu%n, 3ext, Xroup, 3itle'
lsGpresentGstr R : < takes the defaults fro% the Powersoft repositor( tables' 3hese defaults cover fonts, colors,
validation rules, etc'
"M' Wh( %ust (ou specif( the transaction ob)ect for a /ataWindow control after creating the /ataWindow
ob)ect?
3he 2reate56 function %ust be followed b( 1et3rans*b)ect56 function because 2reate5 6 destro(s an( previous
association between the /ataWindow and a transaction ob)ect' 3hen, we can issue a 4etrieve56'
#S' 2an (ou d(na%icall( assign a /ataWindow ob)ect?
Oes, using /ataWindowAs control attribute :/ata*b)ect<'
/ataWindow control has the attribute /ata*b)ect' .f we want to change an associated /ataWindow ob)ect at
runti%e we need to put a line in the script that changes the value of the /ata*b)ect attribute'
Kor exa%ple:
dwG'/ata*b)ect R :dGna%e<
#' 0etAs sa(, (ou share two /W buDers and the pri%ar( /W has so%e ///W colu%ns' Will this ///W be
shared auto%aticall( as well?
,*' !fter we have shared " /ataWindows, we have to share all /rop/owns as well' Kirst, we have to get the
reference for the 2hild /ataWindow using Xet2hild5 6 function and then do sharing b( using 1hare/ata56
function'
/ataWindow2hild dwcG, dwcG"
dwG'getchild5:e%plo(ee<, dwcG6
dwcG'1et3rans*b)ect5sqlca6
dwcG'4etrieve5 6
dwG"'getchild5:e%plo(ee<,dwcG"6
dwcG'1hare/ata5dwcG"6
#"' How can (ou update %ultiple /ataBase tables fro% one /ataWindow?
@sing =odif(56 function' When a /ataWindow is based on a )oin of %ultiple tables, we can update all of those
tables b( %odif(ing attributes /ataWindow'3able, @pdate3able and 5:/epGid'@pdate R ,*<6
dwG'=odif(5:/epGna%e'@pdate R ,*<6
dwG'=odif(5:/epGid'Ve( R ,*<6
dwG'=odif(5:/ataWindow'3able'@pdatetable R ]e%plo(eeA:6
dwG'=odif(5:/epGid'@pdate R O+1<6
dwG'=odif(5:/epGna%e'@pdate R O+1<6
dwG'=odif(5:/epGid'Ve( R O+1<6
dwG'@pdate5 6
+,/ .K
@pdate +%bedded 1F0
##' What is the %ethod to validate a nu%eric colu%n in a /ataWindow?
1etJalidate5 6
#$' .n what attribute of the 3ransaction ob)ect are the database-specifc error codes for
2onnectI@pdateI4etrieve stored?
10
1F0/B2ode
#B' How can (ou change a 1elect state%ent of the /ataWindow at runti%e?
We can change the select state%ent b( using functions 1et1F01elect5 6 or b( changing the data attributes
3able'1elect b( calling function =odif(56'
=odif(56 is preferable because it works faster'
dwG'=odif(5:datawindow'3able'1elect R ]1elect W fro% custo%erA<6
0i%itations to using 1et1F01elect
@se 1et1F01elect onl( if the data source for the /ataWindow ob)ect is a 1F0 1+0+23 state%ent without retrieval
argu%ents and (ou want PowerBuilder to %odif( the update infor%ation for the /ataWindow ob)ect:
dwG'=odif(5^/ataWindow'3able'1electR&select'''&^6
=odif( will not verif( the 1+0+23 state%ent or change the update infor%ation, %aking it faster but %ore
susceptible to user error' !lthough (ou can use =odif( when argu%ents are involved, it is not reco%%ended
because of the lack of checking'
#C' What is an @pdate Nag?
We use the% when we need to update %ultiple /ataBase tables fro% one /ataWindow'
#E' What is the diDerence between nested and co%posite reports?
.n a nested report each report has its own data source'
2o%posite report does not have its own data source-it is )ust a container for other reports'
#L' Oou have B /Ws with ///Ws in each of the%' How can (ou open all ///Ws at the sa%e ti%e? @sing an
arra('
#M' !fter the data has been retrieved, how can (ou fnd out the status of rows ?
B( using Xet@pdate1tatus5 6 5beca%e obsolete and replaced b( row in /B+rror event6
1tatus could be a6 ,ew=odifed -- 4ow onl(
b6 =odifed -- 2olu%n
c6 ,ew - 4ow onl(
,ot=odifed 4ow and 2olu%n
$S' =odifcation status - how %an( of the% do (ou know and which one refers to rows onl( or to colu%n onl(?
,ew and ,ew=odifedH4ow onl(
,ot=odifedH4ow and 2olu%n
=odifedH2olu%n
$' What functions do (ou use to change the row status?
dwG'1et@pdate1tatus5 6 _dwG'1et.te%1tatus56
dwG'Xet@pdate1tatus5 6 dwG'Xet.te%1tatus56
$"' How do (ou stop the user fro% editing data that is displa(ed in a feld of a /ataWindow?
2hange the tab value of the feld to >ero in the /ataWindow painter'
$#' 3he Where clause in a 1F0 state%ent has the eDect of pairing down the nu%ber of rows returned to the
client fro% the server' How can the nu%ber of rows be reduced on the client within PowerBuilder? @se a Kilter'
$$' .n order to sort the contents of a /ataWindow, two co%%ands %ust be used' What are the( and what does
each do?
1et1ort56 and 1ort56'
1et1ort56 defnes the sort criteria 5pri%ar(, secondar( sort fles ` ascending or descending order, etc'6'
1ort56 perfor%s the actual sort'
$B' What is the diDerence between co%puted colu%ns and co%puted felds in a /ataWindow ob)ect?
2o%puted colu%ns are created as a result of a 1F0 quer( on the server side'
2o%puted felds`as a result of internal processing b( /ataWindow on the client side'
$C' When (ou i%ple%ent incre%ental search, there is no 2urrent row, so how do (ou highlight the row (ou are
looking for?
1elect4ow5 6
llGrow R Kind5 6
if llGrow Y S then 1elect4ow 5llGrow6
$E' +xplain how (ou understand the process of deleting data fro% /ataWindows and /atabases?
/ataWindow delete puts its records into the deleted buDer of the /atawindow'
/ataBase delete deletes records fro% a table of our database co%pletel('
$L' What are +xtended colu%n attributes? How can (ou change the% d(na%icall(?
.tAs /ataWindow ob)ect propert( 5+xpressions6 which we can change d(na%icall( using =odif(56 function'
11
$M' What is a code table?
1pecifes whether PowerBuilder uses the code table for the colu%n to validate data' Jalues are Boolean: 3rueH
@ses code table to validate data9 KalseH/oes not use code table to validate data' 3he appearance of the text is
specifed b( the edit %ask' +ach row in the 2ode 3able is a pair of corresponding values: a displa( value that
user sees and data valuesHthose that are saved in the database'
2ode 3ables are used with /rop/own0istBox and 4adioButtons'
BS' How can (ou %odif( a code table during execution?
@sing X+3J!0@+56 and 1+3J!0@+56 functions'
4eports
B' .n a nested report, how can the two reports be related to each other?
3he( are usuall( related b( argu%ents or b( criteria'
B"' How can (ou pass argu%ents to a report nested inside a co%posite report?
3o pass argu%ents to co%ponent report in a co%posite report, we defne %atching argu%ents for the co%posite
report and relate these to the argu%ents of the co%ponents report'
B#' .f (ou wanted to specifcall( reference a report nested inside a co%posite report, for exa%ple, to retrieve or
share data, how would (ou do it?
We can use retrieval argu%ents with a co%posite report to control the rows retrieved for each report:
' /efne one or %ore retrieval argu%ents for the co%ponent reports'
"' 4ight-click the co%posite report, choose 4etrieval !rgu%ents fro% the properties sheet and add to the
co%posite report ever( argu%ent that is needed for the co%ponent reports'
#' 4ight-click each co%ponent report with argu%ents to displa( the properties dialog box'
.n the !rgu%ents tab, relate each argu%ent in the co%ponent report to an argu%ent in the co%posite report'
We can use /ataWindow propert( expressions to refer to the properties of ob)ects in a nested report'
B$' What is the diDerence between Print56 and Print/ataWindow56 functions?
Print56 sends the contents of a /W control or /ata1tore ob)ect to the printer as a print )ob'
Print/ataWindow 5PrintZob,u%ber, dwcontrol6 prints the contents of a /ataWindow control as a print )ob'
PrintZob,u%berH3he nu%ber the Print*pen function assigned to the print )ob
dwcontrolH3he na%e of the /ataWindow control or child /ataWindow containing the /W ob)ect (ou want to
print
4eturn value: .nteger' 4eturns if it succeeds and - if an error occurs' .f an( argu%ent&s value is ,@00,
Print/ataWindow returns ,@00'
BB' What is a 2hild/ataWindow, a /rop/own/ataWindow? /iDerence?
/rop/own/ataWindow is an edit st(le for /ataWindow colu%n' .t is like a //0B which has connection to the
database'
2hild/ataWindow is a regular, ph(sical, real /ataWindow for an edit st(le ///W' 5.t is a ///W in a /W ob)ect6'
! co%bination box that co%bines the features of a /W ob)ect and an 10+' 3he /ataWindow portion of the
///W behaves like an 0B but is populated fro% a /W ob)ect' ! 2hild /W ob)ect is a ///W in a /W ob)ect' !
///W behaves as a child window of the /W ob)ect that contains the%' 3o use a 2hild /W, use dwXet2hild56
function to obtain the child 5data t(pe /ataWindow2hild6, assign it a transaction ob)ect, and then populate it'
Kor exa%ple:
/ataWindow2hild dwc
dwGe%p'Xet2hild5:e%pGid<, dwc6 II dwgetchild5 6 beco%es obsolete in pb B
dwc'1et3rans*b)ect51F02!6
dwc'4etrieve5:argu%ent<6
BC' How do (ou get the na%e of a /rop/own/ataWindow? Xet2hild5 6
BE' How do (ou trap errors fro% the /ataBase in the /ataWindow?
Write so%e code in the /B+rror +vent
Kor exa%ple:
if 1F02!'1F02ode aY S then
=essageBox5 6
return
end if
BL' What two t(pes of co%puted colu%ns are allowed in a /ataWindow?
*ne fro% the database side
*ne fro% the client side
BM' What is .K5 6 function? 5Hint: used in the /ataWindow6
.K5 6 function evaluates a condition and returns a value based on that condition'
CS' How could (ou link two /ataWindows having =asterI/etail relationship?
0etAs sa( we have " /ataWindows in an applicationAs window' *ne is )ust a list of e%plo(ees and another
contains %ore detailed personal info on the selected e%plo(ee' 3o link these two /Ws, we could place, for
exa%ple, in the script for the frst /ataWindowAs /ouble2licked event, functions to retrieve the detailed info for
12
the selected e%plo(ee' We would call the 4etrieve56 function for the second /W with a retrieval argu%ent which
is selected in the frst /ataWindow +%plo(ee ./'
/ata in the /etail /ataWindow gets retrieved based on the retrieval argu%ent taken fro% the selected row of
the =aster /ataWindow b( using function Xet.te%[5 6
.nt liGe%pGnu%
liGrowGnu% R dwGe%pGlist'Xet2licked4ow56
if liGrowGnu% Y S then
dwGe%pGdetail'4etrive5dwGe%pGlist'Xet.te%,u%ber5liGrowGnu%, :e%pGid<66
3o link two /ataWindows we could place, for exa%ple, in /ouble 2licked event function to retrieve the detailed
infor%ation for selected e%plo(ee'
4ow R dwG'Xet4ow5 6
dwGe%p'4etrieve5row6
and row is retrieval argu%ent for dwGe%p'
3o link two /ataWindows we have to retrieve data based on a retrieval argu%ent taken fro% a selected row of
the =aster /ataWindow b( using function Xet.te%[5 6, depends on data t(pe'
C' How can (ou set the /ataWindow to a particular row?
.f (ou %ean that a row is in the /W buDer and not on the displa(, . would use the 1croll3o4ow5 6 function' .f .
need to %ake so%e row current, . will use 1et4ow5 6'
long row
dwGna%e'1et4ow5row6
dwGna%e'1croll3o4ow5row6
C"' How can (ou print %ultiple /ataWindows?
We should open the print )ob b( calling the Print*pen5 6 function' !fter that, we can print /Ws b( using
Print/ataWindow5 6 function' !fter that, we close the print )ob b( calling Print2lose5 6' When we use
Print/ataWindow5 6 with Print*pen5 6 and Print2lose5 6, we can print several /ataWindows in one print )ob' 3he
info in each /ataWindow control starts printing on a new page' +xa%ple:
long )ob
)ob R Print*pen5 6 II+ach /ataWindow starts printing on a new page'
Print/ataWindow5)ob, dwG+%pHeader6
Print/ataWindow5)ob, dwG+%p/etail6
Print/ataWindow5)ob, dwG+%p/pt1u%6
Print2lose5 6
C#' How %an( tables can be updated at the sa%e ti%e in a /W?
*ne is updated b( default' .f we want to update %ultiple tables fro% /W, we have to write a script for this using
=*/.KO56'
C$' +xplain how a /W generates 1F0 select state%ent for each row after issuing ]updateA function?
CB' When do (ou use Fuick 1elect for /ata source?
.f the data is co%ing fro% one table and we need onl( to choose colu%ns selection criteria and sorting, we can
choose Fuick 1elect'
CC' When do (ou use 1F0 1elect for data source?
.f we want to )oin tables to use retrieval argu%ents, or to Xroup data'
CE' When do (ou choose ]externalA for the data set and what do (ou have to defne in this case?
.f the data is not co%ing fro% the /B, for exa%ple, /W will be populated fro% the script 5using 1et.te%56
function6 or i%ported fro% an external fle 5using .%port fle56 function6, we have to defne the result set for /W
ob)ect to t(pe and si>e colu%n in the result set'
What do (ou use co%puted felds for?
We use co%puted felds if we need so%e calculation based on colu%n data that change for each retrieved row,
so%e su%%ar( statistics s(ste% infor%ation 5as current date and ti%e6'
CM' What are the rules for update tables in the /atawindow?
.f the /W contains colu%ns fro% one table, PB defnes all colu%ns of this table as updatable b( default' .f the
/ataWindow contains colu%ns fro% %ore than one table, all these tables b( default are not updatable' We can
%odif( this in the /W painter and defne onl( one table as updatable' .f we want to update %ultiple tables fro%
/W, we have to write a script for this using =*/.KO56'
ES' How do (ou control the update in %ulti-user environ%ent?
.f users are accessing the sa%e table at the sa%e ti%e, we need to decide when to allow our application to
update the /atabase' We use the 2heck-.n and 2heck-*ut procedures'
E' How do (ou assign the transaction ob)ect to the /W control?
We use 1+334!,156 or 1+334!,1*BZ+2356' When we use 1+334!,156, the /W control uses its own 3ransaction
ob)ect and auto%aticall( perfor%s connect, disconnect, co%%it and rollback' 3he 1et3rans*b)ect56 tells the /W
control to share the transaction ob)ect with other /W controls' We have to control the database processing and
we are responsible for %anaging database transactions' !pplication perfor%ance is better when we use
1et3rans*b)ect56'
E"' How do (ou stop the retrieval of the /W i%%ediatel(? @se /B2ancel56
13

E#' .f the source for a /W is a stored procedure and this stored procedure has para%eters, where do we have
to pass these para%eters? .n the 4+34.+J+56
E$' What are # buDers used b( a /ataWindow ob)ect?
*\ciall(, there are # buDers:
Pri%ar( - data that have been %odifed but has not been deleted or fltered out'
Kilter - data that was fltered out'
/elete - data deleted fro% /ataWindow ob)ect'
$th- *riginal- the buDer that keeps the original data fro% the /atabase'

EC' What is the B0*B data t(pe?
@nbound data t(pe that stands for binar( large ob)ect' @suall( used to hold pictures in database, windowAs wave
sound fle or =./. %usic'
EE' 2an (ou call batch 1F0 fro% (our /ataWindow? O+1'
14
/ebugging and running an application
' What can (ou do in /ebug %ode?
We can insert stops or a single stop through the code and displa( the contents of variables'
"' How can (ou look at instance variables in debug %ode?
.nstance variables are part of an ob)ectAs defnition so PB lists instance variables as attributes of that ob)ect
itself at the end of the list'

#' .f a serious error occurs during execution, what event will be triggered?
1(ste% +rror event will be triggered in the application ob)ect and we can write a script for this event'
15
/W Kunctions
+xplain the diDerence between 1et3rans56 and 1et3rans*b)ect56?
.n si%ple ter%s, 1et3rans56 gives (ou no control on the transactions' .t auto%aticall( connects to and
disconnects fro% the database after each 4etrieve56 and @pdate56 function' .t is useful when the nu%ber of
connections are li%ited, but, (ou can&t use this for %ulti-table update' *n the other hand 1et3rans*b)ect56 gives
(ou full control over the transactions' .t is (our responsibilit( to connect to and disconnect fro% the database
and also, (ou need to issue 2*==.3I4*00B!2V state%ents' 3his %ethod is %ore e\cient since there is no
connectIdisconnect overhead for each database operation'
"' When would (ou use 1et3rans5 6?
We use 1et3rans56 when onl( a li%ited ,o' of connections to the /B is allowed or we are onl( retrieving data and
do not need to hold /B locks on records the user is %odif(ing'
#' +xplain 1et!ction2ode56' /o /W events support this function?
3he 1et!ction2ode56 function changes the action that follows a /W event' 3his function overrides the standard
behavior of an event' ,ot all /W events have action codes, onl( those that can have diDerent outco%es' .n PBB
1et!ction2ode56 beca%e obsolete' We use ke( word :return< fro% S to # depending on the event' /efault is 5S6'
4eturn %ust be the last line in a script or state%ent'
$' How do (ou use 1hare/ata56 between two diDerent /ataWindows?
.f we want to share the data between " /W controls we use dwG'1hare/ata5dwG"6'
3wo /ataWindows %ust have the sa%e select but %a( have a diDerent displa('
.n PBB . use it with /ata1tore' 3he controls do not share for%atting9 onl( the data is shared, including data in
the pri%ar(, delete, and flter buDers, and the sort order'
3o turn oD the sharing of data buDers for /ataWindow controls we use the function dwG'1hare/ata*D5dwG"6 '
B' What is the diDerence between 3rigger+vent5 6 and Post+vent5 6?
3rigger+vent 5 6 function %akes the event occur i%%ediatel(' 3his function does not return until the processing
for the event is co%plete'
Post+vent5 6 function %akes the event occur when the current event is fnished executing' .n other words, it
stands in the queue' 3he diDerence between the% lies in ti%ing'
C' What is the purpose of Oield5 6 function?
We use O.+0/5 6 to allow the user to interrupt a tight loop in order to receive an( %essages there %a( be' We
%ust call Oield5 6 and check for an interruption each ti%e we pass through the loop' We %ust also close the
script when we close the window' Oield5 6 checks the %essage queue and if there are %essage in the queue, it
pulls the% fro% the queue' Oields control to other graphic ob)ects including ob)ects that are not PowerBuilder'
.nclude Oield5 6 within a loop so that other processes can happen' +'g', use Oield5 6 to allow end users to
interrupt a loop' B( (ielding control, we give the user ti%e to click on a cancel button in another window' We can
also use Oield5 6 in a loop in which we are waiting for so%ething to fnish so that other processing can take
place, in either our or so%e other application'
E' What is the purpose of !ccept3ext5 6 function?
3he !ccept3ext5 6 function validates the last ite% in the /ataWindow control that a user worked on' ,ever call
!ccept3ext5 6 in the .te%2hanged event' .f a user enters the data and wants to close the window without
pressing the tab or the update co%%and button, we have to be responsible for saving the last %odifcation:
dwcontrol'!ccept3ext5 6
When a user %oves fro% ite% to ite% in a /W control, the control validates and accepts
data the use /ataWindow control or /ata1tore' 3he data in the edit control %ust pass the validation rule for the
colu%n before it can be stored in the ite%'
!pplies to /ataWindow controls, /ata1tore ob)ects, and child /ataWindows
1(ntax dwcontrol'!ccept3ext 5 6
!rgu%ent /escription
dwcontrol 3he na%e of the /ataWindow control, /ata1tore, or child /ataWindow in which (ou want to accept
data entered in the edit control
4eturn value .nteger' 4eturns if it succeeds and - if it fails 5for exa%ple, the data did not pass validation6' .f
dwcontrol is ,@00, !ccept3ext returns ,@00'
@sage: When a user %oves fro% ite% to ite% in a /ataWindow control, the control validates and accepts data
the user has edited' When a user %odifes a /ataWindow ite% then i%%ediatel( changes focus to another
control in the window, the /ataWindow control does not accept the %odifed dataHthe data re%ains in the edit
control' @se the !ccept3ext function in this situation to ensure that the /ataWindow ob)ect contains the data the
user edited' ! t(pical place to call !ccept3ext is in a user event that is posted fro% the /ataWindow&s 0oseKocus
event'
!ccept3ext in the .te%2hanged event
2alling !ccept3ext in the .te%2hanged event has no eDect'
+vents: !ccept3ext %a( trigger an .te%2hanged or an .te%+rror event'6
L' When do (ou use !ccept3ext56?
1o%eti%es if user changed the data and i%%ediatel( changed the focus the data is not accepted (et' We have
to use !ccept3ext56 in the .te%2hange event to accept the data'
M' Oou want to know how fast (our code is being executed' How do (ou ti%e execution of (our code?
use 2P@5 6 function
16
0ong' 4eturns the nu%ber of %illiseconds of 2P@ ti%e elapsed since the start of (our PowerBuilder application'
3hese state%ents deter%ine the a%ount of 2P@ ti%e that elapsed while a group of state%ents executed:
0ong llGstart, llGused II /eclare start and used as long integers'
llGstart R 2P@5 6 II 1et the start equal to the current 2P@ usage'
''' II +xecutable state%ents being ti%ed
II 1et used to the nu%ber of 2P@ seconds
II that were used 5current 2P@ ti%e - start6'
llGused R 2P@5 6 - llGstart
S' What is the purpose of /escribe5 6, =odif(5 6?
=odif(5 6 and /escribe5 6 functions are /W ob)ect level functions' /escribe5 6 reads the attributes of a /W ob)ect
at runti%e' =odif(5 6 changes the attributes at runti%e'
3(pical uses for =odif( 56 are:
b 2hanging colors, text settings, and other appearance settings of ob)ects
b 2hanging the update status of diDerent tables in the /W so that (ou can update %ore than one table
b =odif(ing the WH+4+ clause of the /ataWindow ob)ect&s 1F0 1+0+23 state%ent
b 3urning on Fuer( %ode or Pro%pt Kor 2riteria so users can specif( the data the( want
b 2hanging the status of 4etrieve *nl( !s ,eeded
b 2hanging the data source of the /ataWindow ob)ect
b 2ontrolling the Print Preview displa(
b /eleting and adding ob)ects, for exa%ple, lines or bit%aps, in the /ataWindow ob)ect
dwGcusto%er'=odif(5^/ataWindow'2olor R "BB^6
where ^/ataWindow'2olor R "BB^ is %odstring'
@se /escribe5 6 to understand the structure of a /ataWindow'
3(pical uses for /escribe 56 are:
bands the /ataWindow uses
data t(pes of the colu%ns'
to fnd out the current value of a propert( and use that value to %ake further %odifcations'
to obtain the /ataWindow&s 1+0+23 state%ent in order to %odif( it 5for exa%ple, b( adding a WH+4+ clause6'
dwG'/escribe5^salar('2ol3(pe^6
where ^salar('2ol3(pe^ is attribute list
' How can (ou fnd out what ob)ect is under the %ouse pointer in a /ataWindow?
@sing *b)ect!tPointer5 6 function that fnds out where the user clicked in a graph' *b)ect!tPointer56 reports the
region of the graph under the pointer and stores the associated series and data point nu%bers in the
designated variables' !pplies to graph controls in windows and user ob)ects, and in /ataWindow controls'
#' What is the diDerence between Xet3ext56 and Xet.te%56?
Xet 3ext56 gives (ou the content of the text control , when the data is not accepted (et and (ou can
use it for exa%ple in .te%2hanged +vent to obtain the data that did not pass validation rule'
Xet.te%56 gives (ou value that accepted and is in the /W buDer alread('
$' How can (ou cop( data fro% one /W to another if the( have the sa%e structure?
We could use the function 4ows2op(56 3he function copies a range of rows fro% one /ataWindow control 5or
/ata1tore ob)ect6 to another, or fro% one buDer to another within a single /ataWindow control 5or /ata1tore6'
@ses for 4ows2op(56 include:
=aking copies of or %ore rows so that users can create new rows based on existing data'
Printing a range of rows b( cop(ing selected rows to another /W and printing the second /W'
dwG'4ows2op(5dwG'Xet4ow56, dwG'4ow2ount56, Pri%ar(?, dwG", , Pri%ar(?6
B' What is the function of Kind5 6 ?
Kinds the next row in a /W in which data %eets a specifed condition'
Kind 5expression, start, end6' 3he search is case-sensitive' When (ou co%pare the text to the value in a colu%n,
the case %ust %atch'
C' What is the function of 1et3ab*rder5 6?
2hanges the tab sequence nu%ber of a colu%n in a /W control to the specifed value' +'g',
dwcontrol'1et3ab*rder 5colu%n, 3ab,u%ber6
@se 1et3ab*rder5 6 to change a colu%n in a /W ob)ect to read-onl( b( changing the tab sequence nu%ber of
the colu%n to S'
E' What is the function of /elete4ow5 6?
/eletes a current row fro% a /W control or 2hild /ataWindow'
dwcontrol'/elete4ow 5row6
/elete4ow5 6 deletes the row fro% the /ataWindow&s pri%ar( buDer'
L' How can (ou override a PB function, e'g', /elete4ow5 6, for a /W control?
We need to create a @ser *b)ect of the /ataWindow t(pe and declare the /elete4ow5 6 function for this ob)ect
having the sa%e para%eters as PowerBuilderAs /elete4ow5 6' When we call the function, PB tries to fnd this
function on the ob)ect level frst, thatAs wh( our function will be executed and not PowerBuilderAs' But we can
still call PowerBuilderAs /elete4ow5 6 b( using 2all 1uper :: /elete4ow5 6
M' What is the function of /B+rror2ode5 6?
4eports the database-specifc error code that triggered the /B +rror event'
17
/B+rror2ode56 is obsolete' 3he /B error code is available as an argu%ent 1F0/B2ode in the /B +rror event:
dwcontrol'/B+rror2ode 5 6
When a /B error occurs while a /W control is interacting with the /B, PB triggers the /B +rror event' 1ince
/B+rror2ode is %eaningful onl( if a /B error has occurred, we should call the function onl( in the /B +rror
event'
"S' What is the function of /B+rror=essage5 6?
4eports the database-specifc error %essage that triggered the /B +rror event'
/B+rror=essage5 6 is obsolete' 3he /B error %essage is available as an argu%ent 1F0+rr3ext in the /B +rror
event' dwcontrol'/B+rror=essage5 6
When a /B error occurs while a /W control is interacting with the /B, PB triggers the /B +rror event' 1ince
/B+rror2ode is %eaningful onl( if a /B error has occurred, we should call the function onl( in the /B +rror
event'
"' What is the function of 1croll3o4ow5 6?
1crolls a /W control to the specifed row' 1croll3o4ow5 6 changes the current row' dwcontrol' 1croll3o4ow5 row
6
!fter we call 1croll3o4ow5 6, the specifed row beco%es the new current row' .f that row is alread( visible, the
displa(ed rows do not change' .f it is not visible, the displa(ed rows change to displa( the row' 1croll3o4ow5 6
does not highlight the row' @se 1elect4ow5 6 to let the user know what row is current' 1croll3o4ow5 6 %a( trigger
these events:
.te%2hanged
.te%+rror
.te%Kocus2hanged
4owKocus2hanged
"#' What is the function of 1etKilter5 6?
1pecifes flter criteria for a /W control'
"$' What does the function =odifed2ount5 6 do?
4eports the nu%ber of the rows that have been %odifed but not updated in a /W'
dwcontrol'=odifed2ount 5 6
"B' What is the function of 1hare/ata5 6?
.f we need to share data between a pri%ar( /W and %ore than one secondar( /W control, we call 1hare/ata5 6
for each secondar( /W control' When we call functions in either the pri%ar( or secondar( /W that change the
data, PB applies the% to the pri%ar( /W control and all secondar( /W controls are aDected'
dwGpri%ar('1hare/ata 5 dwGsecondar( 6
1hares data retrieved b( one /W control, which is referred to as the pri%ar( /W, with another /W control,
referred to as the secondar( /W' 3he controls do not share for%atting9 onl( the data is shared, including data in
the pri%ar( buDer, the delete buDer, the flter buDer, and the sort order'
"C'What is the function of 2reate5 6 ?
2reates a /W ob)ect using /W source code and puts that ob)ect in the specifed /W control or /ata1tore ob)ect'
3his d(na%ic /W ob)ect does not beco%e a per%anent part of the application source librar('
dwcontrol'2reate 5 s(ntax 7, errorbuDer 8 6
3he 2reate5 6 function is used to associate the /W ob)ect s(ntax with an existing /W control'
dwG'2reate5 lsGs(ntaxGstr, lsGerr%sg6
"E' What does function 1elect4ow5 6 do?
Highlights or dehighlights rows in a /W control' 1elect4ow5 6 does not aDect which row is current'
dwcontrol'1elect4ow5S, K!01+6 dwcontrol'1elect4ow5row, 34@+6' .f a row is alread( selected and we specif( that
it be selected 5boolean is 34@+6, it re%ains selected' .f a row is not selected and we specif( that it not be
selected 5boolean is K!01+6, it re%ains unselected'
"L' When do 4etrieve!s,eeded5 6 stop working?
.f we use Kilter5 6 and 1ort5 6'
"M' Xive an exa%ple of a case sensitive functions?
Kind5 6
#S' What will happened if we place !ccept3ext56 in .te%2hangeevent?
We get an error %essage
#' What functions used for creating /W d(na%icall(?
=odif(56,/escribe56
18
+,2!P1@0!3.*,
What is encapsulation?
+ncapsulation %eans that the functionalit( of one ob)ect does not eDect the functionalit( of another one'
' What are benefts of using encapsulation? Xive exa%ples of encapsulation in PB'
+ncapsulation gives us a wa( to hide and protect data inside an ob)ect to avoid a conNict with ob)ects, all
infor%ation is protected' 3o hide data, we use private and protected variables' Kor exa%ple, the code to %ake a
2o%%andButton appear depressed is encapsulated into the 2o%%andButton itself' +ncapsulation is a %ethod
of encapsulating data inside an ob)ect, having function to %anipulate the data and not allow access directl(,
onl( trough functions' Jariables are private, functions to access those variables are public' +xa%ple: 0etAs sa(
(ou have a 4adioButton on (our window' 3o check it in the script, (ou can )ust state: rbG'checked R true' .f
(ou want to use encapsulation, (ou would create a @* inherited fro% the 4adioButton and co%plete with the
user-ob)ect function which would have the script to check or uncheck this 4adioButton and direct all the
checkIuncheck calls to this user-ob)ect function'
19
+J+,31
' +xplain .te%2hanged and .te%+rror events?
.te%2hanged event occurs when the ite% has changed the value in a /W control and all validation rules are
passed successfull(, in other words, all three conditions are %et:
.s an(thing changed?
.s the data of correct data t(pe?
/oes data pass validation rules?
.te%+rror event occurs when the ite% does not pass validation test for its colu%n'
"' What is the *3H+4 event?
!n( non-standard event is other event' 3he *ther event occurs when a Windows event that is not a PB event
occurs' Kor exa%ple, when the user presses the %iddle %ouse button on a #-button %ouse'
#' .f there is a proble% with the /B during data retrieval :
Which /W event will be triggered?
Where will the error code be stored?
! /B+rror event will be triggered when a /B error occurs in a /W' 3he action codes for this event are: S -
5/efault6 /ispla( the error %essage'
- /o not displa( the error %essage'
3he +rror code will be stored in /B+rror2ode, which PB B provides to us as an argu%ent in the /B+rror +vent'
$' What is the diDerence between an *pen and !ctivate events?
3he *pen +vent occurs after the window has been opened but before it is displa(ed'
3he !ctivate event occurs )ust before the window beco%es active' When the !ctivate event occurs, the frst
control in the tab order for the window gets focus, if there are no visible controls in the window, the window gets
focus'
$a' What proble% could be with !ctivate event?
Proble% with !ctivate event is we cannot put Kocus2hanged co%%ands such as =essageBox5 6 in this event,
because we will be in a loop'
B' What is 2loseFuer( event? When do (ou use it?
3he 2loseFuer( event occurs before 2lose event when we re%ove the window fro% displa( 5close it6' We use
2loseFuer( event when weAd like to perfor% so%e processing or do so%e checking before user closes the
window' .f we do not want to allow the user to close the window, we set 4eturn else 4eturn S' 4eturn
prevents the window fro% closing and %ust be the last state%ent in the script for the 2loseFuer( event' Be
sure to set 4eturn S when processing is co%plete so the window can be closed' 3o perfor% so%e processing or
do so%e checking before (ou close the window set the value of =essage'4eturnJalue to and then write a
script for the 2loseFuer( event to perfor% the desired processing' 3he state%ent that sets
%essage'4eturnJalue to to prevent the window fro% closing %ust be the last state%ent in the script for the
2loseFuer( event'
C' Which events do not :like< the =essageBox5 6 function to be in their scripts?
!ll K*2@1 events such as Jertical 1croll, Hori>ontal 1croll, !ctivate, 0oseKocus event'
E' What functions cannot be used in the .te%2hanged +vent?
!ccept3ext5 6
1et4ow5 6
L' What are 2onstructor and /estructor events?
2onstructor event occurs in all draggable controls i%%ediatel( before the *pen event' 2onstructor event is also
triggered when a user ob)ect is placed d(na%icall( in a window' /estructor event occurs in all draggable
controls i%%ediatel( after 2lose event' /estructor event is also triggered when a user ob)ect is re%oved
d(na%icall( fro% the window'
M' What is 3i%er event ?
3his is an event triggered b( the 3i%er5n6 function that occurs ever( n seconds after the function is called' +'g',
we can displa( a %essage, beep, or open a window ever( n sec'
S' What do (ou use the 1F0 Preview event for?
Oou can use the 1F0 Preview event to displa( 1F0 state%ent right before its execution' .t is useful for the
debugging' .n PowerBuilder B: =essageBox5:1F0<, 1F01(ntax6
1F0 Preview event occurs i%%ediatel( before 4etrieve56, @pdate56, or 4eselect4ow 56 are executed' .n
PowerBuilder $ to get the current 1F0 state%ent (ou could use either dwG'/escribe5 6 or
dwG'Xet1F0Preview5 6 functions' Kor exa%ple:
string sGte%p
sGte%p R dwG'/escribe5:/ataWindow'3able'1elect<6
=essageBox5:=( 1F0<, :sGte%p<6
!lso, we could use 1F0 Preview event if we want to use 1tored Procedures to perfor% @pdate in the /atabase'
' When does 1F0 Preview event occur and what action codes does this event have?
3he 1F0 Preview event has action codes that specif( the action that takes place when the event occurs after an
@pdate5 6 function call' 3o set action code we use 4eturn ke( word function'
20
3he action codes are :
S - 5default6 2ontinue9
- 1top processing9
" - 1kip this request and execute the next request'
"' What is the usage of the /B+rror +vent?
We want to override the default error %essage' 3he /B+rror +vent is used when a /B error occurs as a result of
the operation perfor%ed b( /ataWindow @pdate5 6 function'
#' When does PB trigger the /B+rror event?
Whenever there is an error following retrieval or update in the /W, for exa%ple, if we tr( to insert a row that
does not have values for all colu%ns that have been defned as not allowing ,@00'
$' What events are triggered b( @pdate5 6?
1F0 Preview
@pdate 1tart
@pdate +nd
How do (ou create (our own custo% event?
Wh( would (ou consider doing it altogether?
21
'+[+ K.0+
' What is '+[+ fle?
'+[+ fle is a for% of an application that can be executed outside of PB'
"' 5true or false6 Oou %ust have either 'PB4 or 'PB/ for ever( application' Kalse
#' 5true or false6 Oou %ust have both 'PB4 and 'PB/ for ever( application' Kalse
$'When do (ou need to use 'PB/ ? We use 'PB/ when:
the nu%ber and si>e of the ob)ects in our application would otherwise %ake a ver( large '+[+ 5'" to 'B
%egab(tes6'
we need to share co%ponents a%ong several applications'
distribute application co%ponents selectivel(, for exa%ple, to upgrade an application or fx a bug'
B' When do (ou need to use a 'PB4 ?
We create 'PB4 if we have an( d(na%icall( assigned ob)ects, bit%aps or icons and to reduce the nu%ber of fles
we need to distribute with the '+[+' We t(picall( use a 'PB4 when we have scripts in our application in which we
d(na%icall( assign resources to attributes of ob)ects or controls in the application' .f we do not use a 'PB4, we
%ust distribute various 'B=P, '40+, '.2* fles with the application' We %ust place in 'PB/As an( ob)ects that we
reference d(na%icall( in scripts in the application'
C' Wh( do we create PB4, PB/ fles?
We create 'PB4 if we have an( d(na%icall( assigned ob)ects, bit%aps or icons to reduce the nu%ber of fles we
need to distribute with the '+[+' We have to create 'PB/ if we have %ore than one PB0' .t allows us to break the
application into s%aller units that are easier to %anage and %akes the executable fle s%aller, and at execution
ti%e we can load an( ob)ects that are not contained in the applicationAs executable fle' .t %akes sense to use
PB/ when our application is reall( large'
E' How %an( 'PB/s can (ou have for one application ?
!s %an( as we need and depending on available %e%or('
L' How %an( 'PB4s can (ou have for one application ?
*ne
M' 5true or false6 .f (ou have created a 'PB/ and a 'PB4 for an application, (ou %ust distribute the '+[+, the PB/,
and the 'PB4 to the users'
3rue
S' What do (ou need to do before creating an '+[+ fle?
Before we create the '+[+ for an application, we need to %ake sure that:
the application is the current application9
we have listed all of the necessar( 'PB0s in the librar( search path for the application9
if we are using a 'PB4, we have created it'
' What do (ou have to distribute with (our application to the end-user?
3he '+[+ Kile
" 3he '//0 Kiles
# /eplo(%ent kit 5 '/00s
"' What is 'PB4 fle?
PB4 fle is an !12.. Kile in which we list resource na%es or /W ob)ect na%es that were referenced d(na%icall( in
the script'
"a' What are PB4, PB/ fles? How do (ou generate the%?
'PB4 fle is a resource fle that contains B=P fles, icons or ob)ects assigned d(na%icall( in a script such as /W
ob)ects that have been used in our application' ! 'PB/ fle is PB d(na%ic librar(' .t contains all co%piled ob)ects
that the 'PB0 fle has and is linked to the application at runti%e' We generate the% through the Pro)ect options
of PB' .f (ou use 'PB4 fles (ou donAt need to distribute to user separatel( '+[+ fle and resource fles - all these
pictures, for exa%ple, will be included into '+[+ fle' 3o create 'PB4 fle si%pl( na%e the resources in a text fle'
.n it, (ou can reference all these ob)ects b( including the na%e and the path of the 'PB0 and the ob)ect na%e'
PB copies ob)ects referenced in a 'PB4 into the '+[+ fle when the fle is generated' PB/ does not have an( data
source' .t cannot be run alone and %ust be specifed in the librar( search path' !ll 'PB/As %ust be specifed in
the librar( search path'

#' What are advantages of using 'PB/ s ?
PB/ %akes the si>e of (our '+[+ s%aller, and ob)ects that we put in PB/s will be loaded at runti%e onl( when
we need it'
$' What is the diDerence between /00 and PB/?
/00 is a fle we co%pile using %achine code in a #"-bit environ%ent' With /00 fles the s(ste% 5our application6
works faster' PB/ is a fle we co%pile using Pcode' When PB builds a d(na%ic librar(, it copies the co%piled
versions of all ob)ects fro% the source librar( 5PB0 fle6 into d(na%ic librar( 5PB/ fle6'
22
B' How do (ou create a 'PB4 fle?
3hrough an( fle editor or 1hift KC'
C' How do (ou include a /ataWindow in a 'PB4 fle?
3o include a /W in the list we have to write the na%e of the librar( 5with extension 'PB06 and na%e of the
/ataWindow ob)ect enclosed in the parenthesis' Kor exa%ple: 3utorial'pbl5dGe%plist6
.f the /ataWindows librar( is not in the director( that will be current when the '+[+ is built, we have to full(
specif( the full search path of a /ataWindow ob)ect and put the /ataWindow ob)ect na%e in parentheses:
c:;pb;tutorial'pbl5dGe%plist6
E' What is the reco%%ended si>e of 'PB0?
3he reco%%ended si>e is less than LSS VB and not %ore than BS-CS entries' 0arger libraries could decrease the
perfor%ance of the application' Oou should split large libraries'
L' How can (ou create in PB an executable that can receive para%eters?
PowerBuilder has a function 2o%%andPar%5 6 that retrieves the para%eter string, if an(, when the application is
executed' Kor exa%ple:
*pen +vent string lsGco%%andGline
lsGco%%andGline R 2o%%andPar%5 6
.f the co%%and line holds several para%eters, (ou can use string functions Pos56, 0eft56, 4ight56, =id56, etc', to
separate the para%eters'
M' What are /00 fles and how can we access /00 functions fro% PB?
/(na%ic 0ink 0ibrar( is a store of executable code that an executable fle 5+[+6 %a( d(na%icall( link to, in
order to %ake use of its functions' PB libraries %a( be co%piled into /00s to reduce the si>e of the pri%ar( +[+
and allow the ob)ects to be shared with other PB applications' ,ote: unlike standard /00s, PB-generated /00s
%a( not be used fro% applications written in other languages' PB-generated /00s %a( be accessed onl( fro%
PB applications'
"S' What is the diDerence between P-2ode and =achine code?
=achine code is new and was introduced in PBB' P-code is co%piled faster than the %achine code but it creates
'PB/s' =achine code creates /00s
PB uses P-code'
"' What t(pe of resources can we list in 'PB4 fle?
Bit%aps, icons, cursors, sound wave fles, etc'Hall fles that are not PB fles'
""' What does the '+[+ fle contain?
3he executable fle contains code that application need to run a Windows application, co%piled versions of
applicationAs ob)ects and resources that application uses'

"#' .s it alwa(s necessar( to create the PB4 Kile to include resources in (our +[+?
,o, if resources were assigned in a painter the( are auto%aticall( copied in (our +[+ but if the( were
referenced d(na%icall( through the string variables, PB cannot identif( the% when co%piling, and we have to
include the% into PB4 fle or distribute the% separatel('

"$' Where can we create '+[+? We can create '+[+ in the Pro)ect Painter'
"B' What is the %ini%u% that (ou %ust deliver for a PB application?
5pick all6
- '+[+
- PB/
- 'PB4
- '/00
- resource fle
- PB'.,.
3he PB'+[+ %ust be on the client %achine - true
.f (ou have bit%aps or icons in (our app', (ou %ust have a resource fle - false
"C' What do (ou need to do to distribute (our application to the end-user?
3he '+[+, an( 'PB/s, and the /B /evelop%ent and /eplo(%ent Vit /00s'
5We need to create an executable fle 5'+[+6 of our application for distribution to users' 3o do so, we can choose
fro% several options' 3wo of the options are:
(ou can incorporate all of the PB ob)ects, all bit%aps, all icons, etc' into one executable fle' 5JariationH
incorporate all of the PB ob)ects into the '+[+, and distribute it with separate fles containing the bit%aps, icons,
etc'6 !dditional options are: (ou can incorporate so%e of the PB ob)ects and all of the bit%aps, icons, etc' into
the '+[+ fle, but place the re%aining PB ob)ects in PB d(na%ic libraries 5'PB/6' 5Jariation: incorporate so%e of
the PB ob)ects into the '+[+9 place the re%aining PB ob)ects in 'PB/s9 and distribute the '+[+ and 'PB/s with
separate fles containing the bit%aps, icons, etc' When distributing (our applications, (ou %ust also distribute
the PB runti%e libraries 5'/00s6'6
23
K@,23.*,
' What is a function?
! function is a pre-defned procedure that perfor%s a specifc task' ! function is a set of so%e t(pe Power1cript
state%ents that perfor%s so%e t(pe of processing and return a value' Kunctions have two defning
characteristics :
all functions return a value
all functions have a return t(pe, i'e', the data t(pe of the value that the function returns'
"' What is the diDerence between a function and a subroutine?
1ubroutines do not return a values, and thus, the( do not have a return t(pe'
1ubroutine is a set of so%e t(pe Power1cript state%ents that perfor%s so%e t(pe of processing'
#' What can (ou do with the return value fro% a function?
$' /escribe how ob)ect-level and global functions are stored'
Xlobal functions are stored in 'PB0 as independent ob)ects, not encapsulated within so%e other ob)ect'
*b)ect-level functions are encapsulated within the ob)ect for which the( are defned'
B' Which does Power1cript state%ent appear at least once in ever( function? Wh( ?
4eturn state%ent' Because ever( function returns a value, our code %ust include the 4eturn state%ent'
C' .f the state%ent :return ]2o%pleteA< appears in the code for a function, what conclusion can (ou draw about
the function declaration?
3he data t(pe of the value that the function returns is 1tring'
E' What is the diDerence between call b( reference and call b( value?
B( reference %eans that the function has access to the value of original variable and can change it directl('
B( value %eans that no %atter what happens to variable in the function the value will be the sa%e'
B( reference %eans that receiving para%eters get the address5%e%or( location of the variable instead of
value' 3his %eans when an( new is assign to the para%eters value, the value of original variable is changed'
When we pass b( value, we are passing the function a te%porar( local cop( of the argu%ent' 3he function can
alter the value of the local cop( within the function, but the value of the argu%ent is not changed in the calling
script for function'
L' +xplain Kunction access t(pes'
3here are three function access t(pes:
Public - lets the function be referenced externall( using dot 5'6 notation
Private - restricts access to scripts within the ob)ect'
Protected - restricts access to scripts within the ob)ect or within ob)ects inherited fro% this ob)ect'
' What is the diDerence between private, protected U public functions?
Private function (ou can onl( call in scripts for events in the ob)ect, in which the function was defned'
Protected function (ou can call in scripts for events in the ob)ect in which the function was defned and its
descendant'
Public functions (ou can call in an( place in the ob)ect
"' What is a user-defned function?
@ser-defned function is the collection of Pscript state%ents that perfor% so%e processing'
#' What kind of user-defned function do (ou know?
Xlobal - that are accessible an(where in the application *b)ect level which are defned for the particular t(pe of
window %enu or user ob)ect' 3hese function %a( be accessible to other scripts or %a( be not'

$' How do (ou have to defne the access for ob)ect level function if (ou want to %ake it accessible for scripts
for other ob)ect?
.t has to be defned as Public
B' What is the diDerence between Private and Protected *b)ect level functions?
Private function (ou can onl( call in scripts for events in the ob)ect, in which the function was defned'
Protected function (ou can call in scripts for events in the ob)ect in which the function was defned and its
descendant'
C' .f function return the value what state%ent inside function do (ou have to use to assign value?
We have to use 4eturn 1tate%ent and when we defne a function we have to defne the data t(pe of returned
value'
E' How could (ou pass argu%ent to the function?
We can pass arg' B( value and b( reference When we pass b( value we are passing to the function a te%porar(
local cop( of the argu%ent and the value of argu%ent in the calling script is not changed .f we pass b(
reference the function has access to the original argu%ent and can change it directl('
How do (ou look up functions for controls 5for exa%ple, 0istbox6
24
.n the Help topic'
M' Oou need to process an arra( in a loop' Which function should (ou use if (ou donAt know arra(As si>e 5i'e'
nu%ber of arra( ele%ents6?
@pperBound56
"S' What is the purpose of Oield function?
Oields control to other graphic ob)ects, including ob)ects that are not PowerBuilder ob)ects' Oield checks the
%essage queue and if there are %essages in the queue, it pulls the% fro% the queue
.nclude Oield within a loop so that other processes can happen' Kor exa%ple, use Oield to allow end users to
interrupt a loop' B( (ielding control, (ou allow the user ti%e to click on a cancel button in another window' 3hen
code in the loop can check whether a global variable&s status has changed' Oou can also use Oield in a loop in
which (ou are waiting for so%ething to fnish so that other processing can take place, in either (our or so%e
other application'
@sing other applications while retrieving data !lthough the user cannot do other activities in a PowerBuilder
application while retrieving data, (ou can allow the% to use other applications on their s(ste%' Put Oield in the
4etrieve4ow event so that other applications can run during the retrieval'
*f course, Oield will %ake (our PowerBuilder application run slower because processing ti%e will be shared with
other applications'
"' ! function %ust be defned in the Kunction painter in order to be public? Kalse
B' What is the diDerence between 3rigger+vent and Post+vent?
3rigger+vent56 stops the progra% and lets the progra% continue after it fnishes'
Post+vent56 stands in a queue and executes at the sa%e ti%e with the script' *ne diDerence between these
events is ti%ing' Postevent puts a custo% window %essage at the back of the stack where it awaits its turn'
3rigger+vent56 progra%-%aticall( causes code to be executed before the next %essage is processed' Kor
exa%ple: cbG*V'3rigger+vent52licked?6
C' What is the diDerence between call b( reference and call b( value?
2alling b( reference is a two-wa( argu%ent passing: changes that the function %akes to the argu%ent value are
passed back to the caller'
2alling b( value is a one-wa( argu%ent passing: the calling script passes a cop( of the argu%ent value into the
function' 2hanges that the function %akes to the argu%ent value are not passed back to the caller'
25
What is PowerBuilder?
PowerBuilder is a powerful Windows-based professional clientIserver application develop%ent tool, which allows
tea%s of developers to quickl( and easil( build sophisticated, graphical applications with access to database
infor%ation stored locall( or on networked servers'
What are PowerBuilder features?
! set of tools, known as painters, that provide a graphical point-and-click environ%ent for creating windows,
%enus, and other ob)ects and for database ad%inistration'
! powerful scripting language, Power1cript, for building event-driven applications'
1upport for all =icrosoft Windows ob)ects and Jisual Basic custo% controls'
! custo% Windows ob)ect, the /ataWindow ob)ect, for database %anipulation and reporting'
*pen integration with confguration control tools, such as PJ21'
1upport for /(na%ic /ata +xchange5//+6, /(na%ic 0ink 0ibraries5/006,
and *b)ect 0inking and +%bedding5*0+6'
1upport for i%porting and exporting popular fle for%ats'
+xtensive on-line help'
#' What are PowerBuilder benefts?
PowerBuilder allows an application developer to:
- Fuickl( develop ob)ect-based windows database applications without coding in 2 or 2cc'
- 3ake advantage of clientIserver architecture'
- 2reate attractive, eas(-to-use applications taking full advantage of Xraphic @ser .nterface 5X@.6 5X@.6 design
principles'
- 2reate applications that can be independent of the database %anage%ent s(ste% being used'
$' What is the strongest and weakest points of PowerBuilder?
1trongest :
/ataWindow'
.nheritance
+ncapsulation
Pol(%orphis%
Weakest :
Bad perfor%ance
,ot full( *b)ect-*riented'
B' What are PowerBuilder applications?
PowerBuilder applications are ob)ect-oriented, event-driven applications that execute within Windows, t(picall(
within a clientIserver architecture'
C' What are Windows?
Windows is an operating environ%ent that uses graphics and s(%bols as a Xraphic @ser .nterface 5X@.6
between the user and the operating s(ste%' 3his interface enables (ou to select and execute co%%ands b(
using a %ouse to point to and click on illustrations, s(%bols 5icons6, or data'
E' What is a %enu bar?
3o navigate in Windows, (ou can also select options or activities fro% a %enu bar that run across the top of the
window' 3his %enu bar contains ite%s such as Kile, +dit, Help' B( clicking on the ite% on the %enu bar, (ou
access pull-down %enus that list %ore options or co%%ands for an activit('
L' What is +vent-driven processing?
.n a PB application, the user is responsible for the sequence of processing that takes place, not the
progra%%er' 3he processing is dependent on the action that the user takes5:event-driven<6' Processing can be
associated with the application, a window, or ob)ects in a window'
M' What is *b)ect-oriented develop%ent?
*b)ect-oriented develop%ent views the anal(sis, design, and i%ple%entation of s(ste%s fro% the perspective
of ob)ects, which have specifc collections of attributes and events'
S' What is ob)ect?
*b)ect is an application co%ponent that co%bine characteristics and behaviors' 3he characteristics are called
attributes' 3he behaviors are called events' Well-designed ob)ect is discrete, self-contained package' *ften it
knows nothing about other ob)ect except its na%e' *b)ects co%%unicate with one another through %essages'
PB applications are developed b( co%bining ob)ects of the following t(pes:
!pplication
Window
/ataWindow
Kunction
=enu
Fuer(
1tructure
@ser *b)ect
' What are attributes?
26
!ttributes are characteristics of ob)ects' 3he co%bination of an ob)ectAs attributes pri%aril( defnes what the
ob)ect looks like, but so%e attributes also prescribe or li%it its behavior'
"' What is an event?
!n event is the co%ponent of an ob)ect that per%its it to recogni>e and respond to a Windows %essage' .n PB
(ou write scripts, as needed, to describe the processing that should occur in response to the %essage' +vents
often for% the connection between the ob)ects in an application s(ste%'
#' What is an application ob)ect?
!n application ob)ect is an entr( point into an organi>ed collection of windows and other ob)ects that perfor%
these activities' .t is a non-visual ob)ect that %aintains default values for various high-level characteristics or
features of the application'
$' What are window ob)ects?
Window ob)ects are visual ob)ects that provide the %ain interface between the user and PB applications'
Windows can displa( infor%ation, request it fro% a user, and respond to %ouse or ke(board actions'
2ontrols are ob)ects that (ou place in a window to allow the user to interact with the application' Oou use
diDerent controls for diDerent purposes' Kor exa%ple, so%e controls %a( displa( data, others accept and
validate user input, and still others act upon input, such as responding to a %ouse click'
B' What is a %enu?
! =enu is a visual ob)ect that provides the user with lists of co%%ands, or alternate wa(s of perfor%ing a task'
3he individual co%%ands or options are known as %enuite%s'
C' What is a /ataWindow ob)ect?
! /ataWindow ob)ect is an intelligent ob)ect unique to PB, co%bining data access intelligence with an user
interface' Oou %a( use /ataWindow ob)ects whenever (our applications need to displa( or capture data'
E' What is a quer(?
! quer( is a non-visual ob)ect consisting of a 1F0 state%ent that (ou associate with a /W ob)ect to indicate its
data source' Fueries enhance developer productivit(, since the( can be coded once but reused as often as
necessar(' 3hus, the( provide Nexibilit( in the develop%ent of /W ob)ects'
L' What are user ob)ects?
@ser ob)ects are custo% ob)ects that (ou build' 3he( t(picall( consist of one or %ore standard PB ob)ects, with
scripts written for particular events to perfor% processing used frequentl( in (our applications' !fter (ou build
an @*, (ou can use it in (our applications as (ou would an( PB ob)ect' 3he processing encapsulated in user
ob)ects is often generic9 thus when (ou use the @* in an application, (ou %ake its processing specifc to the
application b( %odif(ing or extending the scripts for the events in the @*' @ser ob)ects can be visual or non-
visual' 3he( can displa( infor%ation, request it fro% an user, and respond to %ouse or ke(board actions' 3he(
extend, enhance, or otherwise custo%i>e standard built-in ob)ects and their behaviors'
M' What is a function?
! function consist of a set of Power1cript state%ents that perfor%s so%e t(pe of processing and returns a
value' 3here are two t(pes of functions within PB:
*b)ect-level functions
Xlobal functions, that is, function ob)ects
*b)ect-level functions, such as a window function, are encapsulated within the ob)ect for which the( are defned'
Xlobal functions are independent ob)ects, the( are not encapsulated within so%e other ob)ect'
Both t(pes of functions %a( be called fro% scripts for an( other ob)ect in an application, however, the( are
called in diDerent wa(s'
"S' What is a structure?
! structure is a collection of one or %ore related variables of the sa%e or diDerent data t(pes grouped under
one na%e' @sed in scripts, structures allow (ou to refer to related ob)ects as an unit rather than individuall(' .n
so%e languages, for exa%ple Pascal or 2*B*0, structures are called records'
"' What is a painter?
! painter is a graphical tool within PB that (ou use to create a PB ob)ects'
""' How can (ou confgure (our toolbar?
Oou %a( confgure (our PainterBar and the PowerBar in several wa(s:
2hoose 3oolbars''' fro% the Window %enu9 the 3oolbars response window appears'
2lick the right %ouse button on the toolbar to displa( the popup %enu of options'
Both %ethods provide the sa%e options'
"#' Where are PB ob)ects stored?
PB ob)ects are stored in PB librar( fles 5'PB06'
"$' Which of the following can be P@B0.2?
-function -Oes
-script
-instance variable
-window
27
-application
PowerBuilder
"B' Wh( is PowerBuilder a clientIserver application develop%ent tool ?
Because PowerBuilder !pplications request services fro% a server /atabase through 1F0 state%ents'

"C' What is event-driven processing ?
3he user is responsible for the sequence of processing that takes place, not the progra%%er' 3he processing is
dependent on the action that the user takes 5:event-driven<6
"E' What is *b)ect-*riented?
Oou can sa( that the progra%%ing language is ob)ect-oriented if it has # %ain features:
.nheritance'
+ncapsulation'
Pol(%orphis%'
PowerBuilder has all of these features'
.t speeds up the develop%ent process and i%proves code qualit( and e\cienc('
#'What two qualities do all ob)ects have?
!ttributes are the characteristics of ob)ects, which collectivel( defne an ob)ectAs appearance'
+vents are the co%ponents of an ob)ect that per%it it to recogni>e and respond to a Windows %essage'
$'0ist at least four of the eight PowerBuilder ob)ects'
!pplication ob)ect
Fueries
Windows
@ser ob)ects
=enus
Kunctions
/ataWindow ob)ects
1tructures
What is a painter ?
! painter is a graphical tool within PB that we use to create a PB ob)ect'
C' What is the Power Panel? What is Power Bar?
3he( are a collection of icons through which we have an access to a painter'
E' Where are all PowerBuilder ob)ects stored?
PowerBuilder ob)ects are stored in PowerBuilder librar( fles' =an( diDerent ob)ects %a( be stored in the sa%e
librar('
L' What is 2lientI1erver architecture?
2lientI1erver architecture is when an application requests services fro% a server /B through 1F0 state%ents'
/B can be located an(where once the data requested has been passed to the client processing takes place at
the client level' 3he data available to %an( users but processing takes place locall('
M' Where in PowerBuilder can (ou do interactive 1F0?
-database painter in data %anipulation
-/ataWindow painter
-quer( painter
-script
P!43
.s PowerBuilder an ob)ect-oriented language? Wh(?
Oes' Oou can sa( that a progra%%ing language is ob)ect-oriented if it has # %ain features:
.nheritance'
+ncapsulation'
Pol(%orphis%'
PowerBuilder has all of these features' PB is a 2lientI1erver application develop%ent tool, which allows us to
build a new graphical appl' with access to the /B that could be stored locall( or at network s(ste%'
+=B+//+/ 1F0
How do we refer to the PB variables inside 1F0 state%ents?
We have to precede the% b( colon, for exa%ple: .nsert into +%plo(ee 5salar(6 Jalues 5:salGvar6

"' How do we use 1+0+23 state%ent in PB?
.f we expect onl( one row to in our 4esult 1et, we use single 1+0+23, for exa%ple:
1elect e%plo(ee +%pGl,a%e, e%plo(ee +=PGK,!=+
28
into :sleG0,!=+'text, sleGK,!=+'text
fro% +%plo(ee
where +%plo(ee +=P GnbpR:+%pGnu%
.f we expect %ultiple rows we use cursor state%ents' /eclare cursor as a select state%ent, then *P+, the
2ursor and then fetch rows5with fetch state%ent6' @suall( we do fetching
in the 0**P while 1X02!'1F02*/+RS
29
.,H+4.3!,2+
' What is inheritance?
.nheritance is the abilit( to defne a new classes fro% existing ones' .nheritance lets the developer derive
5%ake6 a new class 5ob)ect t(pe 6fro% existing base class' .t enables (ou to build windows, user ob)ects, and
%enus that are derived 5%ade6 fro% existing ob)ects' /escendant inherits all of the co%ponents of the ancestor'
.t includes attributes, variables, structures, functions, events and scripts'
"' What is the beneft of inheritance?
.nheritance ensures consistenc( in the code and look of ob)ects and helps initial coding'
#' What is 1@P+4 ke(word and how it is used?
PB has $ special ke(words used to refer to an ob)ect without having to specif( its na%e:
3hisHused for a reNexive reference to the ob)ect itself 5window, control or user ob)ect6
ParentHrefers to the window that owns or contain the ob)ect %aking the reference
ParentWindowHreference fro% a %enu ite% referring to the window to which is attach
1uperHrefers to the ancestor script
' 3his is equivalent to the following %ore verbose 51(n' using %ore words6 call 5assu%ing the na%e of the
ancestor is wGancestor,
2all wGancestor cbGcalculate::clicked
3his calls the script in the clicked event in the i%%ediate ancestor of the cbGcalculate
2all super :: 2licked
$' When we change an attribute in an inherited control, we break the connection to the parent for that attribute
onl(' -- 34@+
B' Which PowerBuilder ob)ects can be inherited?
=+,@19 @1+4 *BZ+2319 W.,/*W1
C' Xive an exa%ple of how (ou would use inheritance in (our pro)ect?
. used the base 5class6 librar( to inherit it for all %( application ob)ects in order to increase the develop%ent
process'
! standard co%pan( logon window that requires %ini%al changes'
E' How can (ou custo%i>e a descendant?
We can change the values of attributes and variables, extendIoverride the script, add controls, reference an
ancestorAs functions, events, or structures, or declare variables, events, functions and structures for the
descendant'
L' 2an (ou delete a =enu.te% in the descendant %enu if it was created in the ancestor one?
We cannot delete a =enu.te% in the descendant %enu if it was created in the ancestor one but we can %ake it
disabled and invisible'
M' What happens when (ou change the ancestor?
3he changes appl( to the all descendants'
S' What can (ou do with ancestor scripts?
We can *verride or +xtend the ancestor script at the descendant level' We can also call it fro% the descendant
script'
' 0etAs sa(, (ou developed a window wGcusto%ers' !fter so%e ti%e (ou developed a base ancestor window
wGbaseGwin and want to use all functionalit( that (ou put in this ancestor in (our wGcusto%ers window' How can
(ou do this?
B( exporting wGcusto%ers, editing the exported fle and i%porting it back'
"' How %an( levels of inheritance do (ou usuall( use?
. tr( not to use %ore than # levels, because %( opinion is that each extra level decreases the perfor%ance and
%akes the code %ore di\cult to read, but Powersoft sa(s that with PBB, if we use the right structure of
inheritance, it will increase the perfor%ance'
#' How can (ou call an ancestor script fro% a descendant ob)ect? 5see pronouns6
3here is 2!00 co%%and that calls an ancestor script fro% a script for a descendant ob)ect' Kor exa%ple, 2!00
wGe%p :: *pen
2!00 wGe%p'cbGclose :: 2licked
We can also use the word 1@P+4 to refer to the i%%ediate ancestor 5parent6' Kor exa%ple, to call the parentAs
2licked script: 2!00 1@PP+4 :: 20.2V+/
Oou can na%e directl( the ancestor in the call or use the reserved word 1@P+4
2all 1uper :: 2licked
$' How can (ou override ancestor script at descendent level with no script in descendant?
Put co%%ents II
B' How can (ou custo%ise a /escendant?
*verride or extend script, add controls, change value of attributes and variables'
30
C' How can (ou change an ob)ectAs ancestor without recording it?
+xport the descendant, edit it 5changing the na%e of the ancestor6 and i%port it back'
E' 2an (ou inherit a /ataWindow?
We cannot do it directl(, but we can create a standard @ser*b)ect of /ataWindow t(pe 5which can be inherited6
and use it instead of /ataWindow controls' Oou use the sa%e %ethod when (ou need to inherit an( control'
What is the diDerence between inheriting and cop(ing an ob)ect?
When (ou change the ancestor ob)ect the changes are reNected in all the descendants'
When cop(ing, (ou have to %anuall( %ake changes' .n cop(ing (ou can delete or add the sa%e control fro%
the window' .n descendant (ou cannot delete control )ust can %ake it nonvisible'
P'1' 2hanges to an attribute in the ancestor aDect onl( the descendant on which that attribute has not been
changed' WH+, O*@ 2H!,X+ !334.B@3+ ., !, .,H+4.3+/ 2*,34*0, O*@ B4+!V 3H+ 2*,,+23.*, 3* 3H+
P!4+,3 K*4 3H!3 !334.B@3+ *,0O' 3o re-establish the link to the parent (ou can click on the control and choose
+ditI4eset !ttribute
M' How can (ou execute ancestor script fro% the descendant?
2!00 calls an ancestor script fro% a script for a descendent ob)ect' 2all 1uper::2licked 5execute the script on the
clicked event in ancestor6' Oou can call scripts for events in an ancestor of the user ob)ect, %enu, or window' Oou
can also call scripts for events for controls in an ancestor of the user ob)ect or window' 3he following state%ent
calls a script for an event in an ancestor window'
2!00 wGe%p::*pen
3he following state%ent calls a script for an event in a control in an ancestor window'
2!00 wGe%pdcbGclose::2licked
.n so%e circu%stances, (ou can use the 1uper reserved word when ancestor ob)ect is the descendant ob)ect&s
i%%ediate ancestor'

"S' How (ou can call function in ancestor fro% descendant?
wGparent::functionna%e5arg6
.f the descendant has a function with the sa%e na%e
1upper:: wfGfunctionna%e5 6
Oou can call function fro% the descendant: )ust put the function na%e and give it the argu%ents' 3he onl(
exception is if another function in the descendant window has been na%ed exactl( the sa%e as the ancestor
window function' .n this case calling this na%e would call the descendant windowAs function, not the ancestor'
3he solution to this proble% depends on where (ou are %aking the call fro%' .f (ou are calling the ancestor
function fro% the window script 5open or other event6 (ou can:
wGparent::functionna%e5arg6
.f (ou are calling the function fro% within a control or user ob)ect event, (ou %ust create a new descendant
window function that does nothing but %ake a qualifed call to the ancestor window function 5as previousl(6'
3hen (ou call the new descendant window function fro% within the control or user ob)ect'
"' Oou are working with inherited windows, and (our application does not work or produces a%biguous errors'
Oou are tracing the progra% though the /+B@XX+4, and still - nothing' What can (ou do next?
""' Which of the following can be inherited? 5pick all6
-window -O
-data window - O
-application
-function
-quer(
-script
-user ob)ect -O
"#' Oou can create, delete and change controls in a descendent? Kalse
"$' ! descendant can onl( have one ancestor? Kalse
"B' What is 1@P+4 ke(word and how it is used?
1@P+4 is a ke(word used to %ake a reference to an ob)ect without having to specif( its na%e: When (ou write a
script for a descendant ob)ect or control, (ou can call scripts written for an( ancestor' Oou can directl( na%e the
ancestor in the call, or (ou can use the reserved word 1uper to refer to the i%%ediate ancestor 5parent6' .f (ou
are calling an ancestor function, (ou onl( need to use 1uper if the descendant has a function with the sa%e
na%e and the sa%e argu%ents as the ancestor function' *therwise, (ou would si%pl( call the function with no
qualifers'Oou can onl( use 1uper in an event or function associated with a direct descend-ant of the ancestor
whose function is being called'
31
.,13!,3.!3.*,
' How do (ou instantiate one window fro% another?
+ver( ob)ect belongs to an ob)ect class and is called an instance of the class' +ver( window ob)ect, for exa%ple,
is an instance of the :window< class' Oou can think of the ob)ect class as the :protot(pe< or :%odel< for the
ob)ect' When (ou develop a PB appli-cation, (ou design its ob)ect classes' When (ou run the application, the
ob)ect instances co%e into existence' 3he process of creating an ob)ect fro% an ob)ect class is called
instantiation' .nstantiation alwa(s occurs at runti%e' Kor visual ob)ects, instantiation t(picall( occurs 3he
ob)ects (ou declare are the%selves a data t(pe' 3hese kinds of data t(pes are called instance of an ob)ect'
.nstantiation creates an instance of the sa%e ob)ect in %e%or('
We have to declare a window ob)ect as a datat(pe and open it'
wG%ain wG%ain, wG%ain"
*P+,5wG%ain6
*P+,5wG%ain"6
"' What do (ou need .nstantiation in (our application for?
When we want to displa( several windows that are identical in structure but have diDerent data values'
#' Xive a defnition of an instance of a window?
.nstance is a cop( of a window in %e%or(' =ore than one instance of the sa%e window ob)ect can be created in
%e%or('
$' How can (ou create instances of the sa%e window ob)ect?
/eclare a variable of t(pe wGna%e :
wGna%e wG%(Gwindow
3o create an instance we use function open5 6
open5wG%(Gwindow6
We can create an arra( of instances of the window' 1aving a window in the Window painter saves the defnition
of the window and the defnition beco%es a class 5a new data t(pe6 with the sa%e na%e as the window' 3o
create an arra( of instances of a window, declare an arra( of the data t(pe of the window' Kor exa%ple:
wGe%plo(eeGaddress wGeaGinstPBQ
3ip: We usuall( create %ultiple instances of a pop-up or child window rather than a %ain window' *r we can
create an instance of a window in the local script with a local variable of datat(pe of this window and call this
script each ti%e we need to create a new instance of the window'
/ownside: We will not be able to call these windows b( na%e: the handle to the window created this wa( is lost
as soon as the script ends'
B' What the diDerence between 2lass and .nstance?
2lass is in data storage 5hard drive6' .nstance is in %e%or(' .nstantiation is a process of creating of instance of
an ob)ect fro% a class'
32
=/.
' What is an =/. application ?
=/. application is a fra%e used to %anage %ultiple docu%ents of the sa%e or diDerent t(pes within one'
"' What is =icrohelp? Where do (ou defne it?
=icrohelp is additional info about a =enu.te% which is used to help the user understand what the =enu.te%
does' We defne the =icrohelp text in the =enu painter as part of the process of creating the =enu' .t onl(
displa(s if the fra%e window of the application is of the t(pe =/. Kra%e with =icrohelp'
#' Where do all =enus in an =/. application displa(?
!ll =enus, displa( in the %enu bar of the fra%e window'
$' Which %enu applies to an open sheet of a docu%ent t(pe that has been
defned without its own =enu?
When a sheet without a =enu is opened, it uses the current =enu, that is, the =enu that was current when the
sheet was opened'
B' What are the parts of =/. fra%e?
3itleBar
=enuBar
3oolBar
2lient !rea
1tatus !rea
Kra%e Window
B' What is an =/. fra%e?
=/. stands for =ultiple /ocu%ent .nterface' =/. window is a fra%e window in which we can open =ultiple
/ocu%ents Windows 5sheets6 and %ove around the sheets' !n =/. fra%e is a window whose %ain purpose is to
be a container for child windows, called sheets'
C' What t(pes of an =/. fra%e do (ou know?
3here are " t(pes of an =/. fra%e windows: =/. fra%e and =/. fra%e with %icro help'
E' What is the diDerence between 1/. and =/. fra%e?
=/. allows the user to work with %ore than one docu%ent at a ti%e'
1/. allows to work with onl( one docu%ent'
L'What is the diDerence between =/. fra%e and =/. fra%e with %icro help?
=/. fra%e doesnAt have %icrohelp utilit('
=/. fra%e with %icro help has the %icrohelp on the botto% of the window'
M' What is a =/.G ob)ect? 2an we place an( controls on =/.G?
=/.G is a client area or workspace within the fra%e between the toolbar or %enu and status area 5%icrohelp6
in which open sheet is displa(ed' When we create and save an =/. fra%e, PB auto%aticall( creates a control
called =/.G' PB uses =/.G to identif( the client area, the area that holds sheets' We can place an( controls
on =/.G' We have to count the height, the width of a control and extract the% fro% the client area'
S' /oes =/.G have events? What are the(?
,*' .t does not have an( events'
' .s it a good idea to use 2loseFuer( +vent in =/. window?
Oes' .t is a good idea to send a %essage to the user about to exit fro% the application'
Kor exa%ple:
=essageBox5:Fuestion?<, <!re (ou sure (ou want to exit fro% the application?<6
"' How do (ou check if there are an( =/. 1heets currentl( existing?
.sJalid 5wGna%e6 deter%ines whether the window is open
#' Oou have an =/. Window, 1heet with =enu and 1heet " without the =enu' Oou open 1heet " after 1heet
' Which =enu will have 1heet " =/. =enu or 1heet =enu?
.t will have the =enu of 1heet as the last =enu that was displa(ed on the =/. window'
! sheet can have its own %enu, but its not required to'
$' How do the !pplication co%ponents co%%unicate with one another?
/irect access or %anipulation b( calling a function, trigger or posting an event using global variables, passing
para%eters'
B' How do we send para%eters between two alread( opened windows?
global variables9
shared variables9
send para%eters b( =essage*b)ect using function 1end5 6
C' How can two sheets within =/. fra%e co%%unicate with one another?
33
Xlobal variable
1hared variable
=essage ob)ect
=/. !pplications

E' What is =/.?
=/. is an application st(le that we use to open %ultiple windows 5sheets6 in single window and %ove a%ong the
sheets' @suall( =/. has a %enu bar client area and 1tatus area 5if it is =/. with =icrohelp6

L' What functions do we usuall( use working with =/.?
*pen1heet56 - to open sheets inside the =/. fra%e Xet!ctive1heet56 to keep track which sheet is active now,
!rrange1heet56 to arrange sheetAs la(out'
M' How can we displa( infor%ation to the users in the status area?
We can associate %icrohelp with the control defning its 3ag attribute and then we will use 1et=icroHelp56
function to displa( this tag attribute'

"S' How can we displa( toolbar picture under the =enu.te%?
We have to associate a toolbar picture with =enu.te% in the =enu Painter'
"#' How do (ou use *pen1heetWithPar%?
5*pens a sheet within an =/. fra%e window and creates a %enu ite% for selecting the sheet on the specifed
%enu, as *pen1heet does' *pen1heetWithPar% also stores a para%eter in the s(ste%&s =essage ob)ect so that
it is accessible to the opened sheet'6
!pplies to Window ob)ects' 1(ntax:
*pen1heetWithPar% 5 sheetrefvar, para%eter 7, windowt(pe 8, %difra%e 7, position 7, arrangeopen 8 8 6
+xa%ple:
*pen1heetWithPar%5wGchildG, ^=!^, =/.G@ser, ", *riginal?6
34
=+,@
' What is purpose of a =enu ob)ect?
! =enu ob)ect is a visual ob)ect that provides the user with lists of co%%ands, options, or alternate wa(s of
perfor%ing a task'
"' What t(pes of =enus do (ou know ?
/rop/own
2ascading
Pop-up
#' What is the diDerence between the 2licked and 1elected event of a =enu.te%?
3he 2licked event occurs when the user clicks the %ouse on the =enu.te% or selects the =enu.te% with a
ke(stroke and presses +nter'
3he 1elected event occurs when a user uses the arrow ke(s to %ove to a =enu.te% or %oves the %ouse pointer
to the ite% and holds the button down'
$' 5fll in the blank6 3he ellipsis 5_6 is used after a =enu.te% to indicate that a window will appear requesting
%ore infor%ation before the co%%and can be executed'
B' 5fll in the blank63he underlined character is used before a letter in the text of a =enu.te% to assign the letter
as an accelerator ke( for the =enu.te%'
C' What is the diDerence between an accelerator ke( and a shortcut ke( in the wa( a user uses the% to initiate
a co%%and or select an option on a =enu ?
!ccelerator ke(s and shortcut ke(s provide alternative %eans of invoking co%%ands or selecting options
represented b( the =enu.te%s to which the( are assigned'
! shortcut ke( is a single ke(stroke or a co%bination of ke(strokes 52trl c , or K6 annotated to the right of
=enu.te%' !n !ccelerator ke( underlines a character in the =enu or =enu.te%' When the !ccelerator ke( is in a
=enu on the =enu bar, the user %a( press !lt c character to select the =enu'
E' What kind of %enus do (ou use?
! /rop/own %enu is a %enu under an ite% in the %enu bar
2ascading %enu is a %enu to the side of an ite% in a /rop/own %enu'
Pop-up %enu is not connected with a %enu bar'

L' What attribute of the =enu.te% do (ou know?
2hecked' Whether the =enu.te% displa(s with a check %ark next to it'
+nabled' Whether the =enu.te% can be selected'
$' How do (ou use %enus in the window?
We can associate a %enu with a window in the window st(le window or displa( a pop-up %enu in the window
using the Pop-up =enu function'
35
=+11!X+ *BZ+23
' What is the =essage ob)ect' How do (ou use it? Wh( do (ou use it?
*b)ects work with one another b( sending %essages' ! %essage is a subroutine call directed at an ob)ect'
+ver( ob)ect has a predefned set of subroutines 5in PB %ethods6 that (ou can call to send %essages to the
ob)ect'
*b)ect'=ethod 5para%eters6
.n PB, there are three t(pes of %essages:
, "' Kunctions U events which are collectivel( called :%ethods<9
#' Properties'
.n PB, ever( ob)ect has a set of functions, events and properties for receiving %essages' PB also has functions
that are not directed to an ob)ect, such as a =essageBox'
=essageBox5:Hello<, :How are (ou?<6
Kor the transaction ob)ect, (ou do not use the ob)ect'function s(ntax' .nstead, (ou use standard 1F0 s(ntax' !
=essage ob)ect is a PowerBuilder-defned global ob)ect' When we use functions *penWithPar%5 6,
*pen1heetWithPar%5 6, 2loseWith4eturn5 6 5for response window onl(6 specifed para%eters will be passed
through the =essage*b)ect' We can use this =essage ob)ect to store a para%eter when opening or closing a
window'
"' How do (ou use *pen1heetWithPar%5 6?
We use function *pen1heetWithPar%5 6 to pass para%eters between two Windows 5sheets6 in 5=/.6 application
using =essage *b)ectAs attributes 1tringPar%, /oublePar% or Power*b)ectPar%, depending on the variable
datat(pe' 3he Para%eters will be stored in =essage*b)ect' *pen1heetWithPar%5 6 stores the para%eter in the
s(ste%&s =essage ob)ect so that it is accessible to the opened sheet' We use *penWithPar%5 6 to open a
window that is not an =/. sheet and pass infor%ation to the window' We use the *pen1heetWithPar%5 6
function to open =/. sheets when we need to pass infor%ation to the sheet that is being opened or use the
infor%ation to open the sheet'
#' 1tate brieN( and in general ter%s when (ou would use each of the following functions' Be sure (our answer
reNects the diDerence between the two functions'
*penWithPar%5 6
*pen1heetWithPar%5 6
$' 5true or false6 3he *pen56 and *penWithPar%56 are onl( used in 51/.6 applications'
B' !ssu%e (ou are coding the script for the *pen event of a window to which a nu%ber has been passed' 2ode
the state%ent that tests whether the value is greater than SS'
C' 2an a =essage ob)ect Pass Para%eters?
Oes, using 1end 56 co%%and
E' What functions can (ou use to pass para%eters between the Windows in PB?
*penWithPar%5 6
*pen1heetWithPar%5 6
2loseWith4eturn5 6
L' How do *penWithPar%56 and 2loseWith4eturn56 functions pass para%eters?
@sing =essage *b)ectAs attributes 1tringPar%, /oublePar%, Power*b)ectPar% depending on a variable
datat(pe' *penWithPar%5 6 also stores a para%eter in the s(ste%As =essage ob)ect so that it is accessible to
the opened window' 2loses a window and stores a return value in the =essage ob)ect' @se 2loseWith4eturn56
onl( for response windows'
M' What is the usage for 1tringPar%, /oublePar% and Power*b)ectPar% attributes of =essage *b)ect?
S' What attribute in the =essage *b)ect do we have to use if we want to store a 1tructure in it?
We have to use the Power*b)ectPar% attribute'
' What is the =essage *b)ect?
.t is a PB 1(ste% ob)ect that is used to co%%unicate para%eters between windows' When we *pen and 2lose
the% and in 3rigger+vent and Post+vent functions'
"' What attributes of 1(ste% *b)ect do (ou use to pass para%eters windows?
/oublePar% for nu%eric para%eters, 1tringPar% for strings and Power*b)ectPar% for an( PB ob)ects including
structure'
#' What function do (ou use to co%%unicate para%eters between windows?
*penWithPar% and 2loseWith4eturn power script function'
$' How can (ou handle +rror =essages 5exa%ples6?
Put so%e code into /B +rror event 5using 1et!ction2ode6
int errGcode
.f 1F0/B'2ode aY S 3hen
=essageBox 5:/B +rror:<, :,u%ber< c string 5sqldbcode6 c :< c U
sqlerrtext, 1top1ign?6
36
return
+nd if
##' What is the =essage ob)ect? How do (ou use it? Wh( do (ou use it?
*b)ects work with one another b( sending %essages' ! %essage is a subroutine call directed at an ob)ect'
+ver( ob)ect has a predefned set of subroutines 5in PB %ethods6 that (ou can call to send %essages to the
ob)ect'
*b)ect'=ethod5para%eters6
.n PB, there are three t(pes of %essages:
, "' Kunctions U events which are collectivel( called :%ethods<9
Properties'
.n PB, ever( ob)ect has a set of functions, events and properties for receiving %essages' PB also has functions
that are not directed to an ob)ect, such as a =essageBox'
=essageBox5:Hello<, :How are (ou?<6
Kor the transaction ob)ect, (ou do not use the ob)ect'function s(ntax' .nstead, (ou use standard 1F0 s(ntax'
37
*0+
*0+ 5ob)ect linking and e%bedding6 is a standard that allows Windows progra%s to share both data and
progra% functionalit(
.n *0+, what is a server application?
! server application is the progra% that creates, displa(s, and edits e%bedded ob)ects'
"' What is the role of a container application?
! container application is an application that contains references to an ob)ect e%bedded within'
#' +xplain in-place activation'
3he server application appears in the foreground and its %enus replace those of the /ataWindow painter or
PowerBuilder application'
$' Where can (ou fnd infor%ation on *0+ server applications for (our Windows environ%ent?
How do (ou know what data t(pe to use to store blobs in (our /atabase?
/iDerent /B=1 have diDerent data t(pes that can be used to hold blobs'
1(base 1F0 !n(where ---- long binar(
*racle ---- long row
1(base 1F0 1erver ---- i%age
C' How should a blob colu%n be defned in a data table?
Blob colu%ns in the table defnition %ust allow ,@00 values' 5When a row is inserted or updated in the table and
the @pdate56 function is called, all non-blob colu%ns are handled frst using standard 1F0 state%ents' 3he blob
colu%n is then updated separatel(6'
E' .n what wa(s can (ou use *0+ with a /ataWindow?
!s a presentation st(le'
L' How do (ou place a blob colu%n in a /ataWindow ob)ect?
.nclude blobs in a /ataWindows ob)ect and defne the data source'
' What is the diDerence between an instance variable and a shared variable?
3he( have diDerent scope' 3he value of the shared variable is available
fro% all instances of the sa%e ob)ect' .nstance variables are associated with one instance of
an ob)ect such as a window and each instance can have diDerent values in instance
variable'

"'Wh( should (ou opti%i>e libraries?
3he librar( entit( can beco%e frag%ented over ti%e, increasing seek ti%es'

$' How can (ou override user ob)ect&s function?
3o override an ob)ect&s function , create a descendant ob)ect and declare in there a function with the sa%e na%e
and argu%ents as in its ansestor'

C' How %an( clustered and non-clustered indexes can (ou create for a table in 1(base?
Oou can create clustered and up to "$M non-clustered indexes in 1(base'

E' What is the diDerence between Where and Having clauses?
Where clause eli%inates unneeded rows before creating a result set as
opposed to Having clause that gets rid of unwanted rows after the result set is built'

S' How can (ou d(na%icall( place an @ser *b)ect on the Window?
Oou do this b( using function *pen@ser*b)ect56'
.f (ou want to open the @ser *b)ect with passing so%e para%eters to it
(ou use the function *pen@ser*b)ectWithPar%56'
.f (ou don&t need this ob)ect an(%ore (ou have to call the function
2lose@ser*b)ect'

' .f there are both - foreign ke( and triggers on a 1(base table which one will be fred 5checked6 frst?
Koreign ke(s'

"' 0et&s sa( (ou&ve developed a window wGcusto%ers' !fter so%e ti%e (ou developed a base ancestor
window wGbaseGwin and want to use all functionalit( that (ou put in this ancestor in (our wGcusto%er window'
How can (ou do this?
.f (ou developed a window without using an( ancestors, it will be
inherited fro% PowerBuilders Window *b)ect' 3o change the inheritance (ou should +xport existing window in a
text fle 50ibrar( Painter6, change %anuall( all references to a standard Window ob)ect to wGbaseGwin and
.%port the window back fro% this text fle'

C' What are the benefts of using encapsulation? Xive an exa%ple of
encapsulation in PowerBuilder'
38
+ncapsulation gives (ou the wa( to hide and protect data inside an ob)ect ' 3o hide data we use private and
protected variables' Private variables are accessible fro% scripts of the ob)ect onl(, and protected variables are
available not onl( for the ob)ect&s scripts, but also for all descendants& scripts'
Kor exa%ple, the code providing @ser *b)ect functionalit( is written in the scripts and functions inside the @ser
*b)ect '

E' .s PowerBuilder ob)ect-oriented language? Wh(?
Oes it is' .t has # %ain features of ob)ect-oriented languages - inheritance, encapsulation and pol(%orphis%'

L' What t(pes of ob)ects can be inherited?
Windows, %enus and user ob)ects '

""' What is pol(%orphis%? Xive an exa%ple'
With a pol(%orphis%, the sa%e functions calls give diDerent result on
diDerent ob)ects'
Kor exa%ple, (ou can defne an @pdate/atabase56 function for diDerent
kinds of ob)ects' +ach has its own defnition of what @pdate should do'
"#' .f (ou have a colu%n that gets updated frequentl(, what kind of index will (ou create on this colu%n to
i%prove the perfor%ance - clustered or non-cludtered ?
,on-clustered' .f (ou create a clustered index on this colu%n, the
data will be ph(sicall( re-arranged in the database after each update and this will slow down the perfor%ance'

"E' How do (ou %anage /atabase 3ransactions in PowerBuilder?
Oou use !uto2o%%it attribute of the 3ransaction *b)ect for that'
.f the value of !uto2o%%it is 34@+, PowerBuilder )ust passes (our 1F0
state%ents directl( to the 1erver without issuing a Begin 3ransaction co%%and''

.f (ou set the value of !uto2o%%it to K!01+ 5default value6, PowerBuilder requires that (ou use the 2*==.3 and
4*00B!2V ke(words to co%%it and rollback (our transactions when (ou are fnished with the%' .n this case
PowerBuilder begins the new transaction auto%aticall( as soon as (ou 2*,,+23,2*==.3 or 4*00B!2V'
When (ou work with stored procedures in 1(base, !utoco%%it %ust be set to true to be able to execute //0
state%ents and work with te%porar( tables fro% within stored procedures'

!utoco%%it attribute of 1F02! is ignored when (ou work with *racle'
"L' How could (ou change a /ataWindow ob)ect, associated with the /ataWindow control during the runti%e?
/ataWindow control has the attribute /ata*b)ect' .f (ou want to change an associated /ataWindow ob)ect
during runti%e (ou need to put a line in the script that changes the value of the /ata*b)ect attribute' Kor
exa%ple:
dwGcust'/ata*b)ect R ^dGcusto%er^

#S' How can (ou set /ataWindow to a particular row?
Oou can do it b( using the function 1croll3o4ow56'

#' What should be done to %ake sure that several radiobuttons understand that the( belong to the sa%e group
5the user can select onl( one button in the group6?
Oou should place the% in a Xroup box on (our window'

#"' When is usage of indexes not eDective?
When the expected result set has %ore that B-Se of all rows in the table'

##' How %an( triggers can (ou specif( for one database table?
.n 1(base an( table can have up to three triggers: one update trigger, one insert trigger, and one delete trigger'
However (ou can create a single trigger that will appl( to all three user actions 5@pdate, /elete and .nsert6'

.n *racle a single table can have up to " t(pes of triggers -
C row level triggers 5B+K*4+ f !K3+4 .,1+43, @P/!3+, /+0+3+6 and
C state%ent level triggers'

#$'How can (ou check if there are an( indexes on a table in *racle?
Oou can do a select fro% such views as !00G.,/+[+1 or @1+4G.,/+[+1 where 3!B0+G,!=+ R (our table
na%e'

#B' What&s the diDerence between 2o%posite and ,ested reports?
2o%posite report does not have a data source - it&s )ust a container for several datawindows 5reports6'
,ested reports have datasource and %ain datawindow can pass data to the
nested datawindow through retrieval argu%ents'

#E' What are the four levels of validation ?
' Has an(thing changed?
39
"' .s the data of the correct t(pe?
#' /oes the data pass validation rules 5which could be defned for so%e colu%ns6?
$' /oes the data pass the .te%2hanged event?

#L' How can (ou print %ultiple /ataWindows?
Oou should open the print )ob b( calling the Print*pen56 function, after that (ou can print /ataWindows b( using
Print/ataWindow 56 function and after that (ou close the print )ob b( calling Print2lose56'
Oou can also create ,ested 4eports or use the 2o%posite presentation st(le of /ataWindows to print %ultiple
datawindows as one Print Zob'

$S' How can (ou call an ancestor script fro% a script fro% a descendant ob)ect?
3here is a 2!00 co%%and that calls an ancestor script fro% a script for a descendant ob)ect' Kor exa%ple, 2!00
wGe%p::*pen

!lso (ou can use the pronoun 1uper to refer to the i%%ediate ancestor'
Kor exa%ple, 2!00 1uper::2licked

3o execute ancestor&s function (ou )ust do 1uper::ofGcalcGfee56
$' How could (ou defne additional 3ransaction ob)ect? When %ight (ou need it?
3o create an additional transaction ob)ect, (ou frst declare a variable of t(pe transaction, then (ou create the
ob)ect and then defne the attributes that will be used'
3ransaction 3*G1(base
3*G1(baseR24+!3+ transaction

3*G1(base'/B=1 R ^1(base^
3*G1(base'database R ^Personnel^
3*G1(base'0og.d R ^//"B^
'''
Oou need to create 5an6 additional transaction ob)ect5s6 if (ou retrieve data in (our application fro% %ore than
database'
$"' What is the usage of the /@!0 table in *racle?
.t&s an *racle worktable with onl( one row and colu%n in it' .t&s used to %ake so%e calculations or get the
values of so%e pseudo colu%ns that are not dependent upon the colu%ns in a table, i'e'
1elect 1O1/!3+ fro% /@!0
1+0+23 "W#B fro% /@!0
$$' What is the diDerence between 1et.te% and 1et3ext functions?
When (ou use 1et3ext function, it places the value into the edit control on a /ataWindow and it %ust pass
through the validation process'
1et.te% function inserts the value of a specifc cell directl( into the /ataWindow buDer and skips the
validation'
$B' How can (ou get access to a 2hild /ataWindow?
3o retrieve %anuall( a child /ataWindow, we use the Xet2hild56 function to obtain reference to it, then we
assign a transaction ob)ect to it, and then retrieve'
Kor exa%ple:
/ataWindow2hilddwc
int rtncode
rtncode R dwGe%p'Xet2hild5^e%pGid^,dwc6
dwc'1et3rans*b)ect51F02!6
dwc'4etrieve5^argu%ent^6

$C' What is the usage of the Oield56 function?
Oields control to other graphic ob)ects, including ob)ects that are not
PowerBuilder ob)ects' Oield 56 checks the %essage queue and if there are %essages in the queue, it pulls the%
fro% the queue'
Oou can use Oield56 to allow users to interrupt a tight loop' When (ou use Oield56 to interrupt a loop, (ou
%ust call the Oield function and check for an interrupt each ti%e (ou pass through the loop'
$E' How can (ou change select state%ent of the /ataWindow at runti%e?
Oou can change 1elect stat%ent using functions 1et1ql1elect56 or b( changing the attribute
/ataWindow'3able'1elect with the function
=odif(56'Kor exa%ple,

dwG'=odif(5^datawindow'3able'1electR&1elect W fro% custo%ers&^6

.n version B (ou can change attributes of datawindow ob)ect directl( b( using a ke(word *b)ect like
dwG'*b)ect'/ataWindow'3able'1electR&1elect W fro% custo%ers&

1et1ql1elect works slower since it checks the s(ntax of 1F0 state%ent'
40

$L' What kinds of /ataWindow buDers do (ou know?
3here are $ buDers in Powerbuilder: Pri%ar(?, Kilter?, /elete? and
*riginal? buDer'
Pri%ar(? buDer has the current data values9
Kilter? buDer stores the rows that where fltered out as a result of
1etKilter56 and Kilter56 functions9
/elete? BuDer keeps the rows that have been deleted b( /elete4ow56
function9
*riginal? buDer is used b( PowerBuilder to store original data values
retrieved into a datawindow' PowerBuilder uses this buDer to generate the Where clause for the @pdate56
function'
BS' 2an (ou inherit /ataWindow?
Oou cannot do it directl(, but (ou can create a 1tandard @ser *b)ect of
t(pe /ataWindow 5which can be inherited6 and use it instead of /ataWindow controls' Oou use the sa%e %ethod
when (ou need to inherit an( other control'
B' Where can external functions be declared?
+xternal functions can be declared in @ser *b)ects or Windows'

B#' What functions can (ou use to pass para%eters between windows in
PowerBuilder?
*pen WithPar%5 6 , *pen1heetWithPar%5 6, and 2loseWith4eturn5 6'

B$' How do *penWithPar%56 U 2loseWith4eturn56 functions pass para%eters?
3he( pass para%eters using =essage *b)ect&s attributes 1tringPar%,
/oublePar% or Power*b)ectPar%'
BB' 2an (ou delete a %enuite% in the descendant %enu if it was created in the ancestor one?
,o (ou cannot' .f (ou don&t need an ob)ect that was defned in the
ancestor %enu )ust %ake it invisible b( setting its Jisible attribute to K!01+ or using function Hide56'

BC' What are the " ob)ects ever( application has?
+ver( PowerBuilder application has the =essage*b)ect and the +rror*b)ect'

BE' /escribe the sequence of events which are triggered when (ou call the /atawindow&s function @pdate56'
@pdate1tart? event,
1F0Preview? event for ever( %odifed row,
@pdate+nd? event'
BL' What&s the diDerence between co%puted colu%ns and co%puted felds in /ataWindow ob)ect?
Oou defne a co%puted colu%n in the 1elect painter and it&s calculated b( the /B=1 when the data is retrieved'
2o%puted feld is defned in the datawindow painter and is calculated after the data has been retrieved'
.f (ou change values of so%e colu%ns that are part of the co%puted feld expression the( will be recalculated
i%%ediatel(' 2o%puted colu%ns are not recalculated after the data is retrieved'
CS' What is a class or non-visual user ob)ect?
,on-visual user ob)ects 5or classes6 are ob)ects that encapsulate attributes and functions, but are not visible to
the user' Oou can use the%, for exa%ple, to code so%e business rules which are used in diDerent windows'
C"' How can (ou share buDers between two /ataWindows?
3o share buDers between " /ataWindow controls, we use 1hare/ata56
function'
3he result set description for both /ataWindow ob)ects %ust be the sa%e, but the presentation st(le could be
diDerent'
3o turn oD the sharing of data buDers for a /ataWindow control (ou use the function 1hare/ata*D56'
C#'What is the diDerence between 3rigger+vent56 and Post+vent56 functions?
3he 3rigger+vent56 function causes the event to occur i%%ediatel(' 3his function does not return until the
processing for the event is co%plete'
Post+vent56 function causes the event to occur when the current event is fnished executing'

E#' What is the %essage ob)ect and how is it used when passing para%eters between windows?
! %essage ob)ect is a PowerBuilder-defned global ob)ect populated with
infor%ation about an event' .t has such attributes as WordPar% and 0ongPar%'
.t is used to pass data between windows or ob)ects' /ata will be passed through the =essage'1tringPar%,
=essage'/oublePar% or =essage'Power*b)ectPar% depending on the t(pe of data which (ou want to pass'
41
E$' What is function overloading?
! function is overloaded when there are %ultiple versions of this function with the sa%e na%e but with diDerent
argu%ents' When the function is called, PowerBuilder fnds the function whose argu%ent list %atches the
function call fro% the script'
.n PowerBuilder $ (ou had to create a descendant ob)ect for ever( overloaded function'
.n Jersion B (ou can declare all overloaded functions in the sa%e ob)ect'

EB' What could (ou use the 1F0Preview event for?
Oou could use 1qlPreview event if (ou want to use stored procedures to
perfor% update in the database'
Oou can also use the 1F0Preview event to displa( the 1F0 state%ent right before its execution for the
debugging purposes' 3o get the curent 1ql 1tate%ent (ou use Xet1qlPreview56 function'
.n version B (ou don&t even need to call this function since 1F0Preview event has an argu%ent with 1F0
1tate%ent'
EC' What should be distributed to (our user with (our application?
3he '+[+, 'PB/s 5if an(6, and the /atabase /evelop%ent and /eplo(%ent Vit /00s'

L' .f (ou have an =/. Window, sheet with %enu and sheet" without the %enu' Oou open sheet" after sheet'
Which %enu will sheet" have - =/. %enu or 1heet %enu?
.t will have the %enu of 1heet as the last %enu that was displa(ed on the =/. window'
L$' What kind of windows can be closed using the function 2loseWith4eturn56?
4esponse Windows'

LL' How can (ou fnd out what&s the ob)ect under %ouse pointer in a datawindow?
3he function Xet*b)ect!tPointer56 will tell (ou what&s under the %ouse - colu%n, header, etc'
3he function XetBand!tPointer56 will tell (ou the band na%e such as detail, header, etc'
LM' How do (ou handle ,ull values in a database?
.n 1(base (ou use .s,ull56 function, in *racle - ,J056 function'

ML' How %an( t(pes of /(na%ic 1F0 do (ou know in PowerBuilder?
3here are $ for%ats: ' ,on- result-set, no input para%eters9
"' ,on-result-set with input para%eters9
#' 4esult-set, known input para%eters and result-set colu%ns9
$' 4esult-set, unknown input para%eters andIor result set colu%ns'
Kor for%at (ou %ust use +[+2@3+ .==+/.!3+ state%ent9
Kor for%ats ",# and $ (ou need to prepare a d(na%ic staging area 51F01!69
Kor for%at $ (ou also need to use d(na%ic description area 51F0/!6'

S' How can (ou disable or enable trigger in *racle?
Oou can do it using !lter trigger state%ent' Kor exa%ple:

!03+4 34.XX+4 deleteGcuso%er /.1!B0+
!03+4 34.XX+4 updateGorders +,!B0+

L' How can (ou undelete a row in a datawindow?
Oou need to %ove row using a function 4ows=ove56 fro% the /elete? buDer into the Pri%ar(? buDer'

"' How can (ou fnd a nu%ber of rows returned b( an e%bedded 1F0 state%ent?
Oou can fnd it in the attribute 1F02!'1F0,4ows'

"#' How can (ou stop the retrieval process in a datawindow after so%e nu%ber of rows?
Oou need to declare a variable, incre%ent it b( one in the script for the 4etrieve4ow event and check its value
like
ilGcountcc
.f ilGcount Y S then 4eturn II 1top the retrieval

"$' How do (ou process database errors in case of a /atawindow and +%bedded 1F0?
.n case of +%bedded 1F0 (ou check the value of 1F02!'1F02ode and if it&s less than S,
Xet the error code and error %essage fro% 1F02!'1F0/B2ode and 1F0+rr3ext'

.n a /atawindow (ou get the errors in a /B+rror event' .n PBB (ou get error code and text fro% the argu%ents
of this event, in PB$ (ou use the functions /B+rror2ode56 and /B+rror=essage56'
42

"E' 2an (ou update database using views?
Oou can do this onl( if the view is based on a 1elect fro% a single table' .f the view has been built based on a
table )oin (ou cannot do an update'

#E' What is the diDerence between functions and events in Powerbuilder?
3he( are al%ost the sa%e in version B' 3he %a)or diDerence is that ob)ect-level functions could be private and
protected while events are alwa(s public'
Oou can specif( a function na%e in the script even if the specifed ob)ect does not have such a function' Oou )ust
need to add the ke(words K@,23.*, /O,!=.2'
Kor exa%ple:
invoG%ine'K@,23.*, /O,!=.2 ofGcalcGsalar(56'

$#' Which functions should (ou not call in the .te%2hanged event to avoid an endless loop?
Oou should not call !ccept3ext56, 1et2olu%n56 and 1et4ow56 in an .te%2hanged event'

B"' Write a code to update two datawindows in one transaction'
1F02!'!uto2o%%it R K!01+ II 3his Begins the 3ransaction

.K dwG'@pdate5 6 Y S 3H+,
.K dwG"'@pdate5 6 Y S 3H+,
II Both updates succeeded, 2*==.3 the changes'
2*==.39
+01+
II @pdate of dwG" failed, 4*00B!2V the changes9
4*00B!2V9
+,/ .K
+01+
II @pdate of dwG failed, 4*00B!2V the changes9
4*00B!2V9
+,/ .K

II 2lean up !uto2o%%it after 2*==.3I4*00B!2V to prevent another transaction fro% beginning'
1F02!'!uto2o%%it R 34@+

Oou %ight want to call the @pdate function with argu%ents 53rue, Kalse6
to prevent resetting of row statuses' .n this case (ou need to call function 4eset@pdate56
after successful updates'

B#' What&s the %axi%u% si>e of data (ou can store in integer and string variables respectivel(?
.nteger can store values up to #"kb and string variables can hold up to CSSSS b(tes'

BB' What happens to a PowerBuilder ob)ect when (ou regenerate it?
Powerbuilder reco%piles all scripts of this ob)ect to %ake sure that all referred ob)ects exist'

BE' Which of the following /ataWindow ob)ect settings will give (ou the highest row locking protection, in a
%ultiuser environ%ent?
- Ve( 2olu%ns
- Ve( and @pdatable 2olu%ns -- 2orrect answer
- Ve( and =odifed 2olu%ns
BL' What t(pes of )oins do (ou know?
+qui)oin, ,on-equi)oin, *uter )oin, 1elf )oin

ES' What would (ou do to i%prove perfor%ance of a PB application?
*n the back end: ' 2reate indexes where needed'
"' @se stored procedures instead of e%bedded 1F0'
#' 3r( to %ini%i>e use of database cursors'
*n the front end: ' 2onsider 4etrieve !s ,eeded option in slow datawindows'
"' =ini%i>e the nu%ber of controls on the windows - use user ob)ects instead'
#' @se datawindows or datastores instead of e%bedded 1F0'
$' @se /atastores instead of datawindows where possible'
B' @se 'PB/&s to speed up the application loading
43
0ist three benefts of using a service-oriented fra%ework'
0ist three responsibilities of requester ob)ects'
0ist two responsibilities of service ob)ects'
0ist two advantages of using extension levels to custo%i>e code in a fra%ework'
What PK2 librar( contains the window fro% which (ou would inherit to create a fra%e in an =/. application?
What ob)ect would (ou use? What is the na%e of the ancestor ob)ect fro% which this ob)ect is derived?
What librar( contains the PK2 application services (ou would use in (our applications?
What t(pe of PB ob)ects is used to i%ple%ent %ost of PK2 1ervices? Wh( does this t(pe of ob)ect works best?
How do (ou identif( predefned events in PK2 ob)ects?
.n general, how do (ou enable and access PK2 services? How are the( destro(ed?
What is the role of reference variables in i%ple%enting PK2 services?
Wh( are events redirected in PK2 ob)ects?
.n the following list, circle the na%e of the ob)ect 5and the librar( in which it is stores6 that (ou use to create an
application %anager for PK2 applications'
Write the code to create an instance of a PK2 application %anager and begin using it' ,a%e the ob)ect and its
event in which (ou would include this code'
2ircle the PK2 services that (ou can enable in the application %anager'
Write the na%e of the global variable to defne the application %anager'
,a%e the event in the application %anager where application services are auto%aticall( destro(ed'
How do (ou redirect events in an application ob)ect to the application %anager?
What function do (ou use to specif( the na%e of an application .,. fle? What function do (ou sue to return the
na%e of an application .,. fle to an application? ,a%e the ob)ect and its event where (ou initiali>e the
application .,. fle'
/escribe a situation when (ou %ight use the /ata Window caching service' ,a%e the function (ou use to
register an ob)ect to use this service'
,a%e the ob)ect 5and the librar( in which it is stored6 that (ou use to create a %enu for a fra%e in a PK2 =/.
application'
,a%e the ob)ect 5and the librar( in which it is stored6 that (ou use to create a sheet in a PK2 =/. application'
What function do (ou use to send a %essage between a %enu ite% and a window? What do (ou pass with the
function?
Wh( %ust (ou create all PK2 /ata Window controls fro% the uGdw user ob)ect?
,a%e the ancestor ob)ect for all /ata Window service'
What is the frst step in using an( /ata Window service?
What %ethod results in the displa( of the Kilter dialog box? Where is this code i%ple%ented?
0ist the one required step (ou take to i%ple%ent the fnd and replace service?
,a%e the function (ou use to link a detail /ata Window to a %aster /ata Window'
What is the advantage of using the linkage service function to established a transaction ob)ect for /ata Window
in linkage chain? Write the code to i%ple%ent this function'
Wh( %ust insert an extension level before the PK2 extension level?
0ist the four %a)or steps required to add an extension level to the PK2'
0ist the four %a)or steps required to add a /ata Window service ob)ect to the PK2'
0ist the %a)or steps (ou take to i%ple%ent utilit( services'
How is i%ple%enting utilit( services diDerent fro% i%ple%enting the other PK2 services?
44
P*0O=*4PH.1=
' What is pol(%orphis% ?
Pol(%orphis% is functions with the sa%e na%e that can do diDerent things for diDerent ob)ects and give
diDerent results ' Kor exa%ple, c R " %athe%atics plus
:Zohn< c :1%ith< 2oncatenation plus
Pol(%orphis% is a feature of an ob)ect-oriented language which defnes sa%e %ethods for diDerent ob)ects'
+xa%ple: 0etAs sa(, (ou are going to have several windows in (our progra%, all of the% with /ataWindows and
4etrieve buttons' We want to be generic and put code for the retrieve event in the function of the ancestor
window' But so%e of these /ataWindows are with external data source and have to be handled diDerentl( than
the rest' *ur solution is to create a generic function for retrieve in the window-ancestor and for the window with
special handling create their own functions with the sa%e na%e as in the ancestor' 3he function in a descendant
will overload the ancestorAs function' We can defne a Print function for a diDerent kinds of ob)ects' +ach has its
own defnition of what print does'
"' How do (ou understand using *verloading functions in Pol(%orphis%?
*verloading is functions with the sa%e na%es with diDerent para%eters that can be used in the sa%e ob)ect'
!wa( in which pol(%orphis% works in PowerBuilder' =eans that when several functions the sa%e na%e exist in
ancestors and descendants call to another 5with diDerent function bod(6 will overload 5change6 functionAs bod(
in the %e%or('
#' What is overloading?
When the function of the ob)ect has the sa%e na%e but diDerent argu%ents'
$' What is pol(%orphis%?
Pol(%orphis% is when functions have the sa%e na%e but behavior varies with the t(pe of the ob)ect to which it
is applied'
B' Xive exa%ples of pol(%orphic functions in PowerBuilder'
Kor exa%ple, c R " %athe%atics plus
:Zohn< c :1%ith< 2oncatenation plus
!nother exa%ple: When (ou i%ple%ent pol(%orphis%, itAs co%%on to create an ancestor ob)ect that has a
%ethod in it but no code' +'g', suppose, that (ou have a custo% class called uG.nvoice and one called @-check'
3he( are both descendants of the custo% class called uG/ocu%ent' @G/ocu%ent has a Print %ethod but it has
no code in it' Both uGinvoice and uG2heck also have a Print %ethod, each with diDerent code' Wh( create this
structure? Because then an application that uses (our ob)ects can refer to an( docu%ent using variables of
t(pe uG/ocu%ent' !nd when the( want to print a docu%ent, the( can )ust call the Print %ethod'
@oGdocu%ent doc
_
II,ext/ocu%ent56 %a( return a uG.nvoice or uG2heck docu%ent
doc R ,ext/ocu%ent56
doc'Print56
3his is called d(na%ic binding' 3he specifc function (ou are calling isnAt actuall( resolved until runti%e' .t )ust
depends on whether the variable doc is holding a uG.nvoice or uG2heck ob)ect'
C' What is pol(%orphis%?
Pol(%orphis% is an ob)ect-oriented feature' /iDerent ob)ect classes can have functions with the sa%e na%e
which can be used %ore than once to do diDerent things for diDerent ob)ects' 3here are situations in which (ou
want to send the sa%e kind of %essage to diDerent kinds of ob)ects and have each ob)ect respond to that
%essage in its own unique wa('
45
124.P3
C' !ssu%e that when the instance wGcustG%aint of the window wGcustG%aint is displa(ed, (ou want its title to
read :4eferenceable 2usto%er<' Xiven the following declaration, code the state%ents to displa( the window
appropriatel('
wGcustG%aint wGcustG%aint
wGcustG%aint'3itle R :4eferenceable 2usto%er<
C' What is a focus ?
! focus identifes where on the Window the next action will take place'
E' How do (ou pass an arra( as an argu%ent?
3o pass an arra( we should defne it as an argu%ent in the window function with brackets' .n a script we have
to assign an arra( to a veritable in order to use it'
L' What is an arra(?
!n arra( is an indexed %assive of variables of the sa%e /ata 3(pe'
+[' PriseP Q or PrisePBSQ
M' Wh( are static arra(s preferable over d(na%ic arra(s?
1tatic arra(s tell us how %an( ele%ents an arra( will have b( specif(ing nu%ber in brackets' 1tatic arra(s are
faster'
/(na%ic arra(s grow d(na%icall( what is %ore convenient '
Because the %e%or( needed for a static arra( is located i%%ediatel( on creation, so there is no reason to
reallocate and cop( an(thing and also because boundaries of the arra( are known when the arra( is accessed,
so there is no processing overhead while checking the validit( of the arra( subscript'
S' What is !rra( /ata t(pe?
!rra( is a %assive of variables of the sa%e /ata 3(pe
' Oou need to process an arra( in a loop' Which function should (ou use if (ou donAt know arra(As si>e 5i'e',
nu%ber of arra( ele%ents6?
@PP+4B*@,/5!rra(6
int i
K*4 i R 3* @PP+4B*@,/5!rra(6
state%entblock
,+[3
"' What is enu%erated data t(pe? How is it represented and what is its purpose ?
1o%e functions which were written in so%e other languages and build into PowerBuilder and PowerBuilder
recognises the% b( the excla%ation point at the end'
E' What is !,O /ata 3(pe ? How is it used?
!n( is a cha%eleon data t(pe H it takes the data t(pe of the value assigned to it'
L' What is a B0*B data t(pe?
B0*B is @nbound data t(pe that stands for binar( large ob)ect' @suall( used to hold pictures, windowAs wave
sound fle or ver( large text fles'
"S' How do (ou put the ti%e in the status bar?
*n the open event of a window call 3i%er56' *n the ti%er event 3i%e R ,ow5 6
1et=icroHelp53i%e6
1F0 1erver Kunda%entals'
' What is 1F02!, 1F01!, 1F0/!?
3he( are built-in global ob)ects that are predefned in all applications'
1F02! - default PB 3ransaction *b)ect, 1F0 co%%unication area' @sed to co%%unicate with our /atabase'
1F01! is /(na%ic 1taging !rea' We use it when we need to use a 2ursor d(na%icall('
1F0/! is /(na%ic /escription !rea, used in d(na%ic 1F0'
"' When and wh( do we need d(na%ic 1F0?
/(na%ic 1F0 is a structure of 1F0 state%ents which can be changed d(na%icall( in (our progra%' @sed when
at design ti%e it is undeter%ined what the user is going to input 5ad hoc Fuer(6'
"' +xplain the diDerence between char and varchar datat(pes?
2har is fxed-length datat(pe whose trailing spaces are stored' Jarchar is a variable-length datat(pe' ,ullable
char is stored like varchar because it is variable length ` either no length or the declared length'
L#' /escribe the diDerence between a table-level and a colu%n-level constraint'
! constraint is considered table level if it is defned after the colu%n defnitions in the 24+!3+ table state%ent
or is defned using alter table'
46
L$' When %ust (ou defne a constraint as a table-level constraint?
When the constraint references two diDerent colu%ns'
"a' What benefts of 1tored Procedures ?
run faster than the sa%e co%%ands executed interactivel( as a batch
reduce network tra\c
enforce consistenc( throughout the database
help provide securit(
reduce operator error
47
@1+4 *BZ+23
' What are ,on-Jisual @ser *b)ects?
,on-visual user ob)ect is an ob)ect that encapsulates attributes and functions but is not visible to the user' ,J*
is a collection of business user functions' 3he( can be 2usto% 2lass and 1tandard 2lass' ,J*s are useful
because the( allow (ou to encapsulate application operations into ob)ects %aking the% easier to develop,
%anage and %aintain and also to encapsulate all securit( %anage%ent for an application into a single ob)ect'
"' +xplain the purpose of a non-visual user ob)ects
3he purpose of non-visual user ob)ects is to defne business rules and other processing 5which are checked in
diDerent windows in (our application6 that act as a unit' We i%ple%ent the% in PowerBuilder using 2lass @ser
*b)ects'
#' What t(pes of a non-visual user ob)ect do (ou know?
3here are two t(pes of non-visual user ob)ects :
1tandard user ob)ect inherits its defnition fro% one built-in, PB ,J* such as the 3rans-action ob)ect or +rror
ob)ect' We %odif( its defnition to %ake the ob)ect specifc to our application'
2usto% user ob)ects are ob)ects of our own design that encapsulate properties and functions but are not visible
to the user'
3(picall(, we use 2usto% 2lass @ser *b)ects to defne processing in our application that has no visual
co%ponent' We t(picall( use class user ob)ects to defne processing that acts as a unit9 for exa%ple if our
application calculates sales co%%issions, we %ight create a custo% class @ser*b)ect to perfor% the
co%%ission calculation'
!fter we build and save a visual user ob)ect, we can use it as we use a PB control' We can place it in a window or
in other user ob)ects, and we can si>e it, change its st(le, and build scripts for its events'
!fter we build and save a class user ob)ect, we declare a variable of the @ser*b)ect t(pe and create an
inheritance of it using the 24+!3+ state%ent in a script' *nce we have instantiated the class @ser*b)ect, its
attributes and functions are available within the scope of the variable declaration' !fter using the @ser*b)ect,
we destro( it with the /+134*O state%ent to free up %e%or('
We can also build new user ob)ects that inherit attributes, events, structures, and functions fro% an existing
user ob)ect'
$' What are facilities of the @ser *b)ects ?
We defne a co%ponent once, then reuse it %an( ti%es as we need without an( additional work'
B' Xive %e an exa%ple of 1tandard U 2usto% visual user ob)ects (ou have created and what was the purpose of
each?
1tandard ` !n( single control can be placed in a standard user ob)ect
2usto% ` =an( controls can be placed in a custo% user ob)ect
C' What does *pen@ser*b)ect5 6 do?
*pen@ser*b)ect5 6 adds a user ob)ect to the specifed window and %akes all its properties and controls available
to scripts'
windowna%e'*pen@ser*b)ect 5 userob)ectvar, userob)ectt(pe 7, x, ( 8 6
3his function is used when (ou want d(na%icall(, at runti%e place so%e user ob)ects on a window' 3his function
displa(s this user ob)ect, %akes all its attributes available to scripts' Oou %ust open a user ob)ect before (ou can
access the attributes of the user ob)ect' .f (ou access the user ob)ectAs attributes before (ou open it, it will
cause an execution error'
E' How can (ou d(na%icall( place an @ser *b)ect on the window?
B( using functions : *pen@ser*b)ect5 6, *pen@ser*b)ectWithPar%5 6
L' When would (ou use a 1tandard @ser *b)ect?
We use a standard @ser*b)ect to extend the standard set of predefned attributes, events, and functions or to
encapsulate co%%on controls into an ob)ect that can be reused without an( additional work'
M' 2an a standard visual @ser *b)ect contain another @ser *b)ect? ,o'
S' .n what situations would (ou use a custo% visual @ser*b)ect?
We use a visual custo% @ser*b)ect when we frequentl( group controls in a Window and use the controls to
perfor% the sa%e processing'
' What +vents does the 2usto% 2lass have?
2onstructor and /estructor
"' What events are available to a standard class @ser *b)ect?
2onstructor and /estructor
#' What events are available to a standard visual @ser *b)ect?
.t has all events that standard PowerBuilder control has it'
M' What events do (ou know for custo% visual user ob)ects?
48
2onstructor - occurs after windowAs open event or when a user ob)ect is d(na%icall( placed in the window
/estructor -occurs after windowAs 2lose event or when a user ob)ect is d(na%icall( re%oved fro% the window
/rag/rop When a dragged ob)ect is dropped on the user ob)ect
/rag+nter - when a user ob)ect enters the user ob)ect etc'
/rag within
/rag leave
*ther
4ightButton/own
"S' How can (ou co%%unicate between the window and user ob)ect in the window?
When we placed user ob)ect into the window we can write the script s for @ser *b)ect event 5conctructor,
dectructor6 but we cannot write the scripts for controls inside the user ob)ect' But we can use user ob)ect level
functions or user events'
49
J!4.!B0+1
$' What is a local variable?
! local variable is declared in the script for a control or ob)ect that can onl( be referenced in that script' We use
local variables when the value onl( needs to be known while the particular script is executing'
L' When do (ou use instance variable?
Oou use an instance variable when (ou have data that have to be accessible in %ore then one script within the
ob)ect, but donAt need to be global'
"' What is a shared variable? !n .nstance variable? How do (ou use the%?
! shared variable is a variable that belongs to an ob)ect defnition and exists across all instances of the ob)ect'
1hares variables retain their value when an ob)ect is closed and opened again' 1hared variables are alwa(s
private' 3he( are accessible onl( in scripts for the ob)ect and for controls associated with the ob)ect' 1hared
variables can belong to the application ob)ect, a window, a user ob)ect, or a %enu'
!n instance variable is a variable that belongs to an ob)ect and is associated with an instance of that ob)ect 5(ou
can think of it as a propert( of the ob)ect6' .nstance variables have access ke(words that deter%ine whether
scripts of other ob)ects can access the%' .nstance variables can belong to the application ob)ect, a window, a
user ob)ect, or a %enu' 5/iDerence: the( have diDerent scope' 3he value of the shared variable is the sa%e in
each instance of the ob)ect' .nstance variables are associated with one instance of an ob)ect such as a window
and each instance can have diDerent values in the instance variable'6
50
Xive so%e exa%ple of function overloading?
=essagebox56,*pen56,opentab56,openuserob)ect56 etc' all these functions are overloaded because there are
%ore than one function with sa%e na%e in sa%e class with diDerent nu%ber of para%eter'
2an (ou open a response window with opensheet function?
Oes, we can open a response window with opensheet function but then that window will not work as response'.t
will work as a %ain window'1o *pening response windows /o not use the *pen1heet function to open a
response window
2an (ou open %ore that one response window at the sa%e ti%e'and wh(?
,o, (ou can not open %ultiple response windows at the sa%e ti%e because when (ou open one response
window .t expects so%e input fro% user then onl( it proceed further'

How can (ou delete or flter the records with out sending the% to buDer?
We can do so b( using rowsdiscard function'
dwcontrol 4ows/iscard 5startrow, endrow, buDer 6
.f the datawindow update propert( is false and (ou applied a delete function to so%e records what will happen?
.n this case deleted rows will not go to the delete buDer' 3his ti%e delete work as rowsdiscard function
What is the 1F01!?
/(na%ic1taging!rea is a PowerBuilder data t(pe' PowerBuilder uses a variable of this t(pe to store infor%ation
for use in subsequent state%ents'
3he /(na%ic1taging!rea is the onl( connection between the execution of a state%ent and a transaction ob)ect
and is used internall( b( PowerBuilder
PowerBuilder provides a global /(na%ic1taging!rea variable na%ed 1F01!
What is the SQLDA?
/(na%ic/escription!rea is a PowerBuilder data t(pe' PowerBuilder uses a variable of this t(pe to store
infor%ation about the input and output para%eters used in Kor%at $ of d(na%ic 1F0'

PowerBuilder provides a global /(na%ic/escription!rea na%ed 1F0/! that (ou can use when (ou need a
/(na%ic/escription!rea variable'
What are the global variables and objects in pb?
+rror, =essage, 1F02!, 1F01!, 1F0/!'
What are the diference between datasource and datastores?

! datasource is the %ethod used to populate data into a datawindow' While a datastore is a non visual
datawindow'
What item status generate update statements?

,ew=odifed U /ata=odifed'
What are the diDerence between event and functions?

! event can be extended but not overrided U overloaded whereas a function can be'
.f a event is called d(na%icall( then even if the event is not there at runti%e it onl( returns a ` while in si%ilar
case a function will fre an error'
What all functions (ou can not call in ite%change event and wh(?
51

.f (ou call an( of the following function in ite% change event it will go in indefnite loop because these functions
call the ite% change event again' 3hese events are `
!ccept text all scroll functions, set row, set colu%n
What is the diDerence between quick select and sql select?

.n the Fuick 1elect dialog box, (ou can choose colu%ns fro% one table or fro% %ultiple tables if the( are )oined
through foreign ke(s' Oou can not sort and group the colu%ns and specif( retrieval criteria and (ou can not add
co%puted colu%n' Which all are possible in sql select'
Diference between opensheet and open function?

*pen: *pens a window ob)ect of a known data t(pe' *pen displa(s the window and %akes all its properties and
controls available to scripts'
*pen 5 windowvar 7, parent 8 6

OpenSheet : Description
*pens a sheet within an =/. 5%ultiple docu%ent interface6 fra%e window and creates a %enu ite% for selecting
the sheet on the specifed %enu'

*pen1heet 5 sheetrefvar 7, windowt(pe 8, %difra%e 7, position 7, arrangeopen 8 8 6
What is the function of setredraw function?

2ontrols the auto%atic redrawing of an ob)ect or control after each change to its properties'
*b)ectna%e'1et4edraw 5 boolean 6

52

You might also like