internal tables (1)

Upload: prathap-vijay

Post on 07-Jul-2018

221 views

Category:

Documents


0 download

TRANSCRIPT

  • 8/19/2019 Internal Tables (1)

    1/35

    INTERNAL TABLE

  • 8/19/2019 Internal Tables (1)

    2/35

    Kaavian Systems02-Sep-09

    Defnition

    ♦ Snap-shot o a database

    ♦ Dynamic Sequential dataset

    All eco ds ha!e same st uctu e " #ey ♦ E$ist only du in% un time o a p o% am

    2

  • 8/19/2019 Internal Tables (1)

    3/35

    Kaavian Systems02-Sep-09

    &u pose

    ♦ 'o p ocessin% la %e !olumes o data

    ♦ 'o educin% database hits

    ♦ 'o o mattin% data to ft the equi ements o the

    application

    E$ample (

    So tin%) t uncatin%) concatenatin%

    3

  • 8/19/2019 Internal Tables (1)

    4/35

    Kaavian Systems02-Sep-09

    Att ibutes o Inte nal Table

    ♦ Line type

    ♦ *ey

    ♦ Table type

    4

  • 8/19/2019 Internal Tables (1)

    5/35

    Kaavian Systems02-Sep-09

    Line Type

    ♦ It can be any data type

    ♦ Data type is no mally st uctu e

    ♦ Each component o a st uctu e is a column in

    inte nal table

    ♦ Line may also be elementa y o anothe inte nal table

    5

  • 8/19/2019 Internal Tables (1)

    6/35

    Kaavian Systems02-Sep-09

    *ey

    ♦ Standa d *ey +De ault #ey,

    ♦ se defned #ey

    6

  • 8/19/2019 Internal Tables (1)

    7/35

    Kaavian Systems02-Sep-09

    Table Type

    ♦ It dete mines ho. ABA& .ill access indi!idualtable ent ies/

    ♦ Types

    Standa d table 0 Inde$ed So ted table 0 Inde$ed

    1ashed table

    7

  • 8/19/2019 Internal Tables (1)

    8/35

    Kaavian Systems02-Sep-09

    Standa d Table

    ♦ 1a!e an inte nal linea inde$

    ♦ Access uses a linea sea ch

    ♦ Access eithe by #ey o inde$

    ♦ Al.ays non-unique

    ♦ Response time o #ey access is p opo tional to

    numbe o ent ies in table

    ♦ This can flled quic#ly2 no system chec#s onuniqueness o ent ies

    8

  • 8/19/2019 Internal Tables (1)

    9/35

    Kaavian Systems02-Sep-09

    So ted Table

    ♦ Al.ays sa!ed so ted by #ey

    ♦ 1a!e inte nal linea inde$

    ♦ Access eithe by #ey o inde$

    ♦ Table can be unique o non-unique

    ♦ Response time o #ey access is lo%a ithmically

    p opo tional to the no/ o ent ies since bina y sea ch

    is used

    9

  • 8/19/2019 Internal Tables (1)

    10/35

    Kaavian Systems02-Sep-09

    1ashed Table

    ♦ No inte nal linea inde$

    ♦ Access only usin% #ey

    ♦ Response time o access is independent o no/ o

    table ent ies since system accesses the table usin%hash al%o ithm

    ♦ Table #ey must be unique

    10

  • 8/19/2019 Internal Tables (1)

    11/35

    Accessin% Inte nal Tables

    3ou must access inte nal table line by line) usin% a .o # a ea as inte ace o t ans e in% data to "

    om table

  • 8/19/2019 Internal Tables (1)

    12/35

    Kaavian Systems02-Sep-09

    Types o 4o # A ea

    ♦ 1eade line

    ♦ E$plicitly defned

    Use only Work area,Do not use header line .

    12

  • 8/19/2019 Internal Tables (1)

    13/35

    Kaavian Systems02-Sep-09

    5 eatin% Inte nal Table

    Data/types like/type of [with header line] [initial size ].

    Data/types : be in of o!!urs "#,

  • 8/19/2019 Internal Tables (1)

    14/35

    Kaavian Systems02-Sep-09

    Ran%es Tables

    3ou can use the ollo.in% !a iants o the T3&ESand DATA statements to c eate inte nal tables o thesame type as selection tables/

    T3&ES6DATA 7 an%e tab8 T3&E RAN9E :' 7type8/o T3&ES6DATA 7 an%e tab8 LI*E RAN9E :' 7ob;8/

    This defnes inte nal standa d tables .hose linetype is a st uctu e as ollo.s(

    ♦ SI9N+. LI*E 7ob;8♦ 1I91 T3&E 7type8 b>. LI*E 7ob;8

    14

  • 8/19/2019 Internal Tables (1)

    15/35

    Kaavian Systems02-Sep-09

    :pe ations :n Inte nal Table

    ♦ 'illin% inte nal tables

    ♦ So tin% inte nal tables

    ♦ Ret ie!in% lines om inte nal tables

    ♦ 5han%in% an inte nal table

    ♦ 5ont ol Le!el & ocessin%

    15

  • 8/19/2019 Internal Tables (1)

    16/35

    Kaavian Systems02-Sep-09

    'illin% Inte nal Tables

    ♦ Appendin% lines usin% A&&END statement

    ♦ sin% INSERT statement

    ♦ sin% ?:@E statement

    ♦ Readin% om database !ia SELE5T command

    16

  • 8/19/2019 Internal Tables (1)

    17/35

    Kaavian Systems02-Sep-09

    sin% A&&END Statement

    Synta$This statement mo!e the contents o heade

    line o .o # a ea as the last line o the specifed

    inte nal table/&''()D to

    *his state+ent works only with inde ed table as -ast line is !al!ulated internally usin the

    internal inde

    17

  • 8/19/2019 Internal Tables (1)

    18/35

  • 8/19/2019 Internal Tables (1)

    19/35

    Kaavian Systems02-Sep-09

    sin% INSERT Statement

    $) ( * into *&0-(

    $) ( * into itab [$)D(1 ]

    19

  • 8/19/2019 Internal Tables (1)

    20/35

    Kaavian Systems02-Sep-09

    'illin%/// sin% ?:@E Statement

    5opyin% inte nal tables To copy enti e contents o one inte nal table to

    othe s use mo!e statement/

    234(

  • 8/19/2019 Internal Tables (1)

    21/35

    Kaavian Systems02-Sep-09

    'illin%/// sin% ?:@E Statement

    MOVE-CORRESPONDING TO

    This statement mo!es the contents o

    the components o st uctu e 7st uct

  • 8/19/2019 Internal Tables (1)

    22/35

    Kaavian Systems02-Sep-09

    sin% Desc ibe Statement

    DES5RIBE TABLE 7itab8 LINES 7l8 :55 RS

    7n8

    *IND 7#8T 0 Standa d Table

    S 0 So ted Table

    1 0 1ashed Table

    22

  • 8/19/2019 Internal Tables (1)

    23/35

    Kaavian Systems02-Sep-09

    sin% SELE5T 5ommand

    4e can fll inte nal table di ectly om database/

    DATA itCma a li#e table o ma a/

    SELE5T 'R:? ma a INT: TABLE itCma a

    41ERE matn Fm-

  • 8/19/2019 Internal Tables (1)

    24/35

    So tin% Inte nal Tables

    4e can so t a standa d o hashed table in a p o% am/ synta$(

    3 * [as!endin 6 des!endin ] [as te t] [stable] 07

  • 8/19/2019 Internal Tables (1)

    25/35

    Kaavian Systems02-Sep-09

    Ret ie!in% Lines

    ♦ Readin% the lines o inte nal table th ou%h heade

    line o .o # a ea) o e-o %ani>ation o

    manipulations o data/

    ♦ T.o .ays

    sin% L::& 0 AT statement/

    sin% READ statement

    25

  • 8/19/2019 Internal Tables (1)

    26/35

    Kaavian Systems02-Sep-09

    sin% L::& AT

    ♦ 'o e!e y eco d o inte nal table the eco d is

    mo!ed to the .o # a ea o heade line "

    can be accessed di ectly om heade line/

    L::& AT 7itab8 INT: 7.a8om 7n

  • 8/19/2019 Internal Tables (1)

    27/35

    Kaavian Systems02-Sep-09

    sin% READ Statement

    ♦ READ TABLE 7itab8 7#ey8 7 esult8

    ♦ READ TABLE 7itab8 INT: 7.a8 4IT1 *E3

    7#ey8 7!al8 5:?&ARIN97

  • 8/19/2019 Internal Tables (1)

    28/35

    Kaavian Systems02-Sep-09

    5han%in% An Inte nal Table

    4e can edit o chan%e the contents o aninte nal table a te it has been flled) usin%

    ?:DI'3 statement/

    Synta$ (

    23D$ 7 32 [* &) '3 *$); %% 6all fields] i n d e ,

    28

  • 8/19/2019 Internal Tables (1)

    29/35

    Kaavian Systems02-Sep-09

    5han%in% An Inte nal Table

    ♦ sin% 5:LLE5T Statement

    sin% DELETE Statement

    5:LLE5T INT:

    DELETE INDEK ]

    DELETE TABLE 'R:?

    29

  • 8/19/2019 Internal Tables (1)

    30/35

    Kaavian Systems02-Sep-09

    5ont ol Le!el & ocessin%

    It is allo.ed .ithin a L::& o!e an inte nal table/This means that you can di!ide sequences o

    ent ies into % oups based on the contents o

    ce tain felds/

    AT 7le!el8

    7statement bloc#8

    ENDAT

    30

  • 8/19/2019 Internal Tables (1)

    31/35

    Kaavian Systems02-Sep-09

    5ont ol Le!el & ocessin%

    We !an find the total of nu+eri! fields, inside these !ontroltate+ent blo!ks usin U2 state+ent.

    31

  • 8/19/2019 Internal Tables (1)

    32/35

    Kaavian Systems02-Sep-09

    Initiali>in% Inte nal Tables

    ♦ 5LEAR ♦ RE'RES1♦ 'REE

    =-(& =-(& [ ]

    32

  • 8/19/2019 Internal Tables (1)

    33/35

  • 8/19/2019 Internal Tables (1)

    34/35

    Kaavian Systems02-Sep-09

    E$e cise

    B, 5onside th ee inte nal tables .ith ollo.in% felds/Table < ?atn ) Desc iption/Table = ?atn ) &lant) uantity) :?) Amount/Table ?atn ) &lant) & ice/

    Assume suitable feld types .hile defnin% the

    inte nal tables/ &opulate suitable data +please lea!e Amount feld in Table = empty,/ 4 ite a p o% am to p ocess the contents o Table =/ 4 ite code to compute Amount feld and updateTable = as ollo.s/ se matn ) plant !alues omtable = and fnd the p ice om table / ?ultiply the

    uantity .ith this p ice to update Amount feld inTable =/

    4 ite code to display matn ) desc iption) plant)quantity) :?) & ice) Amount/

    34

  • 8/19/2019 Internal Tables (1)

    35/35

    THANK YOU