home *** CD-ROM | disk | FTP | other *** search
/ Delphi Magazine Collection 2001 / Delphi Magazine Collection 20001 (2001).iso / DISKS / Issue54 / Persist / cSQL.pas < prev    next >
Encoding:
Pascal/Delphi Source File  |  2000-01-21  |  4.8 KB  |  189 lines

  1. {* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
  2.   (c) TechInsite Pty. Ltd.
  3.   PO Box 429, Abbotsford, Melbourne. 3067 Australia
  4.   Phone: +61 3 9419 6456
  5.   Fax:   +61 3 9419 1682
  6.   Web:   www.techinsite.com.au
  7.   EMail: peter_hinrichsen@techinsite.com.au
  8.  
  9.   Created: Jan 2000
  10.  
  11.   Notes: SQL uses in the address book application
  12.  
  13. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *}
  14. unit cSQL;
  15.  
  16. interface
  17. const
  18.  
  19.   // Read the primary key (oid & name) of all people
  20.   cSQLPersonRead_PK =
  21.     'select        ' +
  22.     '  oid         ' +
  23.     ' ,last_name   ' +
  24.     ' ,first_name  ' +
  25.     'from          ' +
  26.     '  person      ' +
  27.     'order by      ' +
  28.     '  last_name   ' +
  29.     '  ,first_name ' ;
  30.  
  31.   // Given a person's OID, read their details
  32.   cSQLPersonRead_Detail =
  33.     'select        ' +
  34.     '  title       ' +
  35.     ' ,initials    ' +
  36.     ' ,notes       ' +
  37.     'from          ' +
  38.     '  person      ' +
  39.     'where         ' +
  40.     '  oid = :oid  ' ;
  41.  
  42.   // Given a person's OID, update their details
  43.   cSQLPersonUpdate =
  44.     'update person ' +
  45.     'set           ' +
  46.     ' last_name   = :last_name  ' +
  47.     ' ,first_name = :first_name ' +
  48.     ' ,title      = :title      ' +
  49.     ' ,initials   = :initials   ' +
  50.     ' ,notes      = :notes      ' +
  51.     'where                      ' +
  52.     '  oid        = :oid        ' ;
  53.  
  54.   // Insert a new person
  55.   cSQLPersonCreate =
  56.     'insert into person ' +
  57.     '(                  ' +
  58.     ' OID               ' +
  59.     ' ,last_name        ' +
  60.     ' ,first_name       ' +
  61.     ' ,title            ' +
  62.     ' ,initials         ' +
  63.     ' ,notes            ' +
  64.     ')                  ' +
  65.     'values             ' +
  66.     '(                  ' +
  67.     ' :OID              ' +
  68.     ' ,:last_name       ' +
  69.     ' ,:first_name      ' +
  70.     ' ,:title           ' +
  71.     ' ,:initials        ' +
  72.     ' ,:notes           ' +
  73.     ')                  ' ;
  74.  
  75.   // Delete a person
  76.   cSQLPersonDelete =
  77.     'delete from person ' +
  78.     'where OID = :OID   ' ;
  79.  
  80. {
  81.   cSQLPersonRead_notes =
  82.     'select        ' +
  83.     '  oid         ' +
  84.     '  ,owner_oid  ' +
  85.     ' ,notes       ' +
  86.     'from          ' +
  87.     '  notes       ' +
  88.     'where         ' +
  89.     '  owner_oid = :owner_oid  ' ;
  90. }
  91.  
  92.   cSQLPersonAddressRead =
  93.     'select       ' +
  94.     '  oid        ' +
  95.     ' ,owner_oid  ' +
  96.     ' ,adrs_type  ' +
  97.     ' ,lines      ' +
  98.     ' ,state      ' +
  99.     ' ,pcode      ' +
  100.     ' ,country    ' +
  101.     'from         ' +
  102.     '  adrs       ' +
  103.     'where        ' +
  104.     ' owner_oid = :owner_oid ' ;
  105.  
  106.   cSQLPersonEAddressRead =
  107.     'select                   ' +
  108.     '   oid                   ' +
  109.     '  ,owner_oid             ' +
  110.     '  ,eadrs_type            ' +
  111.     '  ,text                  ' +
  112.     'from                     ' +
  113.     ' eadrs                   ' +
  114.     'where                    ' +
  115.     '  owner_oid = :owner_oid ' ;
  116.  
  117.   cSQLPersonEAddressCreate =
  118.     'insert into EAdrs ' +
  119.     '(                 ' +
  120.     '   OID            ' +
  121.     '  ,Owner_OID      ' +
  122.     '  ,EAdrs_Type     ' +
  123.     '  ,Text           ' +
  124.     ')                 ' +
  125.     'Values            ' +
  126.     '(                 ' +
  127.     '   :OID           ' +
  128.     '  ,:Owner_OID     ' +
  129.     '  ,:EAdrs_Type    ' +
  130.     '  ,:Text          ' +
  131.     ')                 ' ;
  132.  
  133.   cSQLPersonEAddressUpdate =
  134.     'update EAdrs                ' +
  135.     'set                         ' +
  136.     '   Owner_OID  = :Owner_OID  ' +
  137.     '  ,EAdrs_Type = :EAdrs_Type ' +
  138.     '  ,Text       = :Text       ' +
  139.     'where                       ' +
  140.     '   OID        = :OID        ' ;
  141.  
  142.   cSQLPersonEAddressDelete =
  143.     'delete from EAdrs ' +
  144.     'where OID = :OID  ' ;
  145.  
  146.   cSQLPersonAddressCreate =
  147.     'insert into adrs ' +
  148.     '(                ' +
  149.     '  oid            ' +
  150.     ' ,owner_oid      ' +
  151.     ' ,adrs_type      ' +
  152.     ' ,lines          ' +
  153.     ' ,state          ' +
  154.     ' ,pcode          ' +
  155.     ' ,country        ' +
  156.     ')                ' +
  157.     'Values           ' +
  158.     '(                ' +
  159.     '  :oid           ' +
  160.     ' ,:owner_oid     ' +
  161.     ' ,:adrs_type     ' +
  162.     ' ,:lines         ' +
  163.     ' ,:state         ' +
  164.     ' ,:pcode         ' +
  165.     ' ,:country       ' +
  166.     ')                ' ;
  167.  
  168.   cSQLPersonAddressUpdate =
  169.     'update adrs               ' +
  170.     'set                       ' +
  171.     '  owner_oid  = :owner_oid ' +
  172.     ' ,adrs_type  = :adrs_type ' +
  173.     ' ,lines      = :lines     ' +
  174.     ' ,state      = :state     ' +
  175.     ' ,pcode      = :pcode     ' +
  176.     ' ,country    = :country   ' +
  177.     'where                     ' +
  178.     '  oid        = :oid       ' ;
  179.  
  180.   cSQLPersonAddressDelete =
  181.     'delete from adrs          ' +
  182.     'where                     ' +
  183.     '  oid        = :oid       ' ;
  184.  
  185.  
  186. implementation
  187.  
  188. end.
  189.