Query Course

download Query Course

of 44

Transcript of Query Course

  • 8/17/2019 Query Course

    1/44

    PROGRESS(Version 8.2A)

    BASIC QUERY COURSEUpdated Ma 2!!"

  • 8/17/2019 Query Course

    2/44

     

    #AB$E O% COES

     

    C'AP#ER *A#ABASE CO&CEP#S...................................................................+DATABASE........................................................................................................................ 1-1

    TABLE.............................................................................................................................. 1-1

     Record: (Row).........................................................................................................1-1

     Field: (Column)......................................................................................................1-1K EY: (U NIQUE IDENTIFIER )............................................................................................ 1-2

    I NDEX.............................................................................................................................. .1-2THE R ELATIONAL MODEL............................................................................................... .1-2

    C'AP#ER 2 USI&G #'E PROCE*URE E*I#OR.................................................2+CREATING A NEW PROGRAM........................................................................................... 2-1

    OPENING AN EXISTING PROGRAM................................................................................... 2-2

    SAING A PROGRAM........................................................................................................ 2-!EDITING A PROGRAM....................................................................................................... 2-"

     Entering Text............................................................................................................2-4

    Selecting Text...........................................................................................................2-4Cutting, Coping !nd "!#ting Text..........................................................................2-4

     $n!cti%!ting or Commenting Text............................................................................2-&

    Se!rc'ing Text..........................................................................................................2-& $n#erting ! Field !me into ! "rogr!m..................................................................2- 

    CHECKING# COMPILING# AND R UNNING A PROGRAM......................................................2-$

    C'ec*ing "rogr!m Snt!x.......................................................................................2-+ 

     Running ! "rogr!m.................................................................................................2-+ EDIT BUFFERS.................................................................................................................. 2-%

    iewing pen Edit u//er#.......................................................................................2-0

    IEWING DATABASE TABLES.......................................................................................... .2-%

    C'AP#ER , ACCESSI&G #'E *A#ABASE.........................................................,+R ETRIEING R ECORDS FROM THE DATABASE................................................................. !-1

     FR EC..............................................................................................................3-1

    WHERE expre##ion................................................................................................ 3-2BY expre##ion......................................................................................................... 3-3

     -C5................................................................................................................3-3

     F$6........................................................................................................................3-3WHERE expre##ion................................................................................................ 3-4

    OF  t!7le-n!me........................................................................................................3-&

    CONTROLLING ERROR  PROCESSING WITH FIND.............................................................!-&

  • 8/17/2019 Query Course

    3/44

     Progress Basic Query Course

     -ERRR..............................................................................................................3- 

    C'AP#ER - OPERA#ORS A&* %U&C#IO&S......................................................-+OPERATORS...................................................................................................................... "-1

     rit'metic per!tor#...............................................................................................4-1Comp!ri#on per!tor#............................................................................................4-1

     5eword#.................................................................................................................4-1FUNCTIONS...................................................................................................................... "-2PRECEDENCE.................................................................................................................... "-!

    C'AP#ER " CO&*I#IO&A$ PROCESSI&G........................................................."+IF'THEN'ELSE............................................................................................................ .-1

    ELSE  87loc*9#t!tement.........................................................................................&-1;#ing

    FIRST-OF !nd LAST-OF  Function#.......................................................................+- 

    ;#ing ACCUMULATE !nd ACCUM..................................................................... +- EXPORT STATEMENT...................................................................................................... $-$

    STREAM  #tre!m-n!me..........................................................................................+-+ 

    DELIMITER c'!r!cter.......................................................................................... +-+ 

    Table of Contents

  • 8/17/2019 Query Course

    4/44

     Progress Basic Query Course

    I&*E0........................................................................................................................I+

    Table of Contents

  • 8/17/2019 Query Course

    5/44

     

    C'AP#ER

    *A#ABASE CO&CEP#S 

    PROGRESS *+,+ ,/0/ 304+, +0*50*, 0 67, 30. A ,/0/ 304+,

    +8+0,9 ,/0,+ 3,,0 30 04/,+ 0 ,5; 0;, 3# 0;,,,# + 5050 90. A 304+, /, 50+ 0;, 304+, 3,0+ 3 30.

    D04+, 3,0+ 5/*3, 04/, 9,+# ,/3 9,+# ?,8 ,/3+# 3 3,>,+.

    DatabaseA 304+, + ,/,505 /6 +8+0,9 676 3 +06 30. I0 + /?, /6

    54,0 @;+,

  • 8/17/2019 Query Course

    6/44

     Progress Basic Query Course

    Key: (Unique Identifier

    I PROGRESS 0;,, , 0@ 08

  • 8/17/2019 Query Course

    7/44

     

    C'AP#ER

    USI&G #'E PROCE*URE E*I#OR 

    Y* 5 *+, 0;, P5,3*, E30 0 5,0,# 938 3 * PROGRESS 53, (

  • 8/17/2019 Query Course

    8/44

     Progress Basic Query Course

    E0ERCISE 

    . Open the Procedure Editor and type the following:

    FOR EACH admin NO-LOC:!"#PLA$ unum rnum %"&H ' COL()N*

    EN!*

    2. #a+e the program a, newprog*p.* /Refer to Sa1in a Prora3 on page 0*1,. Clo,e the program 2y ,electing %i4e C4ose from the menu 2ar*

     

    +,enin% an E!istin% 'r#%ra

    T

  • 8/17/2019 Query Course

    9/44

     Progress Basic Query Course

    E0ERCISE 2

    . Open the program newprog*p. u,ing the %i4e Open menu ,election* &ry

    opening it 2oth way,*2. Clo,e the program 2y ,electing %i4e C4ose from the menu 2ar*

     

    Sa*in% a 'r#%ra

    T +, ,@/8 5,0,3

  • 8/17/2019 Query Course

    10/44

     Progress Basic Query Course

    E0ERCISE ,

    . Open newprog*p.*2. Choo,e %i4e Sa1e from the menu 2ar*

    ,. &he program ha, 2een ,a+ed again a, newprog*p.*

    -. Choo,e %i4e Sa1e As from the menu 2ar*". #a+e the program a, copyprog*p.*. Open copyprog*p. in the Procedure Editor*/. Clo,e 2oth program,* 

    Editin% a 'r#%ra

    T;, P5,3*, E30 ,4/,+ 8* 0 0

    S,/,50 0,>0

    C*0# 50

    S,5; @3# 0 @// 4, +,0,3 3 0;, 5*+ ,0 4/5?.

    Chapter ": #sing the Procedure $ditor 

  • 8/17/2019 Query Course

    11/44

     Progress Basic Query Course

     nactiating or Commenting Te%t 

    Y* 5 500, (599,0)# 0;, 0; 3,/,0,# /,+ 53, @0; 8* 0.

    C;+, Sear/" )ind 're*i#us (S4I)T0)3 0 3 0;, 0. C;+, Sear/" Re,la/e ($TRL0R 0 3 +

  • 8/17/2019 Query Course

    12/44

     Progress Basic Query Course

     nserting a Field *ame into a Program

    Y* 5 +,0 ,/3 9, 3,50/8 9 04/, 3,0 0 0;, 5*++

  • 8/17/2019 Query Course

    13/44

     Progress Basic Query Course

    ". W;, 8* , 3, 9?6 8* +,/,50+ 0;, F,/3 S,/,50 +5,,# 5/5? 0;, -+K. 4*00. Y* ,/3+ @// 4, +,0,3 0 8*

  • 8/17/2019 Query Course

    14/44

     Progress Basic Query Course

    E0ERCISE "

    . Open copyprog*p.*2. Chec5 the ,ynta* "f there are any error,8 correct them*,. Run the program*

     

    E0ERCISE "A

    Create ,ynta error, and u,e the Re5ent Messaes6Messaes option, to +iew theerror,* 

    Edit Buffers

    A ,30 4*, + 0,9

  • 8/17/2019 Query Course

    15/44

     Progress Basic Query Course

    W;, 8* +,/,50 T##ls Data Adinistrati#n Database Re,#rts# PROGRESS

     

  • 8/17/2019 Query Course

    16/44

     

    C'AP#ER

    ACCESSI&G #'E *A#ABASE 

    PROGRESS

  • 8/17/2019 Query Course

    17/44

     Progress Basic Query Course

    N#te: E>99

  • 8/17/2019 Query Course

    18/44

     Progress Basic Query Course

    O/8 ,53+ @0; *9 4,6 ,0,,3.

    T;, ,0,,3 ,53+ 4,6 +0,3 3,+5,36 7< 53, 3,.

    **9# *9# /,6/ 9,# 3 0> 7< 53, 4,6 3+ to ,ort retrie+ed record, 2y initial lia2ilitydate in de,cending order*

    2. Chec5 the ,ynta and run the program*,. #a+e the program a, foreach?*p.* 

     *.23.C4 

    T"e N+;L+$K 5eyrd6 alt"#u%" #,ti#nal6 s"#uld al&ays be used

  • 8/17/2019 Query Course

    19/44

     Progress Basic Query Course

    N#te: E>9emp m?emp*EN!* 34 for each admin 43

  • 8/17/2019 Query Course

    20/44

  • 8/17/2019 Query Course

    21/44

     Progress Basic Query Course

    $#ntr#llin% Err#r 'r#/essin% &it" )IND

    PROGRESS

  • 8/17/2019 Query Course

    22/44

     

    C'AP#ER

    OPERA#ORS A&* %U&C#IO&S 

    M8 +0

  • 8/17/2019 Query Course

    23/44

     Progress Basic Query Course

    )un/ti#ns

    PROGRESS

  • 8/17/2019 Query Course

    24/44

     Progress Basic Query Course

    're/eden/e

    PROGRESS *+,+ +

  • 8/17/2019 Query Course

    25/44

     

    C'AP#ER

    CO&*I#IO&A$ PROCESSI&G

     

    C30/ emp m?emp*

  • 8/17/2019 Query Course

    26/44

     Progress Basic Query Course

    N#te: I E>9

  • 8/17/2019 Query Course

    27/44

     Progress Basic Query Course

     *esting 7ultiple F &tatements

    PROGRESS //@+ 8* 0 0;, +00,9,0 + 0;, +9,# ,63/,++ 0;, *94,

    IF +00,9,0+ *+,3.

    N#te: T;+ ,>966 NO-LOC:

    "F ,tatu,9cd @ '. &HEN !O:"F 7uarterly*m?emp =@ '066 &HEN !O:F"N! admin %HERE admin*unum @ 7uarterly*unum and  admin*rnum @ 7uarterly*rnum

    NO-LOC NO-ERROR*"F AA"LA

  • 8/17/2019 Query Course

    28/44

     Progress Basic Query Course

    E0ERCISE 2

    . Read the admin ta2le for all record, with an initial lia2ility date after 6G3?63>66?*2. Find the related 7uarterly record for >66-'8 u,ing the where clau,e*,. "f the 7uarterly i, a+aila2le8 chec5 the meei code* "f it i, '8 or B8 di,play the

    account num2er and #ingle.* "f it i, >8 di,play the account num2er and )a,ter.*Otherwi,e8 di,play the account num2er and #u2unit.*

    -. "f it i, not a+aila2le8 di,play the account num2er and No uarterly for >66-'.*

    ". Chec5 the ,ynta and run the program*. #a+e the program a, ifne,t*p.* 

    Chapter

  • 8/17/2019 Query Course

    29/44

     

    C'AP#ER

    *E%I&E S#A#EME 

    T;, DEFINE +00,9,0 ,4/,+ 8* 0 5,0, 0,9

  • 8/17/2019 Query Course

    30/44

     Progress Basic Query Course

    DE$IMALS n

    T;, n 350,+ 0;, *94, 3,59/

  • 8/17/2019 Query Course

    31/44

     Progress Basic Query Course

     *.2#*!.

    T;+ ?,8@3 5*+,+ PROGRESS 0 ,/,+, 0;, +06, ++50,3 @0; 0;, 4/, @;,

    0;, ,5*0,+.

    !EF"NE AR"A

  • 8/17/2019 Query Course

    32/44

     Progress Basic Query Course

    N#te: T;+ 53, + 0?, 9 0;, / 9

  • 8/17/2019 Query Course

    33/44

     Progress Basic Query Course

     u//er-n!me + 9, 0;0 8* ++6 0 0;, 330/ ,53 4*,. G,,//8# 0;, 9,+;*/3 50 +9, ,,,5, 0 0;, 04/, @0; @;5; 0 + ++50,3 3 3,08 0;,

     4*,+ 50,0+.

    N#te: T;, ,53 4*,

  • 8/17/2019 Query Course

    34/44

     Progress Basic Query Course

    Definin% +ut,ut Streas

    PROGRESS *+,+ 3,*/0 *0

  • 8/17/2019 Query Course

    35/44

     

    C'AP#ER

    GE&ERA#I&G REPOR#S

     

    R,0,6 30 9 0;, 304+, + /8 *+,*/ 8* 5

  • 8/17/2019 Query Course

    36/44

     Progress Basic Query Course

    PAGE STREAM C*+,+ 0;, *0

  • 8/17/2019 Query Course

    37/44

     Progress Basic Query Course

    S'A$E ? (n @ 

       3,0,+ 0;, *94, +0 0,9 + 3+

  • 8/17/2019 Query Course

    38/44

     Progress Basic Query Course

    E0ERCISE 2

    Create a program that read, 2oth the admin and 7uarterly ta2le,* !i,play whate+erfield, you de,ire8 2ut ma5e ,ure to include a FOR)A&. ,tatement for at lea,t one of them* (,e #PACE and #"P to help format the report* Output the report to a filenamed myrept*ttD* Eperiment with what you ha+e learned8 u,ing any,tatement,3command, we ha+e co+ered in the cour,e to thi, point* 

     !efining .utput &treams

    T;, DEFINE STREAM +00,9,0 5 4, *+,3 0 3,, 330/ *0

  • 8/17/2019 Query Course

    39/44

     Progress Basic Query Course

     /ggregate2Phrase &ynta%:

     /unction LABEL  /unction-identi/ier  BY 7re!*-group

    LABEL  function2identifier 

    A++6+ /4,/ 0 0;, 66,60,3 /*, 3+

  • 8/17/2019 Query Course

    40/44

     Progress Basic Query Course

    FIRST-OFJLAST-OF (7re!*-group)

    N#te: T;, FIRST-OF of >66-' and gi+e a count of the record,* Hint: &he aggregation, you need are AERAIE and CO(N&* 

    Chapter A: >enerating Reports

    E0AMP$E 2

    FOR EACH 7uarterly NO-LOC (#E-"N!E y7ur %HERE yr @ >66 AN! ,tatu,9cd @ '.

  • 8/17/2019 Query Course

    41/44

     Progress Basic Query Course

    E1'+RT Stateent

    T;, EXPORT +00,9,0 5 4, *+,3 0 *0

  • 8/17/2019 Query Course

    42/44

     

    I&*E0

     

    A

    ACCUM +00,9,0# $-&

    ACCUMULATE +00,9,0# $-&

    A66,60,-# 1-2K,8# 1-2

    F,6 ?,8# 1-2

    P98 ?,8# 1-2T4/,# 1-1

    F,/3# 1-1R,53# 1-1

    D04+, 3,0+# 1-1D04+, 04/,+

    C0,0+ 3 ,/0+;

  • 8/17/2019 Query Course

    43/44

  • 8/17/2019 Query Course

    44/44

     Progress Basic Query Course

    R,/0/ 93,/# 1-2

    R,