Page 1 of 7
1) What is the difference between: Print $some_var (1,1,0) and Print $some_var (+1,1,0) 2) What are some possible reasons for seeing an error like this:
(SQR 5528) DB2 SQL PREPARE/DECLARE error -204 in cursor 1: SQL0204N "DRO.DEALERSHIP" is an undefined name. SQLSTATE=42704 SQL: SELECT orgHier.GEOG_NM, dlrshp.DLR_CD, dlrshp.dlrshp_nm, agmt.APPNTD_DT, agmt.CNSCTV_TERM_NO FROM DRO.DEALERSHIP dlrshp, ..... .... Error on line 227: (SQR 3716) Error in SQL statement. Errors were found in the program file. SQR: Program Aborting.
3) What is the Load-Lookup structure in SQR useful for and when might you use it. 4) How is a Load-lookup table different from an Array 5) What is the difference between an ASK and an INPUT parameter. 6) let $var = SQR RULES print $var (1,1,5) print $var (+1,5,0) What will the output of these print statements be? (Type in the answer below) 7) For this questions assume you are given the following report to build. The requirements are that after each break in diversity type the total net profit and total number of dealers in the diversity type should be printed (the bolded values inside the squares). And at the end of the report a grand total should be printed. The diversity type should only be printed for the first dealer of that diversity type. Assume you are connecting to the following table:
Diversity_Dealers dd_id diversity_type region_cd start_dt dealer_cd dealer_nm address INTEGER VARCHAR VARCHAR DATE VARCHAR VARCHAR VARCHAR
Page 2 of 7
Refer the mock up of the report below and write an SQR program that will use the above table to generate this report. (Note: dont worry about minor errors in syntax or getting the print placement parameters exactly correct. The idea here is to test your ability to use SQR to generate the report and meet the requirements.)
Page 3 of 7
African- GST American GST KC GST NY GST BOS CAT GST KC GST GST SF SF LA LA
10/01/96 12/08/97 12/09/92 11/11/91 09/19/97 10/05/89 02/27/90 02/09/98 07/15/91 12/19/94 08/07/97 10/31/96 02/19/93 08/01/97 01/28/98 05/16/96
J. PAULEY TOYOTA 6200 SOUTH 36TH STREET COURTESY OLDS-TOYOTA-GMC621 S. KNOXVILLE COURTESY OLDS-TOYOTA-GMC720 S. KNOXVILLE TEAGUE TOYOTA-CHEVY-OLDS1830 WEST HILLSBORO PHIL WRIGHT TOY-CHEV CO. 19TH & SOUTH ARKANSAS TODD ROONEY TOY GMC OLDS 1800 SOUTH DIVISION CONWAY TOYOTA 1110 COLLIER DRIVE LIBERTY TOYOTA 2520 E. BROADWAY LIBERTY TOYOTA 2714 E. BROADWAY LITTRELL TOYOTA 300 N. BROADWAY TROTTER TOYOTA 3010 AUTO DRIVE BALE TOYOTA 1110 COLLIER DRIVE RON GOODE TOYOTA, INC. This is a test RON GOODE TOYOTA, INC. 1815 CLEMENT ST BOB BAKER TOYOTA-LEMON GR 6800 FEDERAL BOULEVARD SOUTAR'S 631 W MAIN ST
FORT SMITH RUSSELLVILLE RUSSELLVILLE EL DORADO RUSSELLVILLE BLYTHEVILLE CONWAY WEST MEMPHIS WEST MEMPHIS BLYTHEVILLE PINE BLUFF CONWAY ALAMEDA ALAMEDA LEMON GROVE BARSTOW
AR AR AR AR AR AR AR AR AR AR AR AR CA CA CA CA
72903 72801 72801 71730 72801 72315 72032 72301 72301 72315 71601 72032 94501 10000 91945 92311
256 843 594 856 318 548 328 618 749 166 256 843 594 856 318 548
2516357 8547853 6598742 3515987 3658975 5482459 2135489 2549875 2516357 3515987 3658975 5482459 2135489 2549875 2516357 8547853
RAYMOND DAN W.B. DON VINCENT WILLIAM JAMES JOSEPH LAYTON JACK PATTI JACK ROBERT GLENN DENISE DORIAN
F L J F A J C J C A
BOURNE BOUTTE BOVARD BOWEN BOWEN BOWEN BOWER BOWERS BOWERS BOWKER BOWKER BOWKER JR BOWLING BOYD BOYLAND BOYLAND
Total 95
$34,681,067
Page 4 of 7
7) True or False, the SQR syntax does allow for a GOTO control structure. 8) What do the RTRIM and RPAD functions do? 9) Write an SQR program that offers a local procedure that allows a user to form a single string that will contain the value of a persons full name, Darrin Alan Miller for example. The SQR program should: A. Prompt the user for a persons first name, middle name, and last name B. Allow the user to enter the aforementioned values in upper, lower, or mixed case C. Prompt the user for the style of name they want to see (LFM, FML, LF, FL) D. Prompt the user with a choice whether or not they want the middle name portion of the resulting name to be abbreviated or not. If the user wants the abbreviated version of the middle name, then that name must be followed with a period. E. Return the persons full name with each word having its first character capitalized. F. If a persons last name is the first portion of the full name string created, then that last name should be followed by a comma and appropriately spaced G. Although the user may be requesting to see the persons middle name as part of the full name variable that is created, if the middle name is null (and it can be), then the logic for making this name part of the full name variable should be omitted. First Name DARRIN Darrin Darrin Middle Name Alan AlAN Last Name Miller Miller miller Style Abbr MN LFM Y FML Y FML Y Result Miller, Darrin A. Darrin Miller Darrin A. Miller
10) True or False, the attributes associated with a chart as declared within the DECLARE-CHART definition of an SQR program may be overridden by corresponding attributes within the PRINT-CHART command. 11). The creation of charts within an SQR program requires the use of what type of in memory data type: A. An array B. A load-lookup C. A file D. A cursor E. A select statement 12) True or False, the use of arrays within an SQR program should be avoided because they can not be dynamically sized and therefore may obtain more OS memory than needed. 13) What are the methodologies available to pass user parameters into an SQR program? A. INPUT B. PROMPT C. ASK
Page 5 of 7
D. E. F. G.
Choices A and B above Choices B and C above Choices A and C above All of the above
14) True or False, user parameters passed to an SQR program via the INPUT command retrieve a compile-time substitution variable. 15) Within a BEGIN-SQL paragraph various DDL and DML commands such as creates, drops, updates, etc. can be issued against the RDBMS. The ability to issue these types of commands is determined and constrained by the A. RDBMS privileges assigned to the database administrator B. RDBMS privileges assigned to Dan Thornhill C. RDBMS privileges assigned to the user executing the SQR program D. roles, grants, and synonyms assigned to the user executing the SQR program E. SQR program designer 16) Which SQR section is responsible for defining and controlling information that is to be printed at the top of each output page? 17) An & variable within SQR A. May represent and store a numeric value selected from the RDBMS B. May represent and store a string value selected from the RDBMS C. Is a read only variable D. A, B, and C above E. None of the above 18) Referring to the excerpt of SQR code that follows and assuming that the procedure queried 10 rows of data and that each row possessed a value of 10.00 for the PROD_PRICE column, what will be the value of the #product_total variable that is displayed?
BEGIN-PROCEDURE CALC_FIGURES LET #PRODUCT_TOTAL = 100 BEGIN-SELECT PROD_CODE &PROD_CODE PROD_PRICE &PROD_PRICE LET #PRODUCT_TOTAL = (#PRODUCT_TOTAL + &PROD_PRICE) FROM PRODUCTS WHERE PROD_CODE = 1709 END-SELECT DISPLAY #product_total END-PROCEDURE
19) Referring to the excerpts of SQR code that follow, will the contents of #PROD_TOTAL in both excerpts be the same after program execution has completed?
Page 6 of 7
BEGIN-PROCEDURE CALC_FIGURES BEGIN-SELECT PROD_CODE &PROD_CODE PROD_PRICE &PROD_PRICE LET #PROD_TOTAL = (#PROD_TOTAL + &PROD_PRICE) FROM PRODUCTS WHERE PROD_CODE = 1709 END-SELECT END-PROCEDURE
BEGIN-PROCEDURE CALC_FIGURES BEGIN-SELECT PROD_CODE &PROD_CODE SUM(PROD_PRICE) &PROD_TOTAL MOVE &PROD_TOTAL TO #PROD_TOTAL FROM PRODUCTS WHERE PROD_CODE = 1709 END-SELECT END-PROCEDURE
20) & variables within SQR are assigned during the processing of what type of SQR paragraph? A. BEGIN-SQL B. BEGIN-PROCEDURE C. BEGIN-ERROR D. BEGIN-SELECT E. BEGIN-PROGRAM Use the following excerpts of SQR code to answer following questions.
Program Excerpt A: BEGIN-PROCEDURE GET_CUSTOMERS BEGIN-SELECT C.NAME (1,1) O.ORDER_DATE (1,35) O.ORDER_NUM (1,50) NEXT-LISTING FROM CUSTOMERS C, ORDERS O WHERE C.CUST_NUM = O.CUST_NUM ORDER BY C.NAME END-SELECT END-PROCEDURE Program Excerpt B: BEGIN-PROCEDURE BEGIN-SELECT C.NAME C.CUST_NUM DO GET_ORDERS FROM CUSTOMERS C ORDER BY C.NAME END-SELECT END-PROCEDURE GET_CUSTOMERS (+1,1) &LE_NUMBER
BEGIN-PROCEDURE GET_ORDERS BEGIN-SELECT O.ORDER_DATE (0,35) O.ORDER_NUM (0,50) FROM ORDERS WHERE CUST_NUM = &LE_NUMBER END-SELECT END-PROCEDURE
21) The &LE_NUMBER portion of code is known as a: A. blind variable B. bound variable C. flexible variable D. bind variable E. substitution variable 22) If the CUSTOMERS table contains 20 rows, and the ORDERS table contains 20 rows, and these tables have 10 rows with matching CUST_NUM values, will both programs achieve the same results? 23) The code within Program Excerpt B can be described as: A. a correlated sub-query
Page 7 of 7
B. C. D. E.
24) How many distinct queries are being issued to the RDBMS within Program Excerpt B 25) Modify the excerpts of SQR code above related to the previous questions so that possible errors encountered from the RDBMS will be handled.