Progress Quiz - Feedback on Answers

Qn 1. Enumerate the layers of a 3-tier application:
Ans: Presentation/Application Layer, Business Logic Layer and Data Layer

Qn 2. What are (some of) the PROPATH's characteristics (check the appropriate entries)?

1. it is an OS environment variable -yes
2. .r files are automatically searched on the file system only in the folders specified (and in that order) - YES
3. it is read-only throughout a Progress session - NO
4. it stores a (comma-separated) list of folders - YES
5. you cannot call a Progress source located outside the folders listed in PROPATH - YES
6. between sessions, PROPATH is stored in the .ini file - NO
Qn3: Enumerate the main components of a database:
Ans: Fields, Tables, Index, Sequence

Qn4: What is a foreign key.
Ans: Well, I understand, but to give a defintion in the forum, I cheated a bit and here is the precise answer! I would not have worded like this though!

A foreign key is a column that references a primary key of another table. The foreign key value either is NULL or exists as the primary key value. The table that contains the foreign key is called the referencing table. The table that contains the primary key is called the referenced table.

Qn5: Enumerate the database-events that fire a trigger:
Ans: Create, Delete, Find, Write

These are the first 5 out of 30 questions! Feedback please!
 
Qn6: Define a variable to store this value: 03/02/2005 09:05:46.359
Answer?

I think it must use some form of DATETIME or DATETIME-TZ, but don't know how!

Qns 7 and 8 are skipped.

Qn9: Can a database trigger be run (Y/N)?
Ans: NO

Qn 10:Enumerate the three Progress 4GL statements that define blocks:
Ans: DO, DO WHILE, FOR EACH, REPEAT

Qn 11: What will be the output of the following Progress code:


calling procedureinclude called

&scoped-define aaa outer
display "Before include call: " "{&aaa}" skip.
{include1.i &aaa="include"}.
display "After include call: " "{&aaa}".

display "Within include: " "{&aaa}" SKIP.
ANS:
Before include call: outer
Within include: .include.
After include call: .outer

Qn 12: Describe the ways to pass parameters to an include file:
Ans: Arguments, Pre-processors
 
Qn 13: What is the difference between “RUN procname.p” and “RUN procname.p PERSISTENT SET handle” statements?
Ans: 1st one is a call to an external procedure and 2nd one makes procname.p as a persistent procedure for the duration of the called procedure.

Qn 14: Check the code below and mention if a progress transaction is started or not in each case!
answer (Y/N)
FOR EACH table:
DISPLAY table.
END.
No
FOR EACH table:
UPDATE table.
END
Yes
FIND FIRST table.
REPEAT ON ENDKEY UNDO, LEAVE:
ASSIGN table.field = aFunction().
FIND NEXT table.
END
Yes
FOR EACH table EXCLUSIVE-LOCK:
DISPLAY table.
END.
Yes


Qn 15: Is the following code correct? Explain! Assume that Sports2000 database is connected!

DEFINE VARIABLE order-rec AS ROWID.
DEFINE VARIABLE answer AS LOGICAL.

REPEAT:

FIND NEXT order NO-LOCK.

DISPLAY order WITH 2 COLUMNS 1 DOWN.

MESSAGE "Do you want to update this record?"
VIEW-AS ALERT-BOX QUESTION BUTTONS YES-NO UPDATE answer.
IF answer THEN DO:
order-rec = ROWID(order).
UPDATE order EXCEPT order-num cust-num.
END.
END.

Ans: Two issues.

1. There is no error-handling in the find.
2. before the update the record is not fetched in exclusive-lock

Qn 16: If necessary, fix the code in Question15.

Ans:

DEFINE VARIABLE order-rec AS ROWID.
DEFINE VARIABLE answer AS LOGICAL.

REPEAT:

FIND NEXT order NO-LOCK NO-ERROR.
IF AVAILABLE order THEN DO:
DISPLAY order WITH 2 COLUMNS 1 DOWN.
MESSAGE "Do you want to update this record?"
VIEW-AS ALERT-BOX QUESTION BUTTONS YES-NO UPDATE answer.

IF answer THEN DO:
order-rec = ROWID(order).
FIND order WHERE ROWID(order) = order-rec EXCLUSIVE-LOCK NO-ERROR.
IF AVIALABLE order THEN
UPDATE order EXCEPT order-num cust-num.
END. /* If answer */
END. /* If Avail Order */
END. /* Repeat */
 
Qn 17. What is the difference between ADD-FIELDS-FROM () and ADD-LIKE-FIELD() methods of a dynamic temp-table? Name another method to add fields to a dynamic temp-table!

Ans: ADD-FIELDS-FROM adds all the fields from the mentioned table to the temp-table.
ADD-LIKE-FIELD() adds only the mentioned field.
Another method to add fields??

Qn 18: What is the default locking level for reading records in Progress? Give some reasons why this should be used or not!
Ans: Default locking when no explicit lock is given is SHARE-LOCK.

When another user reads the same record and starts updating, the record gets locked for the second user. If then, the first user starts updating, he needs to wait till the second user releases.

It is best to read the record in NO-LOCK if it is display only purpose.

It is best to read the record in EXCLUSIVE-LOCK if it is for update, so others can retrieve only in NO-LOCK mode.

Qn 19: Name the main difference between FIND statement and CAN-FIND() function. What CAN-FIND() returns?
Ans: FIND fetches the record from the database and makes it physically available.
CAN-FIND() just returns a logical yes/no to say whether a record is available in the database

Qn 20: What happens when you use NO-ERROR clause in a (internal or external) procedure call? How we can treat the error in both cases (with and without the NO-ERROR)?
Ans: NO-ERROR suppresses any error on the RUN statement itself.
The messages can be captured using NUM-MESSAGES or GET-MESSAGE and appropriate action taken
 
Qn 21: What are the ways to pass a temp-table as a parameter?
Ans: Use TABLE FOR?

Qn 22: In the following code, how many times the file is included?
FOR EACH customer:

IF FALSE THEN

{include.i}

END.

Ans: 0

Qn 23: How can a handle be tested for validity?
Ans: IF VALID-HANDLE(hdl1)

Qns 24: We have the code below. What happens when the <condition> becomes true? What block is left and how can we force to leave the other block?

For EACH table1:

For EACH table2:

/*Do something…*/

IF condition THEN

LEAVE.

END.

END.

Ans: When the condition becomes true, the table2 block is left, but proceeds with the next iteration of the table1 and the loop continues till all the records in table1 have been read.

Qn 25: How can more values be returned from one particular function?
Ans Convert the function to procedure?
 
Qn 26: What is the difference between searching and filtering when using a database table?
Ans: Search – searches for the records in the table – usually returns logical answer.
Filter – filters out and returns the only required records – physically brings the data

Not confident on the above answer!

Qn 27: Is the following example correct? Explain!
FUNCTION myFunc RETURNS LOGICAL:

IF TRUE THEN

RETURN 'YES’.

ELSE DO:

RETURN NO.

END.

END FUNCTION.

Ans: Yes is returned as a string, so it is not correct, the function expects only logical field to be returned
 
Qn 28: What message will be shown after running the following code?

FUNCTION myFunc RETURNS LOGICAL (INPUT iplPar01 AS LOGICAL) FORWARD.

MESSAGE myFunc(YES) VIEW-AS ALERT-BOX.

FUNCTION myFunc RETURNS LOGICAL

(INPUT iplPar01 AS LOGICAL):

IF iplPar01 THEN

MESSAGE "myFunc, THEN branch" VIEW-AS ALERT-BOX.

ELSE DO:

MESSAGE "myFunc, ELSE branch" VIEW-AS ALERT-BOX.

END.

END FUNCTION.

Ans: myFunc, THEN branch
 
Qn 29: What messages are shown after running the following code (in both cases!) ?
a.
PROCEDURE p1:
MESSAGE 1 AVAILABLE(customer).
END PROCEDURE.

PROCEDURE p2:

DEFINE BUFFER customer FOR customer.

MESSAGE 2 AVAILABLE(customer).

END procedure.

FIND FIRST customer NO-LOCK NO-ERROR.

RUN p1.
RUN p2.

b.

PROCEDURE p1:

FIND FIRST customer EXCLUSIVE-LOCK NO-ERROR.

MESSAGE 1 TRANSACTION.

RUN p2.

END PROCEDURE.

PROCEDURE p2:

MESSAGE 2 TRANSACTION.

END PROCEDURE.

RUN p1.

Ans:
a. 1 and yes or no depending on if customer record is available. 2 and yes or no again.
b.
1 TRANSACTION
2 TRANSACTION
 
Qn 30: Write a procedure (p1.p) that contains a function internalFunction() and a procedure internalProcedure (both returning a string). Write another (p2.p) procedure to call both the internalFunction() and the internalProcedure from the first procedure using super-procedures mechanism.
 

TomBascom

Curmudgeon
Qn6: Define a variable to store this value: 03/02/2005 09:05:46.359
Code:
define variable d as datetime initial "03/02/2005 09:05:46.359".

display d.

Watch out for session:date-format!

Qns 7 and 8 are skipped.

Too easy?

Qn9: Can a database trigger be run (Y/N)?
Ans: NO

Wellllllll... not successfully ;)

Qn 10:Enumerate the three Progress 4GL statements that define blocks:
Ans: DO, DO WHILE, FOR EACH, REPEAT

You named 4...

This is not a very clear question. I think the question wants to know what 3 statements define "control blocks". And that would be DO, FOR EACH, and REPEAT.

PROCEDURE and FUNCTION also define blocks. (Plus all of the OO stuff that this test doesn't care about.)

Qn 11: What will be the output of the following Progress code:

calling procedureinclude called

&scoped-define aaa outer
display "Before include call: " "{&aaa}" skip.
{include1.i &aaa="include"}.
display "After include call: " "{&aaa}".

display "Within include: " "{&aaa}" SKIP.
ANS:
Before include call: outer
Within include: .include.
After include call: .outer

Where are the "." in ".include." coming from? I don't get that.

Qn 12: Describe the ways to pass parameters to an include file:
Ans: Arguments, Pre-processors

I'd go with: STOP USING INCLUDE FILES!
 

TomBascom

Curmudgeon
This is crazy confusing. One thread per question (or per post with a small subset of questions) will be a *lot* easier to follow.
 
Top