66 downloads
301 Views
426KB Size
Report
This content was uploaded by our users and we assume good faith they have the permission to share this book. If you own the copyright to this book and it is wrongfully on our website, we offer a simple DMCA procedure to remove your content from our site. Start by pressing the button below!
Report copyright / DMCA form
FBGBKL?JKL?J:PBB :JKL
NZdmevl_lijbdeZ^ghcfZl_fZlbdbbf_oZgbdb DZn_^jZl_ogbq_kdhcdb[_jg_lbdb bZ\lhfZlbq_kdh]hj_]mebjh\Zgby
JZajZ[hldZijbeh`_gbc[Za^Zgguo \kj_^_Delphi F_lh^bq_kdh_ihkh[b_dki_pdmjkm ©Ijh]jZffbjh\Zgb_bgnhjfZpbhgguokbkl_fª ^eyklm^_glh\dmjkZ^/hbdmjkZ\/h nZdmevl_lZIFF KhklZ\bl_evJm^Ze_\<=
2
Ij_^bkeh\b_ >Zggh_ ihkh[b_ ij_^gZagZq_gh klm^_glZf dmjkZnZdmevl_lZijbdeZ^ghcfZ l_fZlbdbbf_oZgbdb<=M<ihkh[bbbaeZ]Zxlkyhkgh\ukha^Zgbyijbeh`_gbc [Za^Zgguo\kj_^_Delphi ^eyWindows 95. Delphi - fhsgZymgb\_jkZevgZykbk l_fZ ijh]jZffbjh\Zgby ^ey Windows gZ hkgh\_ yaudZ Object Pascal, \dexqZx sZy \ k_[y kj_^kl\Z ih^^_j`db [Za ^Zgguo ;> Hkgh\guf gZijZ\e_gb_f bk ihevah\Zgby Delphi y\ey_lky jZajZ[hldZZ\lhghfguoi_j_ghkbfuo dhff_jq_ kdboijbeh`_gbcmf_xsbojZ[hlZlvdZdkehdZevgufblZdbkm^Ze_ggufb[Z aZfb^Zgguo\kj_^_deb_gl-k_j\_jkha^Zgb_jZkij_^_e_gguobgnhjfZpbhgguo kbkl_fKj_^b[eb`ZcrboZgZeh]h\bdhgdmj_glh\Delphi \wlhch[eZklb fh` ghhlf_lblvClarion,KBuilder, Power Builder b, hlqZklbVisual Basic.) Delphi wlh bgkljmf_gl ijh]jZffbklZ Z g_ dhg_qgh]h ihevah\Zl_ey >ey i_j\hgZqZev gh]hbamq_gbyKM;>b^eyj_r_gbyijhkluoaZ^ZqihZ\lhfZlbaZpbbhnbkguo jZ[hl [he__ m^h[gufb y\eyxlky ki_pbZebabjh\Zggu_ kbkl_fu bgl_jij_lb jmxs_]hlbiZgZijbf_jVisual FoxPro, Microsoft Access bebParadox. P_evx ihkh[by g_ y\ey_lky kbkl_fZlbabjh\Zggh_ baeh`_gb_ kijZ\hqghc bgnhjfZpbb?]haZ^ZqZkhklhbl\^jm]hf: [ukljhgZmqblvklm^_glZg_aZ\bkb fhhlmjh\gy_]hih^]hlh\dbhkgh\Zfkha^Zgbyijh]jZff^ey[Za^Zgguoey m]em[e_ggh]h bamq_gby fZl_jbZeZ fh]ml [ulv j_dhf_g^h\Zgu dgb]b [1-3]YaudSQL ijhs_\k_]hhk\hblvih[4].<[5] hibkZgZf_lh^bdZijh_dlbjh \Zgby[Za^Zgguo kbkihevah\Zgb_f k_j\_jZInterBase>eyi_j\hgZqZevgh]hha gZdhfe_gby k Delphi fh`gh bkihevah\Zlv f_lh^bq_kdb_ mdZaZgby [9-11]. :[kh exlghg_h[oh^bfufbgkljmf_glhfijbex[hcjZ[hl_kDelphi y\ey_lky\kljh _ggZykijZ\hqgZykbkl_fZZijbj_r_gbbkeh`guoaZ^ZqqZklhijboh^blkybam qZlvbbkoh^gu_l_dklu[b[ebhl_db \bamZevguodhfihg_glh\. JZ[hlZkihkh[b_fij_^iheZ]Z_lagZgb_hkgh\[Za^ZgguobKM;>\jZf dZodmjkZ©;Zau^Zgguobwdki_jlgu_kbkl_fuªqblZ_fh]hgZdmjk_^hn-lZ IFFmf_gb_ihevah\ZlvkyklZg^Zjlgufb\bamZevgufbdhfihg_glZfbDelphi. Baeh`_gb_hkgh\ZghgZ\_jkbyoDelphi 3.0-4.0 Client/Server Suite.
3
F_lh^bdZkha^Zgbyijbeh`_gbc <\_^_gb_ Kj_^kl\ZjZ[hluk[ZaZfb^Zgguo\Delphi fh`ghjZa^_eblvgZ^\_]jmiiu • mgb\_jkZevgu_mlbeblukjZa\blufihevah\Zl_evkdbfbgl_jn_ckhfDataBase Desktop, ReportSmith, DataBase Explorer). • dhfihg_glu Delphi ^ey jZajZ[hldb Z\lhghfguo ijh]jZff \_^_gby [Za ^Zgguo. Mgb\_jkZevgu_mlbebluij_^klZ\eyxlkh[hckbevghmijhs_ggu_\ZjbZg luh[uqguoKM;> k \_kvfZh]jZgbq_ggufb\hafh`ghklyfb Ihwlhfmbop_e_ khh[jZagh bkihevah\Zlv ebrv \ dZq_kl\_ \kihfh]Zl_evgh]h bgkljmf_glZ gZ ijbf_j^eykha^Zgbybebbaf_g_gbykljmdlmju[Zau^ZgguohleZ^dbaZijhkh\ bl^ Fu[m^_fjZkkfZljb\Zlvlhevdhgh\u_ki_pbnbqgu_^eyDelphi kj_^kl\Z jZajZ[hldb gZ hkgh\_ dhfihg_glh\ < qZklghklb jZkkfhljbf h[smx f_lh^bdm jZajZ[hldbbkihevah\Zgb_dhfihg_glh\^hklmiZd[ZaZf^Zgguob\bamZevguo dhfihg_glh\kha^Zgbyihevah\Zl_evkdh]hbgl_jn_ckZ I_j_^ gZqZehfjZ[hluk;>g_h[oh^bfhm[_^blvkyqlhgZ`_kldbc^bkd dhfivxl_jZ mklZgh\e_gZ[b[ebhl_dZBDE (Borland DataBase Engineijhp_kkhj [Za ^Zgguo). NZceu BDE aZibku\Zxlky ijh]jZffhc mklZgh\db Delphi. JZkih eh`_gb_BDE j_]bkljbjm_lky\j__klj_Windows. BDE j_Zebah\Zg\\b^_^bgZ fbq_kdbaZ]jm`Z_fuo[b[ebhl_dDLL <BDE \oh^yl^jZc\_jugbadhmjh\g_ \h]h ^hklmiZ d nZceZf ;> jZaguo nhjfZlh\ ^jZc\_ju yaudh\hc ih^^_j`db bgl_jij_lZlhju SQL b^jBgl_jn_ckh[jZam_fucnmgdpbyfbBDE, ba\_kl_g ih^ gZa\Zgb_f IDAPI. BDE y\ey_lky ihkj_^gbdhf f_`^m ijbeh`_gb_f b ;>, hk\h[h`^Zxsbf ijbeh`_gb_ (gh g_ jZajZ[hlqbdZ) hl g_h[oh^bfhklb agZgby ^_lZe_c^hklmiZdnZceZff_klhgZoh`^_gbynZceh\b^Z`_hlqZklbhlZjob l_dlmju;>Dhg_qgmxj_ZebaZpbxex[uo^_ckl\bck;>[_j_lgZk_[y^jZc\_j BDE. BDEih^^_j`b\Z_ljZ[hlmknZceZfbi_jkhgZevguoKM;>Paradox (*.db), dBase-kh\f_klbfuoKM;>*.dbf),bknZceZfbm^Ze_gguo[Za^ZgguojZkiheh `_gguogZSQL-k_j\_jZoInterBase, Oracle, Informix b^j.:jobl_dlmjZBDE hl djulZbfh`_l[ulv^hiheg_gZgh\ufb^jZc\_jZfb Dkh`Ze_gbxBDE lZd^hdhgpZbg_[uehleZ`_gjZajZ[hlqbdZfb<ih ke_^g_c \_jkbb Delphi 5 l_ogheh]by BDE ihkl_i_ggh \ul_kgy_lky ?) Ihy\b ebkvdhfihg_glugZhkgh\_[he__mgb\_jkZevghcl_ogheh]bb^hklmiZd^Zgguf ADO nbjfuMicrosoft^ey^hklmiZd;>InterBase kha^ZgZhl^_evgZyki_pbZeb abjh\ZggZyebg_cdZdhfihg_glh\bkihevamxsboAPI wlhcKM;>BDE ^eygbo g_lj_[m_lky H^gZdh wlbgh\u_\hafh`ghklbg_f_gyxsb_kmlb\hijhkh\fu jZkkfZljb\Zlvg_[m^_flZddZdgZfhf_glgZibkZgbyihkh[byyg\Zjv] Delphi 5 _s_ g_ ihemqbeZ rbjhdh]h jZkijhkljZg_gby \hafh`gh ih ijbqbg_ ljZ^bpbhgghaZ\ur_gguokbkl_fguolj_[h\ZgbcRAM g_f_gvr_ 64M bli
4
IjbjZ[hl_kBDE j_dhf_g^m_lkykha^Z\ZlvZebZku:ebZk (Alias, ik_\^h gbf -mkeh\gh_h[hagZq_gb_ki_pbnbdZpbbdZlZeh]Z]^_gZoh^ylkynZceu;> GZijbf_jijbmklZgh\d_Delphi Z\lhfZlbq_kdbkha^Z_lkyZebZkDBDEMOS ^ey h[hagZq_gby dZlZeh]Z \DELPHI3\DEMOS\DATA\ ]^_ ojZgylky nZceu ^_fhgkl jZpbhgguo b mq_[guo [Za ^Zgguo J_dhf_g^m_lky \ ijh]jZffZo bkihevah\Zlv bf_ggh ZebZku Z g_ dhgdj_lgu_ bf_gZ dZlZeh]h\ < wlhf kemqZ_ ijh]jZffu ijbh[j_lZxl ^hihegbl_evgmx ]b[dhklv ijb baf_g_gbb f_klhiheh`_gby nZc eh\g_lg_h[oh^bfhklbi_j_^_eu\Zlvijh]jZffmZ^hklZlhqghi_j_hij_^_eblv ik_\^hgbf k ihfhsvx gZijbf_j mlbeblu DB Explorer. InterBase ojZgyl ky\h^ghfnZce_ gdb>Zevg_cr__baeh`_gb_hjb_glbjh\ZghgZbkihevah\Z gb_lZ[ebpParadox bInterBase. Kha^Zgb_ kljmdlmju lZ[ebpu b __ aZiheg_gb_ bgnhjfZpb_c fh`_l \u ihegylvky g_kdhevdbfb kihkh[Zfb: ki_pbZebabjh\Zggufb KM;> lbiZ Paradox beb FoxPro ih^^_j`b\Zxsbfb lj_[m_fuc nhjfZl ^Zgguo, mlbeblZfb Data Base Desktop (DBD) bebDB Explorer, kihfhsvxdhfihg_glh\Delphi. G_h[oh^bfh mqblu\Zlv qlh DBD iehoh jZ[hlZ_l k dbjbeebq_kdbfb rjbnlZfbb g_bkihevam_l\k_o\hafh`ghkl_cInterBase.Ihwlhfmhkgh\gh_ gZagZq_gb_ DBD – kha^Zgb_ beb baf_g_gb_ kljmdlmju ehdZevguo lZ[ebp bg ^_dkh\b^jm]bof_lZ^Zgguo MlbeblZDB Explorer^jm]h_gZa\Zgb_SQL Explorer) k\h[h^gZhlwlbog_ ^hklZldh\bfh`_lijbf_gylvky^ey\\h^ZbgnhjfZpbbbhleZ^dbSQL-aZijhkh\. Hkh[_gghm^h[gZhgZijbjZ[hl_kInterBaseldiha\hey_lkha^Z\Zlvbbaf_gylv f_lZ^Zggu_ InterBase\lhfqbke_kljmdlmjmlZ[ebpH^gZdhbmDB Explorer ijb]hlh\e_gu©kxjijbauª^eyihevah\Zl_ey Hkgh\gu_dhfihg_glu Ex[h_ ijbeh`_gb_ jZ[hlZxs__ k ;> ^he`gh kh^_j`Zlv \ k\h_f khklZ\_ dZd fbgbfmfljbdhfihg_glZ TQuery\uiheg_gb_SQL-aZijhkh\d;>)beb TStoredProc \uiheg_gb_ojZgbfuogZk_j\_j_;>ijhp_^mj .
5
<ijhkl_cr_fkemqZ_bkihevamxlkyljbdhfihg_glZTTable, TDataSource bTDBGrid.JZkkfhljbff_lh^bdmbobkihevah\Zgby Dhfihg_gl TTable hibku\Z_l eh]bq_kdmx \bjlmZevgmx lZ[ebpm - h[jZa nbabq_kdhclZ[ebpunZceZ^Zgguo K_cqZki_j_qbkebflhevdhhkgh\gu_,\k_ ]^Zbkihevam_fu_k\hckl\Z TTable, ^hklmigu_q_j_abgki_dlhjh[t_dlh\ DataBaseName,lbi String - kh^_j`bleb[hZebZk[Zau^Zgguoeb[hihe gmxki_pbnbdZpbxdZlZeh]Z]^_gZoh^ylkynZceu;> TableName: TFileName - bfy lZ[ebpu Wlb ^\Z k\hckl\Z ij_^gZagZq_gu ^eyijb\yadbTTable dnbabq_kdhclZ[ebp_q_j_aBDE. Name - bfy wda_fieyjZ dhfihg_glZ \ ijh]jZff_ Ih mfheqZgbx bf__l agZq_gb_Table1. ActivelbiBoolean - mklZgh\dZActive \True hldju\Z_llZ[ebpmb^_eZ_l__ ^hklmighc^eyijhkfhljZIhmfheqZgbx- False. eywlh]hgZ^hmdZaZlv\ _]hk\hckl\_DataSet: TDataSet bfyagZq_gb_k\hckl\Z Name wda_fieyjZTTable. AZ^ZqZdhfihg_glZTDBGrid (©k_ldZ^Zgguoª -hlh[jZ`_gb_bj_^Zdlbjh \Zgb_ ^Zgguo gZ wdjZg_ \ lZ[ebqghf \b^_ Qlh[u k\yaZlv DBGrid k ^Zggufb
6
gZ^hmdZaZlv\_]hk\hckl\_DataSource bfydhfihg_glZTDataSource, q_j_adh lhjuci_j_^Zxlky^Zggu_ ;eZ]h^Zjy bkihevah\Zgbx dhfihg_glZ TDataSource dhfihg_gl TDBGrid klZgh\blky[he__ki_pbZebabjh\ZggufZke_^h\Zl_evgh[he__ijhklufbm^h[ guf?]haZ^ZqZ-lhevdh\bamZevgh_ij_^klZ\e_gb_^ZgguoTDBGrid g_aZ\bkbl gbhlnhjfZlZnZceh\gbhlbf_gbdhgdj_lghclZ[ebpu_]h©agZ_lªTable), gb hldhgdj_lgh]hlbiZgZ[hjZ^Zgguo-lZ[ebpubebaZijhkZ EZ[hjZlhjgZyjZ[hlZ1.Kha^Zgb_ijhklhcnhjfu;> IjhklZynhjfZbkihevam_lky^eyjZ[hlukh^ghclZ[ebp_c 1. Hldjhcl_gh\ucijh_dlkimklhcnhjfhc 2. JZaf_klbl_ gZ nhjf_ dhfihg_glu TTable b TDataSource. Bo fh`gh gZclbgZkljZgbp_Data AccessiZebljudhfihg_glh\Wlh-g_\bamZevgu_dhf ihg_glugZnhjf_hgbbah[jZaylky\\b^_ibdlh]jZffZ\h\j_fy\uiheg_gby \b^gug_[m^ml 3.
Jbk1
7
6. JZaf_klbl_dhfihg_glTDBGrid (kljZgbpZ Data Control iZebljudhfih g_glh\ K\y`bl_ _]h k DataSource1 mdZaZ\ bfy DataSource1 \ k\hckl\_ DataSource.IjZ\bevghklvk\yau\Zgbydhfihg_glh\ijh\_jvl_ihjbk1. 7. MklZgh\bl_k\hckl\hActive h[t_dlZTable1 \True.LZ[ebpZhldjh_lkyb __kh^_j`bfh_hlh[jZablky\k_ld_^Zgguo(DBGrid). Hldhfibebjmcl_b\uihegbl_ijbeh`_gb_ MklZgh\bl_Active \FalseZ\h[jZ[hlqbdkh[ulbykha^ZgbynhjfuOnCreate \klZ\vl_Table1.Open. L_i_jvlZ[ebpZhldjh_lkylhevdh\h\j_fy\uihe g_gbyijbeh`_gbyQlh[uwlhijh\_jblvih\lhjbl_rZ] QZklh [u\Z_l m^h[gh ijhkfZljb\Zlv b j_^Zdlbjh\Zlv lZ[ebpm \ \b^_ g_ kdhevdbokljhddZ`^Zybadhlhjuohlh[jZ`Z_lh^ghihe_l_dms_caZibkb>ey wlhcp_ebij_^gZagZq_gdhfihg_glTDBEdit (kljZgbpZData Control)GZnhjf_ ke_^m_l jZaf_klblv klhevdh h[t_dlh\ TDBEdit kdhevdh ihe_c eyhlh[jZ`_gby]jZnbq_kdboihe_clbiZGraphics, Blob) bl_dklh\uo ihe_clbiZMemo) ij_^klZ\e_gu\bamZevgu_dhfihg_gluTDBImage b TDBMemokhhl\_lkl\_ggh I_j_f_s_gb_ihaZibkyflZ[ebpum^h[ghhj]Zgbah\Zlvkihfhsvxdhf ihg_glZTDBNavigator. eyb^_glbnbdZpbbihe_ci_j_^dZ`^uf \bamZevgufdhfihg_glhfihf_klbl_h[t_dlTLabel kih^ibkvxIjbf_jguc j_ amevlZljZ[hluijbeh`_gby^he`_gbf_lv\b^jbk2.
8
Jbk2 1.3. MklZgh\e_gb_k\ya_cf_`^mlZ[ebpZfb Kha^Zgb_h^ghk\yaghcnhjfu. H^ghk\yagZy nhjfZ kh^_j`bl ^\_ lZ[ebpu - ]eZ\gmxbih^qbg_ggmxdhlhju_ k\yaZguf_`^mkh[hcq_j_ah^bgZdh\u_iheyIh^qbg_ggZylZ[ebpZh[yaZl_ev gh ^he`gZ [ulv ijhbg^_dkbjh\ZgZ ih k\yamxs_fm ihex GZijbf_j ]eZ\gZy lZ[ebpZkh^_j`blihegu_k\_^_gbyhaZdZaqbdZoZih^qbg_ggZy-haZdZaZobfb k^_eZgguoH^ghfmaZdZaqbdmfh`_lkhhl\_lkl\h\Zlvg_kdhevdhkljhd\ih^qb g_gghc lZ[ebp_ h^gZdh lZf hg ij_^klZ\e_g ebrv k\hbf mq_lguf ghf_jhf CustNo. Ihe_CustNo \u[bjZ_lky\dZq_kl\_k\yamxs_]hihey >eykha^Zgbyk\yab\dhfihg_gl_TTableih^qbg_gghclZ[ebpug_h[oh^b fh^hihegbl_evghaZ^ZlvagZq_gbyk\hckl\MasterSource (bfydhfihg_glZDataSource ]eZ\ghclZ[ebpu), MasterField (bfyk\yamxs_]hihey]eZ\ghclZ[ebpu IndexFieldNames (bfy Zdlb\gh]h bg^_dkgh]h ihey ^ey ih^qbg_gghc lZ[ebpu \ dZq_kl\_dhlhjh]h\u[bjZ_lkyk\yamxs__ihe_ Hlf_lbfqlhaZibkb\ih^qbg_gghclZ[ebp_^hihegbl_evghnbevljmxlky ih mkeh\bx kh\iZ^_gby h^ghbf_gguo ihe_c Ihwlhfm \ ih^qbg_gghc lZ[ebp_ ihdZau\ZxlkylhevdhaZdZauk^_eZggu_l_dmsbfaZdZaqbdhfba]eZ\ghclZ[eb pu EZ[hjZlhjgZyjZ[hlZ3 Kha^Z^bfijbeh`_gb_hlh[jZ`Zxs__^Zggu_ba^\mok\yaZgguolZ[ebp]eZ\ghccustomer.db bih^qbg_gghcorders.db.
9
1. JZaf_klbl_ \ hdg_ nhjfu ^\Z dhfie_dlZ dhfihg_glh\ TTable, TDataSource b TDBGrid ih h^ghfm gZ dZ`^mx lZ[ebpm b h^bg dhfihg_gl DBNavigator^ey]eZ\ghclZ[ebpu 2. K\y`bl_dhfihg_gluklZ[ebpZfb customer.db borders.dbdZdwlh^_eZ ehkvjZg__ 3. MklZgh\bl_ k\yav f_`^m lZ[ebpZfb aZ^Z\ agZq_gby k\hckl\ MasterSource, MasterField, IndexFieldNames ^ey ih^qbg_gghc lZ[ebpu Ko_fZ mklZ gh\e_gbyk\ya_cijb\_^_gZgZjbk3. 4. Hldhfibebjmcl_b\uihegbl_ijbeh`_gb_ 5. Kha^Zcl_ZgZeh]bqgh_ijbeh`_gb_kihfhsvxmlbebluWdki_jlZnhjf [Za^Zgguoimgdlf_gxHelp).
Jbk3 EZ[hjZlhjgZyjZ[hlZ4kZfhklhyl_evgZy Kha^Zgb_ fgh]hk\yaghc nhjfu Kha^Zcl_ nhjfm kh^_j`Zsmx ljb k\y aZggu_ lZ[ebpu I_j\Zy lZ[ebpZ Customer.db y\ey_lky ]eZ\ghc k g_c k\yaZgZ ih^qbg_ggZylZ[ebpZOrders.db, dhlhjZy\k\hxhq_j_^vy\ey_lky]eZ\ghclZ[ ebp_c^eyItems.db.<lZ[ebp_Items kh^_j`ZlkyoZjZdl_jbklbdbaZdZah\H[sZy f_lh^bdZlZdZy`_dZdbijbkha^Zgbbh^ghk\yaguonhjf>eyk\yablZ[ebpOrdersbItems bkihevamcl_ihe_OrderNo.
10
Fh^meb^Zgguo JZg__ fu jZaf_sZeb \k_ dhfihg_glu ^hklmiZ d ^Zgguf g_ihkj_^kl\_ggh gZ ]eZ\ghcnhjf_ijbeh`_gbyH^gZdhjZaf_s_gb_gZh^ghcnhjf_[hevrh]hdh ebq_kl\Z jZaghjh^guo dhfihg_glh\ gZjmrZ_l ijbgpbi fh^mevghklb b aZljm^ gy_ljZajZ[hldmGZqbgZyk\_jkbb, \Delphiihy\beZkv\hafh`ghklvhdhgqZ l_evgh jZa^_eblv \bamZevgu_ b g_\bamZevgu_ dhfihg_glu [Za ^Zgguo \ug_ky \k_ g_\bamZevgu_ dhfihg_glu DataSet b DataSource \ ki_pbZevgmx jZagh\b^ ghklv nhjfu - fh^mev ^Zgguo (Data Module) LZdhc fh^mev kh^_j`bl \kx bg nhjfZpbxh[Za_^ZgguoojZgblkyhl^_evghgZ^bkd_bfh`_l[ulvbkihevah \ZgjZaebqgufbijbeh`_gbyfb<hlebqb_hlh[uqghcnhjfufh^mev^Zgguo g_\b^_g\h\j_fy\uiheg_gby <qZklghklb\fh^me_^Zgguop_e_khh[jZaghojZgblvdhfihg_gluTQuery kh \kljh_ggufb keh`gufb aZijhkZfb g_kdhevdh \ZjbZglh\ dhfihg_glh\ TTable c jZaebqgufb lZ[ebpZfb b bg^_dkZfb b li kf ijbf_j \ jZ[hl_ [5]). Bkihevah\Zgb_ fh^me_c \h\k_ g_ h[yaZl_evgh; bo ij_bfms_kl\Z ijhy\eyxlky ij_`^_ \k_]h, \ lj_oa\_gghc Zjobl_dlmj_ ;> [2], dh]^Z h^bg fh^mev ^Zgguo jZkiheh`_gguc gZ k_j\_j_ ijbeh`_gbc bkihevam_lky fgh`_kl\hf ©lhgdboª deb_glkdboijbeh`_gbcgZjZ[hqboklZgpbyo. Hlf_lbf kjZam `_ g_dhlhjmx imlZgbpm \ l_jfbgheh]bb Fh^mev ^Zgguo (Data Module) bijh]jZffgucfh^mev(Unit) -wlhjZagu_\_sb Fh^mev^Zgguo -wlhjZagh\b^ghklvnhjfub^eyg_]hkms_kl\m_lk\hcUnit. EZ[hjZlhjgZyjZ[hlZ KgZqZeZ jZkkfhljbf i_j\uc wlZi - kha^Zgb_ fh^mey ^Zgguo gZ ijbf_j_ ;>baeZ[hjZlhjghcjZ[hlu 1. Hldjhcl_gh\ucijh_dl 2.
11
2.
GZ\b]Zpbhgguc^hklmid;> <Delphi ih^^_j`b\Zxlky^\Zkihkh[Z^hklmiZd[ZaZf^ZgguoI_j\uckihkh[ j_Zebah\Zgguc dhfihg_glhf TTable, hkgh\Zg gZ i_j_f_s_gbb ih hl^_evguf aZibkyf lZ[ebpu LZdhc ih^oh^ gZau\Z_lky gZ\b]Zpbhgguf Recordhjb_glbjh\Zgguf Dhfihg_gl TQuery gZijhlb\ \ha\jZsZ_l p_eu_ gZ[hju ^Zgguo ihemq_ggu_ ihke_ \uiheg_gby hi_jZlhjh\ yaudZ SQL. Wlh - SQLhjb_glbjh\Zgguc[he__©j_eypbhggucªih^oh^H^gZdhh[Zdhfihg_glZy\ey xlkyihlhfdZfbdeZkkZTDataSetgZ[hj^Zgguo bbf_xlfgh]hh[sbomgZke_ ^h\Zgguo hl TDataSet gZ\b]Zpbhgguok\hckl\bf_lh^h\dhlhju_fh`ghijb f_gylvd\ha\jZsZ_fhfmgZ[hjm^Zgguo<^ZgghfjZa^_e_fu[m^_fjZkkfZl jb\Zlv \ hkgh\ghf bf_ggh wlb mgb\_jkZevgu_ k\hckl\Z b f_lh^u ijbf_gyy bo[_ah]jZgbq_gbyh[sghklbddhfihg_glmTTable>eybeexkljZpbb_kebg_ h]h\Zjb\Z_lky ijhlb\gh_ [m^_f bkihevah\Zlv ijbf_j ijhklhc ;> ©AZdZauª hibkZgghc\Ijbeh`_gbb JZ[hlZkiheyfbgZ[hjZ^Zgguo DZd \ ijh]jZff_ h[jZlblvky d dhgdj_lghfm ihex dhgdj_lghc aZibkb? ey^hklmiZ d dhgdj_lghfm nbabq_kdhfm ihex l_dms_c aZibkb ij_^gZagZq_g deZkk TField eh]bq_kdh_ ihe_ . < g_f kh[jZgu bgdZikmebjh\Zgu \k_\hafh`gu_ k\hckl\Z f_lh^ubkh[ulbydhlhju_fh]mlihgZ^h[blvkyijbjZ[hl_khklhe[phflZ[eb puGZijbf_jk\hckl\hValue lbiZVariant1 ojZgblagZq_gb_iheyk\hckl\hDisplayLabel – aZ]heh\hd klhe[pZ k\hckl\h DisplayFormat – nhjfZl hlh[jZ`_gby iheybli
1
12
Kha^Zgb_h[t_dlh\-ihlhfdh\TField Kms_kl\m_lljbkihkh[Z 1) K ihfhsvx j_^ZdlhjZ ihe_c MdZaZl_eb gZ h[t_dlu TField \dex qZxlky\hibkZgb_nhjfuZwda_fieyjuZ\lhfZlbq_kdbkha^Zxlkyijbkha^Zgbb nhjfu b mgbqlh`Zxlky ijb __ aZdjulbb. LZdb_ ihey bgh]^Z g_ kh\k_f ijZ \bevghgZau\ZxlklZlbq_kdbfbWlhlkihkh[m^h[_gl_fqlhiha\hey_ljZ[hlZlv kihe_fdZdkh[uqgufdhfihg_glhfbj_^Zdlbjh\Zlv_]hk\hckl\ZgZwlZi_\b amZevghcjZajZ[hldb 2) Ih mfheqZgbx Wda_fieyju TField kha^Zxlky Z\lhfZlbq_kdb ijb hldjulbb lZ[ebpu \ iheghf khhl\_lkl\bb k qbkehf b lbihf __ nbabq_kdbo ihe_c b mgbqlh`Zxlky ijb __ aZdjulbb Hlh[jZ`Zlvky \ \bamZevguo dhfih g_glZo[m^ml\k_iheybf_xsb_ky\lZ[ebp_ 3) Ijh]jZffgh l_ k ihfhsvx kh[kl\_gguo f_lh^h\-dhgkljmdlhjh\ OZjZdl_jbklbdb ihe_c \j_fy kha^Zgby b \j_fy m^Ze_gby hij_^_eyxlky ijh ]jZffbklhf Wlhl kihkh[ [he__ fhsguc gh f_g__ m^h[guc lZd dZd hl ijh ]jZffbklZhglj_[m_lm\u!)g_dhlhjhcd\ZebnbdZpbb J_^Zdlhjihe_c JZkkfhljbf gZ dhgdj_lghf ijbf_j_ i_j\uc kihkh[ kha^Zgby ihey \Z`^us_edgbl_gZh[t_dl_Table1. Ihy\blkyhdghj_^ZdlhjZihe_c, i_j\hgZqZevghimklh_ldh[t_dluTField _s_g_kha^Zgu 3. GZ`fbl_ijZ\mxdghidmfurbb\ihy\b\r_fkydhgl_dklghff_gx\u [_jbl_imgdlAdd Fields. <hdg_Available Fields [m^mli_j_qbke_gu\k_nbabq_ kdb_iheylZ[ebpu
13
4.
Jbk 7. MklZgh\bl_Active \True.
^Z_lmgb\_jkZevguckihkh[h[jZs_gbydh[t_dlZfTField, g_aZ\bkbfuchllh]h dZdbfh[jZahfhgb[uebkha^Zgu IZjZf_ljhff_lh^Zy\ey_lkygZa\Zgb_iheyZj_amevlZlhfjZ[hlu-kkue dZgZwda_fieyjdeZkkZTField ^eymdZaZggh]hiheyGZihfgbfqlhh[jZs_gb_d hl^_evguf Zljb[mlZf ihey aZ]heh\dm kh^_j`Zgbx b ^j ijhba\h^blky q_j_a
14
k\hckl\Zdhfihg_glZTField. GZijbf_jqlh[ubaf_gblvaZ]heh\hdihey Address \lZ[ebp_Cust ;>“AZdZau”, bkihevamcl_dhgkljmdpbx: 7DEOH)LHOG%\1DPHµ$GGUHVV¶ 'LVSOD\/DEHO ¶:^j_k¶;
?kebh[t_dl[uekha^ZgkihfhsvxJ_^ZdlhjZihe_clhdg_fmfh`ghh[jZlvky dZdkihfhsvxFieldByNamelZdbihbf_gbBfyh[t_dlZkljhblkyihijZ\bem bfygZ[hjZ^ZgguobfyiheygZijbf_j Table1Address.DisplayLabel:=’:^j_k’;
DagZq_gbxiheyfh`ghh[jZlblvkyeb[hkihfhsvxk\hckl\ZValue lbiZ Variant, eb[hkihfhsvxk\hckl\AsNNN lbiZNNN<k\hckl\_Value ojZgylky agZq_gbyke_^mxsbolbih\: string longInt double boolean TDataTime
^eyh[t_dlh\ TStringField, ^ey\k_op_euolbih\h[t_dlh\TField, ^ey\k_o\_s_kl\_gguolbih\TField, ^eyh[t_dlh\lbiZTBooleanField ^eyh[t_dlh\lbiZTDateField, TDateTimeField, TTimeField
H^gZbagZb[he__qZkluoaZ^Zq-hlh[jZ`_gb_agZq_gbyihey\\bamZevghfdhf ihg_gl_gZijbf_jTEditbebh[jZlgZyhi_jZpbyIjbql_gbbijhbkoh^blij_ h[jZah\Zgb_agZq_gbyValue dlbimi_j_f_gghcdm^Zhgh[m^_laZibku\Zlvky gZijbf_j ^eyp_eh]hiheyKolvo Edit1.text:=Table1.FieldByName(‘Kolvo’).Value;
[m^_lwd\b\Ze_glgh Edit1.text:=IntToStr(Table1.FieldByName(‘Kolvo’).Value);
IjbaZibkb\k\hckl\h Value ke_^m_lihfgblvqlh^eywlh]hk\hckl\Z\hlebqb_ hl h[uqguo \ZjbZglguo i_j_f_gguo f_lh^ aZibkb [m^_l iulZlvky ij_h[jZah \Zlv lbi ijbk\Zb\Z_fhc i_j_f_gghc d lbim ihey mdZaZgghfm \ lZ[ebp_ kf \ur_ bwlhfh`_l bgh]^Zijb\h^blvdhrb[dZf\j_f_gb\uiheg_gbyGZijb f_j ijZ\bevguh[jZs_gby Table1.FieldByName(‘Kolvo’).Value:=100; Table1.FieldByName(‘Kolvo’).Value:=Edit1.text; // ‘100’ Table1.FieldByName(‘Kolvo’).Value:=StrToInt(Edit1.text);//‘100’
bhrb[hqguh[jZs_gby Table1.FieldByName(‘Kolvo’).Value:=Edit1.text; // ’01.01.80’ Table1.FieldByName(‘address’).Value:=100.
;he__m^h[gub[_ahiZkguk\hckl\ZAsString: String, AsInteger: integer, AsFloat: Double, AsDateTime: TDateTime, AsCurrenty: Currenty ij_h[jZamxsb_ d lbim ihey mdZaZgghfm \ gZa\Zgbb (g_dhlhju_ dheebabb a^_kv fh]ml [ulv ©hleh\e_ guª dhfibeylhjhf).
15
eylbibabjh\Zgguoh[t_dlh\-ihlhfdh\TFieldddhlhjuf\k_]^Z hlghkylky©klZlbq_kdb_ªiheyk\hckl\h Valueihebfhjnghi_j_hij_^_ey_lkyb bf__lm`_dhgdj_lguclbiIhwlhfmijbk\Zb\Zgb_ Table1Kolvo.Value := Edit1.text; \uah\_lhrb[dmdhfibeypbb^h]Z^Zc l_kvdZdmx IjZ\bevgh^ey©klZlbq_kdboªihe_c[m^_l Table1Kolvo.Value := StrToInt(Edit1.text); beb Table1Kolvo.AsString := Edit1.text;
Qlh[uh[jZlblvkydagZq_gbxiheyfh`ghlZd`_bkihevah\Zlvk\hckl\h property FieldValues [F: string]: variant,
y\eyxs__kyk\hckl\hf©ihmfheqZgbxªgZ[hjh\^ZgguogZijbf_j 7DEOH)LHOG9DOXHV>µ$GGUHVV¶@ ¶Fhkd\Z¶ beb 7DEOH>µ$GGUHVV¶@ ¶Fhkd\Z¶
JZ[hlZlv k FieldValues ke_^m_l lZd `_ hklhjh`gh dZd b kh k\hckl\hf Value: Variant. Ihemq_gb_bgnhjfZpbbhiheyo H[jZlblvkydTFieldDefs fh`ghq_j_ak\hckl\hG> property FieldDefs: TFieldDefs,
\ha\jZsZxs__kkuedmgZwda_fieyjTFieldDefs. K\hckl\ZTFieldDefs: property Count: integer;
16
property Size: Integer; ey[hevrbgkl\Z
qbkeh\uolbih\jZaf_jiheyg_aZ^Z_lkybhij_^_ey_lkylbihfihey OZjZdl_jbklbdb eh]bq_kdbo ihe_c h[t_dlh\ TField) fh`gh magZlv k ih fhsvxkj_^kl\yaudZObject Pascal ^eyijh\_jdblbiZ\j_f_gb\uiheg_gby EZ[hjZlhjgZyjZ[hlZ
JZaf_klbl_gZnhjf_bkh_^bgbl_dhfihg_gluTTable (bfy T1), TDataSource, TDBgrid K\y`bl_ T1 k dZdhc-gb[m^v lZ[ebp_c b mklZgh\bl_ Active \ True. JZaf_klbl_dhfihg_glTComboBox kbf_g_fCB1bljbiZjudhfihg_glh\ TLabel bTEdit. 2.Kha^Zcl_h[jZ[hlqbdb ke_^mxsbokh[ulbc OnCreate ^eynhjfu: procedure TForm1.FormCreate(Sender: TObject); var i: integer; begin //AZiheg_gb_kibkdZbf_gZfbnbabq_kdboihe_c for i:=0 to Table1.FieldDefs.Count-1 do cb1.Items.add(T1.FieldDefs.Items[i].Name); end;
OnChange ^eyCB1: procedure TForm1.CB1Change(Sender: TObject); begin //Hij_^_e_gb_lbih\eh]bq_kdboihe_c Edit1.text :=T1.FieldByName(CB1.text).AsString; Edit2.text := T1.FieldByName(CB1.text).ClassName; // Hij_^_e_gb_lbih\agZq_gbc if VarType(T1.FieldByName(cb1.text).value)=VarDate then Edit3.text :='TDate' else if VarType(T1.FieldByName(cb1.text).value)=VarInteger Edit3.text :='VarInteger' else if VarType(T1.FieldByName(cb1.text).value)=VarDouble then Edit3.text :='VarDouble' else if VarType(T1.FieldByName(cb1.text).value)=VarString then Edit3.text :='VarString' end;
then
Ihke_dhfibeypbbbaZimkdZ\u[_jbl_bfyihey\dhf[bgbjh\Zgghf kibkd_ijbwlhfhdghijh]jZffuijbf_l\b^
17
Jbk >hjZ[hlZcl_ijh]jZffmqlh[uhgZihdZau\ZeZ khklZ\boZjZdl_jbklb dbnbabq_kdboihe_c (k\hckl\h FieldDefs: TFieldDefs G>), Z lZd`_khklZ\boZ jZdl_jbklbdbeh]bq_kdbo ihe_c (k\hckl\h Fields [index: integer]: TField G>). Bfyihey,kdhlhjufk\yaZgh[t_dlTField, kh^_j`blky\_]hk\hckl\_FieldName: string; bfyh[t_dlZdZdh[uqghkh^_j`blky\k\hckl\_Name.Qbkeheh ]bq_kdboihe_cfh`ghmagZlvbkihevamyk\hckl\hG>FieldCount: integer; >hjZ[hlZcl_ijh]jZffmqlh[uhgZfh]eZ\h\j_fy\uiheg_gbyhldju \Zlvex[mxlZ[ebpmba[Zau^Zgguokex[ufaZj_]bkljbjh\ZggufZebZkhf MdZaZgb_: bkihevamcl_dhfihg_glTSession.) GZ\b]ZpbyihgZ[hjm^Zgguo L_dmsZyaZibkv–wlhaZibkv^hklmigZy\^Zggucfhf_gl^eyijhkfhljZbeb fh^bnbdZpbb >ey ^hklmiZ d dhgdj_lghfm ihex l_dms_c aZibkb g_h[oh^bfh h[jZlblvkydwda_fieyjmh[t_dlZTField ^Zggh]hiheyMdZaZl_evl_dms_caZib kb gZau\Z_lky dmjkhjhf gZ[hjZ ^Zgguo >ey baf_g_gby dmjkhjZ G> ij_^gZ agZq_guke_^mxsb_f_lh^u h[t_dlh\TDataSet: procedure First; I_j_^\b]Z_ldmjkhjdi_j\hcaZibkbG> procedure Last; I_j_^\b]Z_ldmjkhjdihke_^g_caZibkbG> procedure Next; I_j_f_sZ_ldmjkhjgZh^gmaZibkv\gba procedure Prior; I_j_f_sZ_ldmjkhjgZh^gmaZibkv\\_jo K\hckl\h BOF: BooleanmklZgZ\eb\Z_lky\Truedh]^ZdmjkhjgZoh^blkygZi_j \hcaZibkbZk\hckl\hEOF: Boolean mklZgZ\eb\Z_lky\True, dh]^ZdmjkhjgZ oh^blkygZihke_^g_caZibkb K\hckl\hRecordCount \ha\jZsZ_lqbkehaZibk_c\G> F_lh^ function MoveBy (n: integer): integer;
i_j_f_sZ_ldmjkhjgZn aZibk_cddhgpmgZ[hjZ^Zgguon>0) bebdgZqZemgZ [hjZn<0).
18
Ke_^m_l ihfgblv qlh i_j_f_s_gb_ ijhbkoh^bl \ khhl\_lkl\bb k eh]bq_ kdbf ihjy^dhfaZibk_chij_^_ey_fufZdlb\gufbg^_dkhfkfi dhlhjuc fh`_l hlebqZlvky hl nbabq_kdh]h ihjy^dZ Ihwlhfm qlh[u g_ aZimlZlvky ijb gZ\b]Zpbb g_evay baf_gylv ihe_ hij_^_eyxs__ Zdlb\gucbg^_dkDjhf_lh]h ijbZdlb\babjh\Zgghfnbevlj_kfi i_j_f_s_gb_ijhbkoh^bl\gmljbh[ eZklbG>m^h\e_l\hjyxs_cmkeh\bxnbevljZGZijbf_jf_lh^Last i_j_c^_l g_ gZ ihke_^gxx nbabq_kdmx aZibkv Z gZ ihke_^gxx aZibkv h]jZgbq_ggmx mkeh\b_fnbevljZ >eyi_j_f_s_gbyihG>\gbagm`gh\uihegblvke_^mxsb_^_ckl\by: with Table1 do begin First; while not EOF do begin ^_ckl\b_gZ^l_dms_caZibkvx! Next; end; end;
>eyi_j_f_s_gbyihG>\\_jo: with Table1 do begin Last; while not BOF do begin ^_ckl\b_gZ^l_dms_caZibkvx! Prior; end; end;
2.3. >_ckl\bygZ^l_dms_caZibkvx aZ\bkbl hl _]h khklhygby G_dhlhju_ hkgh\gu_khklhygbyG>hibkZgu\lZ[ebp_ LZ[ebpZ Khklhygb_ HibkZgb_ I_j_\h^\khklhygb_ dsInActive G>aZdjul F_lh^Close dsBrowse AZibkvijhkfZljb\Z_l F_lh^ Open (hldju\Z_l aZ djuluc G>); f_lh^ Post kyghg_baf_gy_lky (nbdkbjm_l gZ ^bkd_ baf_ (khklhygb_ihmfheqZ g_ggmxaZibkv); f_lh^Cancel gbx hlf_gy_lbaf_g_gby dsEdit L_dmsZy aZibkv j_^Zd F_lh^Edit lbjm_lky dsInsert nbevljm_lky K\hckl\hFiltered:=False dsCalHij_^_eyxlky \uqbk cFields ey_fu_ ihey Baf_g_ gby \ G> \ghkblvky g_ fh]ml
19
K\hckl\h State \ha\jZsZxs__ agZq_gby ijb\_^_ggu_ \ i_j\hf klhe[p_ lZ[ebpuiha\hey_lmagZlvl_dms__khklhygb_G> Ijb j_^Zdlbjh\Zgbb G>g_ihkj_^kl\_ggh\k\yaZgghfkgbf\bamZevghf dhfihg_gl_gZijbf_j TDBGridgZ[hj^Zgguo i_j_\h^blky\khklhygb_j_^Zd lbjh\ZgbyZ\lhfZlbq_kdbijbwlhfk\hckl\hAutoEdit dhfihg_glZTDataSource ^he`gh[ulvmklZgh\e_gh\True). Ijbfh^bnbdZpbbG>baijh]jZffuke_^m_lkgZqZeZ\ua\Zlvf_lh^uEdit, Insert bebAppendZihke_fh^bnbdZpbb–f_lh^Post (aZdj_ie_gb_)bebCancel hlf_gZ GZijbf_j with Table1 do begin Edit; FieldByName(‘Address’).value:=’Fhkd\Z’; Post; end;
Ijb bkihevah\Zgbb \bamZevguo dhfihg_glh\ j_^Zdlbjh\Zgby gZijbf_j TDBGrid, TDBEdit wlbf_lh^u\uau\ZxlkyZ\lhfZlbq_kdb. >eymklZgh\dbagZq_gbcihe_cl_dms_caZibkb fh`ghlZd`_bkihevah\Zlv f_lh^ procedure SetFields(const V: array of const);
IZjZf_ljV - hldjulucfZkkb\kwe_f_glZfb\ZjbZglgh]hlbiZ1 [8]. F_lh^u Edit bPost \kljh_gu\SetFieldsihwlhfmhl^_evgh\uibku\Zlvbog_lj_[m_lky GZijbf_j Table1.SetFields ([5, ‘B\Zgh\’, ‘Fhkd\Z’]).
Lbibihjy^hdwe_f_glh\^he`_gkhhl\_lkl\h\Zlvlbimbihjy^dmihe_cebr gb_we_f_glu\fZkkb\_g_mqblu\Zxlky^eyg_^hklZxsbowe_f_glh\iheyg_ f_gyxlagZq_gby >ey\klZ\dbgh\hcaZibkbbaZiheg_gby__agZq_gbyfbfh`ghbkihevah \ZlvZgZeh]bqgucf_lh^ procedure InsertRecord(const V: array of const);
>ey^h[Z\e_gby–f_lh^ procedure AppendRecord(const V: array of const);
F_lh^EmptyTable m^Zey_l\k_aZibkbbaG> >eym^Ze_gbyl_dms_caZibkbkem`blf_lh^ Delete. NbevljZpbygZ[hjZ^Zgguo NbevljZpbyG>hagZqZ_lqlhihevah\Zl_ex[m^_l\b^gZebrvqZklvG>m^h\ e_l\hjyxsZyg_dhlhjhfmeh]bq_kdhfmmkeh\bxgZau\Z_fhfmmkeh\b_fnbevl jZpbbNbevljfh`_lgZoh^blvky\Zdlb\ghfbebg_Zdlb\ghfkhklhygbb<i_j Hldjuluc fZkkb\ ijb i_j_^Zq_ \ ijhp_^mjm fh`_l bf_lv jZagh_ qbkeh we_f_glh\ b aZ^Z\Zlvky \ \b^_ kibkdZ agZq_gbc \ d\Z^jZlguo kdh[dZo gh g_ imlZlv k fgh`_kl\hf Const \ gZqZe_ hagZqZ_l qlh fZkkb\ i_j_^Z_lky ih agZq_gbx (gh g_ q_j_a kl_d!). Const \ dhgp_ - qlh fZkkb\ \ZjbZglguc b _]h we_f_glu fh]ml bf_lv jZaguc lbi ?s_ g_ aZimlZebkv? Lh]^Z ijh^he`bf 1
20
\hfkemqZ_k\hckl\hFiltered: Boolean gZ[hjZ^Zgguo^he`gh[ulvmklZgh\e_gh \True. IhmfheqZgbxnbevlj\udexq_gbFiltered jZ\ghFalse. Mkeh\b_nbevl jZpbbfh`_l[ulvaZ^Zgh^\mfykihkh[Zfb<i_j\hfbagbobkihevam_lkyk\hc kl\h Filter lbiZ String,^hklmigh_dZdijh]jZffghlZdbq_j_abgki_dlhjh[t_d lh\GZijbf_jijbaZ^Zgbbmkeh\by Filter:=’Price>100’;
[m^ml ^hklmigu lhevdh aZibkb lh\Zjh\ k p_ghc [hevr_c m_ < mkeh\bb fh`ghijbf_gylvhi_jZlhjuhlghr_gbylZdb_`_dZd\Pascal’_ beh]bq_kdb_ hi_jZlhjuAND, OR, NOT. K\hckl\h FilterOptions: TFilterOptions iha\hey_laZ^Zlvj_`bfunbevljZ pbb Ih mfheqZgbx FilterOptions=[] agZq_gb_ foCaseInsensitive bkihevam_lky qlh[u nbevljZpby ijhbkoh^beZ [_a mq_lZ j_]bkljZ [md\ agZq_gb_ foNoPartialCompare – qlh[u nbevljZpby ijhbkoh^beZ ijb mkeh\bb lhqgh]h kh\iZ^_gby kljhdDkh`Ze_gbx\gug_^hklmiguo\_jkbyoDelphi ZhiulihdZau\Z_lqlh lZd [m^_l b \h \k_o ihke_^mxsbo \_jkbyo wlh k\hckl\h g_ ihgbfZ_l jmkkdbo [md\Ihwlhfmij_^ihqlbl_evgufy\ey_lky\lhjhc[he__]b[dbckihkh[aZ^Zgby mkeh\bynbevljZpbbkbkihevah\Zgb_fh[jZ[hlqbdZkh[ulbyOnFilterRecord. Kh[ulb_OnFilterRecord gZklmiZ_lijbZdlb\baZpbbnbevljZl_ijbmk lZgh\d_Filtered\ True).H[jZ[hlqbdkh[ulbybf__l^\ZiZjZf_ljZ: bfynbevl jm_fh]h gZ[hjZ ^Zgguo DataSet: TDataSet b iZjZf_lj Accept: Boolean, \ha\jZ sZxsbc j_amevlZl ijh\_jdb mkeh\by nbevljZpbb < hlnbevljh\Zgguc G> \dexqZxlky lhevdh aZibkb ^ey dhlhjuo Accept bf__l agZq_gb_ True. µ1DPH¶@ ); // Mkeh\b_g_lhqgh]hkh\iZ^_gbykljhd end;
A^_kvba\_klgZy
?kebaZ^Zgumkeh\byb\k\hckl\_Filterb\h[jZ[hlqbd_ OnFilterRecord, lhhgbh[Zmqblu\Zxlky Nbevlju bkihevamxlky \ hkgh\ghf ^ey ihbkdZ aZibk_c gh ihbkd wlhl \_kvfZf_^e_gguclZddZdhkgh\ZggZihke_^h\Zl_evghfi_j_[hj_aZibk_c>ey G>TTable, ijb\hafh`ghklbke_^m_lbkihevah\Zlv[he__[uklju_f_lh^ubg ^_dkgh]hihbkdZ
21
Bg^_dkubbg^_dkgucihbkd F_lh^u jZkkfhlj_ggu_ \ ij_^u^msbo ih^jZa^_eZo h^bgZdh\h ijb]h^gu ^ey gZ[hjh\^ZgguoTTable bTQuery.Bkihevah\Zgb_bg^_dkh\–hkh[_gghklvdhf ihg_glZTTable. Kha^Zgb_bg^_dkZ Bg^_dk–wlh\kihfh]Zl_evgZykljmdlmjZhij_^_eyxsZyeh]bq_kdh_jZkiheh`_ gb_aZibk_c\lZ[ebp_>eyh^ghclZ[ebpufh`_lkms_kl\h\Zlvg_kdhevdhbg ^_dkh\aZ^Zxsbokhjlbjh\dmihjZagufiheyf h^bgbadhlhjuofh`_l[ulv Zdlb\guf:dlb\gucbg^_dkbaf_gy_lihjy^hdijhkfhljZbgZ\b]Zpbb\lZ[eb p_ Ihe_^eydhlhjh]hkha^Zgbg^_dkgZau\Z_lkybg^_dkgufihe_f,bebdex qhfBg^_dkkha^Zgguc^ey mgbdZevgh]hi_j\bqgh]hdexqZlZ[ebpu–i_j\bq guc bg^_dk, bg^_dku kha^Zggu_ ih ^jm]bf iheyf – \lhjbqgu_ bg^_dku >ey lZ[ebpParadox i_j\bqgucbg^_dk^he`_gkms_kl\h\Zlv,bgZq_g_\hafh`gh kha ^Zgb_hklZevguobg^_dkh\H[uqgh\dZq_kl\_i_j\bqgh]hdexqZ\u[bjZxlih e_kh^_j`Zs__mgbdZevgucdh^^eyaZibkbBg^_dkufh]mlhij_^_eylvkylZd`_ gZhkgh\_khklZ\gh]hdexqZkhklhys_]hbag_kdhevdboihe_c Kha^Z\Zlv bg^_dku m^h[g__ \k_]h k ihfhsvx mlbeblu DBD (^ey lZ[ebp InterBase \iheg_ijb]h^_gSQL Explorer [5])ijbwlhfmdZau\Zxlkyiheyihdh lhjuf kljhblky bg^_dk b bfy bg^_dkZ >ey bg^_dkh\ ihkljh_gguo ih h^ghfm ihex bg_bkihevamxsbodZdb_-eb[h\uqbke_gbybfybg^_dkZfh`_lkh\iZ^Zlv kbf_g_fihey
A^_kvName - bfygh\h]hbg^_dkZ Fields –kibkhdihe_chij_^_eyxsbo bg^_dk q_j_a lhqdm k aZiylhc Options – fgh`_kl\h Zljb[mlh\ bg^_dkZ kh klhys__baagZq_gbc · ixPrimaryi_j\bqgucbg^_dk · ixUniquemgbdZevgucbg^_dk · isDescendingbg^_dkihm[u\Zgbx) · ixCaseInsensitivebg^_dkg_qm\kl\bl_evgucdj_]bkljm) · ixExpression\uqbkey_fucbg^_dklhevdh^ey dBASE). I_j\bqgu_bg^_dkuwlhlf_lh^g_kha^Z_lohlyhipbyixPrimary ij_^m kfhlj_gZ I_j_^kha^Zgb_fbg^_dkZg_h[oh^bfhm[_^blvkyqlhgbh^ghijbeh`_gb_ g_jZ[hlZ_lk;>bmklZgh\blvk\hckl\hExclusive:=True. Ijbf_j: AddIndex(By_FIO_Address,’FIO;Address’,[ ]); Kms_kl\mxsb_bg^_dkuZdlb\babjmxlkykihfhsvxk\hckl\ZIndexName bebIndexFieldNames (kfijbf_qZgbydi).
22
Ihemq_gb_bgnhjfZpbbh[bg^_dk_ K\hckl\hIndexDefslbiZTIndexDefs h[t_dlZTTable kh^_j`bl\kxbgnhjfZpbx hkms_kl\mxsbobg^_dkZolZ[ebpu G_dhlhju_ k\hckl\Zbf_lh^udeZkkZ TIndexDefs iheguci_j_q_gvkf\ [3]): property Count: integer; qbkehbg^_dkh\ property Items[Index: Integer]: TIndexDef; - gZ[hjh[t_dlh\lbiZTIndexDefkh^_j`ZsbobgnhjfZpbxhdhgdj_lghfbg^_dk_, procedure Updates; - h[gh\e_gb_gZ[hjZTIndexDef kmq_lhf\gh\vkha^Zgguo bg^_dkh\ G_dhlhju_k\hckl\ZdeZkkZTIndexDef: property Name: String; -bfybg^_dkZ property Fields: string; - kibkhdihe_c\oh^ysbo\bg^_dk property Options: TIndexOptions; EZ[hjZlhjgZyjZ[hlZ Kha^Z^bfnjZ]f_glijh]jZffu\dhlhjhffh`gh\u[bjZlvZdlb\gu_bg^_dku baknhjfbjh\Zggh]hkibkdZ JZaf_klbl_ dZd h[uqgh ljb dhfihg_glZ ^ey ^hklmiZ d ;> k\yaZ\ bo k 1. lZ[ebp_cCustdhfihg_glListBox bLabel. Kha^Zcl_ h[jZ[hlqbdb kh[ulby OnCreate ^ey nhjfu b OnClick ^eyList2. Box1: procedure TForm1.FormCreate(Sender: TObject); var i: integer; begin ListBox1.Clear; Table1.IndexDefs.Update; for i:=0 to Table1.IndexDefs.Count-1 do ListBox1.Items.Add(Table1.IndexDefs[i].Name); end; procedure TForm1.ListBox1Click(Sender: TObject); begin Label1.Caption:= Table1.IndexDefs.Items[ListBox1.Itemindex].Fields; Table1.IndexName:=ListBox1.Items[ListBox1.ItemIndex]; end;
?keb\k_[uehk^_eZghijZ\bevghlhihke_aZimkdZijbeh`_gb_[m^_l bf_lv\b^jbk
23
Jbk Bg^_dkgucihbkd J_dhf_g^mxlky^\Zf_lh^Zbg^_dkgh]hihbkdZFindKey bFindNearestI_j\uc f_lh^ij_^gZagZq_gguc^eylhqgh]hihbkdZhibku\Z_lkyke_^mxsbfh[jZahf: function FindKey(const KeyValues: array of const): boolean;
IZjZf_ljKeyValues aZ^Z_lkibkhdagZq_gbcdexq_\uoihe_cH[uqghwlh lhevdhh^ghagZq_gb_G_kdhevdhagZq_gbcbkihevamxlky^eyihbkdZihkhklZ\ ghfmdexqmF_lh^ij_^iheZ]Z_lqlhg_h[oh^bfucbg^_dkm`_Zdlb\babjh\Zg kihfhsvxmklZgh\dbk\hckl\IndexFieldNames bebIndexName. <kemqZ_mki_r gh]h ihbkdZ f_lh^ \ha\jZsZ_l True b i_j_f_sZ_l mdZaZl_ev gZ gZc^_ggmx aZ ibkv\kemqZ_g_m^Zqb\ha\jZsZ_lFalse. <hlebqb_hlg_]hf_lh^ijb[eb`_ggh]hihbkdZ procedure FindNearest (const KeyValues: array of const);
\k_]^Zmki_r_g. HggZoh^blaZibkvagZq_gb_bg^_dkgh]hiheydhlhjhc[hevr_ bebjZ\ghagZq_gbx KeyValues. IhmfheqZgbxbkihevamxlkyi_j\bqgu_bg^_d ku Qlh[u ihbkd ihke_^h\Zl_evgh mlhqgyeky ih f_j_ \\h^Z \k_ gh\uo [md\ \klZ\vl_\uah\f_lh^ZFindNearest\h[jZ[hlqbdkh[ulbyOnChange dhfihg_glZ TEdit. Ijhbeexkljbjm_fjZkkfhlj_ggu_gZfbf_lh^u^hklmiZke_^mxs_ceZ[h jZlhjghcjZ[hlhc EZ[hjZlhjgZyjZ[hlZ Kha^Zgb_nhjfu^ey\_^_gby`mjgZeZaZdZah\ P_evijbeh`_gby–Z\lhfZlbaZpbyaZg_k_gby^Zgguo\lZ[ebpm©AZdZauª G_h[oh^bfu_k\_^_gby\u[bjZxlkybalZ[ebp©AZdZaqbdbªb©Lh\Zjuª?keb aZdZaqbdhlkmlkl\m_l\lZ[ebp_hglm^Z^h[Z\ey_lkyIhbkdaZdZaqbdZ\_^_lky ijb[eb`_ggufbg^_dkguff_lh^hfIjbg_h[oh^bfhklbfh`ghijhkfhlj_lv k\yaZggmxbgnhjfZpbxbalj_olZ[ebp Kha^Z^bfnhjfmij_^klZ\e_ggmxgZjbkG_h[oh^bfu_dhfihg_glu ;>: ljbljhcdbTTable, TDataSource, TDBGrid, TDBNavigator. Ihke_^gbck\yau
24
\Z_lkykdhfihg_glhfTTable ^eylZ[ebpu©AZdZauªKlZ[ebp_c©Lh\Zjuªk\y `bl_dhfihg_gluDetal_Code: TDBText bDetal_Price: TDBText. MklZgh\bl_ k\yabf_`^mlZ[ebpZfCust bCd ihihexNc bf_`^mlZ[ebp_cCd bDetalih ihexNd. MklZgh\bl_k\hckl\hActive ^ey\k_olZ[ebp\ True. 2.<hdg_]jmiiuCustBox1: TGroupBoxjZkiheh`bl_we_f_glu^eyj_^Zd lbjh\Zgby Zljb[mlh\aZdZaqbdZEditCust: TEdit, EditAdres: TEdit, EditCode: TEdit, FindCust: TButton, AddCust: TButton, ExtractCust: TButton, LabelAdres: TLabel. 3. GZiZg_eb CDPanel: TPanel jZkiheh`bl_ we_f_glu^eyj_^Zdlbjh\Zgby aZdZaZNdLabel: Tlabel, Edit_Detal_Name: TEdit, Edit_Detal_Kol: TEdit, PriceLabel: TLabel, Edit_Detal_Total: TEdit, Edit_Date: TEdit, FindDetal: TButton, ExtractDetal: TButton, CustDetal: TButton kkhhl\_lkl\mxsbfbf_ldZ fb-h[hagZq_gbyfb JZaf_klbl_^\Z\udexqZl_eyCust_CD_Link: TCheckBox b Cd_Detal_Link: TCheckBox ^eyhldexq_gbyk\yabf_`^mlZ[ebpZfb
Kha^Zcl_h[jZ[hlqbdbkh[ulbc:
Jbk
procedure TForm1.FindCustClick(Sender: TObject); begin Table1.IndexName := 'Cust_Name'; //:dlb\baZpbybg^_dkZ Table1.FindNearest([EditCust.text]); //Ijb[eb`_ggucihbkd end;
25
procedure TForm1.FindDetalClick(Sender: TObject); begin Cd_Detal_Link.Checked := false; Cd_Detal_LinkClick(sender); Table3.IndexName := 'detal_Name'; Table3.FindNearest([Edit_Detal_Name.text]); end; procedure TForm1.AddCustClick(Sender: TObject); begin Table1.AppendRecord([Nil, EditCust.Text, EditAdres.Text]); end; procedure TForm1.Cd_Detal_LinkClick(Sender: TObject); begin with Table3 do if Not (Cd_Detal_Link.Checked) then begin IndexName := 'detal_Name'; MasterSource := Nil; MasterFields := ' '; end else begin IndexFieldNames := 'Nd'; MasterSource := DataSource2; MasterFields := 'Nd'; end; end; procedure TForm1.Cust_CD_LinkClick(Sender: TObject); begin with Table2 do if Not (Cust_Cd_Link.Checked) then begin IndexFieldNames := 'No'; MasterSource := Nil; MasterFields :=' '; end else begin IndexFieldNames := 'nc'; MasterSource := DataSource1; MasterFields := 'Nc'; end; end; procedure TForm1.CustDetalClick(Sender: TObject); begin Cust_Cd_Link.Checked := false; Cust_CD_LInkClick(sender); Edit_Date.text := DateToStr(date);
26
Table2.AppendRecord ([Nil,EditCode.Text,Table3[Detal_Code.DataField], Edit_Detal_Kol.Text,Edit_Detal_Total.Text, strToDate(Edit_Date.Text)]); end; procedure TForm1.Edit_Detal_KolChange(Sender: TObject); begin if Edit_Detal_Kol.Text<>'' then Edit_Detal_Total.Text := IntToStr(StrToInt(Edit_DEtal_Kol.text) *Table3['Price']); end; procedure TForm1.ExtractCustClick(Sender: TObject); begin EditCust.text := Table1['Name']; EditCode.Text := Table1['nc']; EditAdres.Text := Table1['Address']; end; procedure TForm1.ExtractDetalClick(Sender: TObject); begin Edit_Detal_Name.text :=Table3['Name']; end;
6. Kh[ulbyfOnChangedhfihg_glh\EditCustbEdit_Detal_Nameijbk\hc l_ q_j_a bgki_dlhj h[t_dlh\ h[jZ[hlqbdb kh[ulbc FindCustClick b FindDetalClickkhhl\_lkl\_ggh 7. Ihke_hdhgqZl_evghchleZ^db\b^hbaf_gbl_ijh]jZffmbkihevamy ^ey \\h^Z^Zgguo, ]^_wlh\hafh`ghdhfihg_gluTDBEdit bTDBLookupComboBox. Ihke_^gbc dhfihg_gl bkihevam_lky ^ey aZiheg_gby h^ghc lZ[ebpu ^Zggufb \u[jZggufbba^jm]hck\yaZgghc kg_clZ[ebpu;he__ih^jh[gmxbgnhjfZ pbxkf\[1-3]. 8. Baf_gbl_kljmdlmjmlZ[ebpuDetal^h[Z\b\ihe_©HklZlhdgZkdeZ^_ªb fh^bnbpbjmcl_ ijh]jZffm lZd qlh[u g_evay [ueh ijh^Zlv hlkmlkl\mxsbc gZ kdeZ^_lh\ZjFgh]b_\hjhg_`kdb_nbjfu\jy^eb[m^ml\\hklhj]_hllZdh]h mkh\_jr_gkl\h\Zgby
3. SQL-hjb_glbjh\Zgguc^hklmid;> Bkihevah\Zgb_SQL YaudSQL (Structured Query Language) ijbgyl\dZq_kl\_hkgh\gh]h^eyjZ[hluk m^Ze_ggufb;>\kj_^_deb_gl-k_j\_j[1], gh\k_qZs_bkihevam_lkybijbjZ [hl_kehdZevgufb^Zggufb >ey\dexq_gby\ijh]jZffmhi_jZlhjh\SQL \Delphi kms_kl\m_lki_pb Zevguc dhfihg_gl - TQuery, jZkiheh`_gguc gZ kljZgbp_ Data Access iZeblju dhfihg_glh\ Hg bf__l fgh]h h[sbo k\hckl\ k dhfihg_glhf TTable b lZd`_ fh`_l bkihevah\Zlvky ^ey ijhkfhljZ b j_^Zdlbjh\Zgby ^Zgguo gh h[eZ^Z_l b jy^hfki_pbnbqguok\hckl\IhkjZ\g_gbxc TTable hgfh`_ljZ[hlZlvkjZamk
27
g_kdhevdbfblZ[ebpZfbbhl[bjZlv^Zggu_ihg_kdhevdbfdjbl_jbyfHlf_lbf qlhgZijZdlbd_h[uqghijboh^blkybkihevah\Zlv g_lhevdhj_eypbhggu_ghb jZkkfhlj_ggu_gZfbh[sb_gZ\b]Zpbhggu_k\hckl\Zbf_lh^uTQuery, mgZke_ ^h\Zggu_bfhldeZkkZTDataSet. GZb[he__\Z`guke_^mxsb_hkh[_gghklb: 1) <TQuery mdZau\Z_lkylhevdhZebZkZk\hckl\hTableName hlkmlkl\m_l Lj_[m_fu_lZ[ebpumdZau\Zxlky\l_dkl_aZijhkZ L_dklu SQL-aZijhkh\ aZibku\Zxlky \ k\hckl\h SQL h[t_dlZ TQuery. Wlhk\hckl\hlbiZTStrings ij_^klZ\ey_lkh[hch[t_dl-fZkkb\kljhdIjb\u[h j__]h\bgki_dlhj_h[t_dlh\aZimkdZ_lkyki_pbZebabjh\Zggucj_^Zdlhjkljhd K\hckl\h SQL fh`_lkh^_j`Zlvl_dkllhevdhh^gh]haZijhkZ AZijhkfh`_l[ulvhldjulb\uiheg_gm`_gZwlZi_jZajZ[hldbijbeh`_ gbykhhl\_lkl\mxs_cmklZgh\dhck\hckl\ZActiveJ_amevlZl\uiheg_gbyaZijh kZhlh[jZ`Z_lky\k\yaZgghf\bamZevghfdhfihg_gl_hlh[jZ`_gby^ZgguogZ ijbf_j\TDBGrid. IjbjZ[hl_ijbeh`_gbyaZijhkfh`_l[ulv\uiheg_gf_lh^Zfb Open beb ExecSQL. F_lh^ Open bkihevam_lky _keb aZijhk bkihevam_l ijbeh`_gb_ SELECT b \ha\jZsZ_l ijbeh`_gbx j_amevlZl F_lh^ ExecSQL bkihevam_lky \h \k_ohklZevguokemqZyo L_dklaZijhkZfh`_l[ulvaZibkZg\k\hckl\hSQL^\mfykihkh[Zfb k ihfhsvx ki_pbZebabjh\Zggh]h j_^ZdlhjZ \uau\Z_fh]h q_j_a bgki_dlhj h[t _dlh\ gZ wlZi_ jZajZ[hldb ijh]jZffu b k ihfhsvx kh[kl\_gguo f_lh^h\ h[t_dlZdeZkkZTStrings (Add, Clear, LoadFromFileb^j [9] gZwlZi_\uiheg_gby ijh]jZffu. Ijhbeexkljbjm_f h[Z kihkh[Z ke_^mxsbfb eZ[hjZlhjgufbjZ[h lZfb. EZ[hjZlhjgZyjZ[hlZ Kha^Zcl_ nhjfm hlh[jZ`Zxsmx ^Zggu_ ba ^\mo k\yaZgguo lZ[ebp ]eZ\ghccust.db bih^qbg_gghccd.db. 1. JZaf_klbl_ \ hdg_ nhjfu dhfihg_glu Query1: TQuery, DataSource1: TDataSource bDBGrid1: TDBGrid.Hlf_lbfohlylZ[ebp^\_jZaf_sZ_lkylhev dhh^bgdhfihg_gl^ZgguoTQueryBf_gZlZ[ebpbk\yabf_`^mgbfbmdZau\Z xlky\l_dkl_aZijhkZ K\y`bl_mklZgh\e_ggu_dhfihg_gluh[uqgufh[jZahf mklZgh\b\k\hckl\hDataSet h[t_dlZDataSource1\Query1<dZq_kl\_agZq_gby k\hckl\ZDataBaseName h[t_dlZQuery1 aZ^Zcl_ZebZkDBDemos. 2.
3. MklZgh\bl_ k\hckl\h Active h[t_dlZ TQuery \ True. Hldhfibebjmcl_ b \uihegbl_ijbeh`_gb_ JZkkfhljbf\lhjhckihkh[aZibkbaZijhkh\Hkgh\gh_ijZ\behbaf_gylv k\hckl\hSQL fh`ghlhevdhijbaZdjulhfaZijhk_
28
KlZg^ZjlgZyihke_^h\Zl_evghklv^_ckl\bc 4XHU\&ORVHFh`_lijbf_gylvky^Z`_ijbaZdjulhfaZijhk_ Query1.SQL.Clear; //HqbkldZaZijhkZ Query1.SQL.Add (‘SELECT * FROM cust’); 4XHU\2SHQbeb4XHU\$FWLYH 7UXH
EZ[hjZlhjgZyjZ[hlZ Kha^Zgb_bgl_jZdlb\gh]hj_^ZdlhjZaZijhkh\ JZajZ[hlZcl_ ijbeh`_gb_ dhlhjh_ iha\heyeh [u baf_gylv b \uihegylv aZijhk \h \j_fy \uiheg_gby ijh]jZffu \u[bjZlv ih `_eZgbx ihevah\Zl_ey kihkh[ ^hklmiZ d ^Zgguf q_j_a TTable beb TQuery). Lj_[m_fuc \g_rgbc \b^ ijbeh`_gbyihdZaZggZjbk
Jbk 1. Hldjhcl_ gh\uc ijh_dl JZaf_klbl_ \ hdg_ nhjfu dhfihg_glu Query1: TQuery, Table1: TTable, DataSource1: TDataSource bDBGrid1: TDBGrid. K\y`bl_DBGrid1 bDataSource1. (DataSource1[m^_lk\yaZgkTable1 bebQuery1 \oh^_\uiheg_gby 2. MklZgh\bl_ agZq_gby ke_^mxsbo k\hckl\ Table1 b Query1: DataBaseName - DBDemos , Active - False. 3. JZkiheh`bl_gZnhjf_^\_dghidb-KlZjlb
29
AZihegbl_ kibkhd ComboBox1 bf_gZfb lZ[ebp dhlhju_ ij_^iheZ]Z_lky ijh kfZljb\Zlvbkihevamcl_k\hckl\hItems \bgki_dlhj_h[t_dlh\ GZ\lhjhciZ g_eb Panel2) jZaf_klbl_ ZgZeh]bqgu_ ComboBox2 b Label2 ^ey \\h^Z aZijhkZ SQL b aZg_kbl_ \ kibkhd ComboBox2 g_kdhevdh ij_^iheZ]Z_fuo aZijhkh\ GZ lj_lv_c iZg_eb Panel3) jZkiheh`bl_ kljhdm j_^Zdlbjh\Zgby Edit1) ^ey \\h^Z eh]bq_kdh]h mkeh\by nbevljZ b dghidm-\udexqZl_ev CheckBox1 ^ey Zdlb\baZ pbbnbevljZ 4. JZaf_klbl_ ]jmiim dghihd-i_j_dexqZl_e_c RadioGroup1 qlh[u fh`gh [ueh\u[bjZlvf_`^mdhfihg_glZfbTTable bTQuery. Kha^Zcl_^eywlhc]jmi iuh[jZ[hlqbdkh[ulbyOnClick: procedure Tform1.RadioGroup1Click(Sender: TObject); begin case RadioGroup1.ItemIndex of 0: begin Panel1.Enabled:=True; Panel2.Enabled:= False; end; 1: begin Panel2.Enabled:= True; Panel1.Enabled:= False; end; end; end;
LZdbf h[jZahf ijb \u[hj_ h^gh]h ba kihkh[h\ ^hklmiZ gZijbf_j TTable, Zevl_jgZlb\guc ^hklmi aZij_sZ_lky iZg_ev kh kljhdhc aZijhkZ klZgh \blkyg_^hklmighcenabled:=False). 5. Kha^Zcl_h[jZ[hlqbdkh[ulby OnClick dghidbClZjl procedure TForm1.Button1Click(Sender: TObject); begin case RadioGroup1.ItemIndex of 0: begin 7DEOH&ORVHAZdjulb_lZ[ebpu TaEOH7DEOH1DPH &RPER%R[7H[WBfylZ[ebpu DataSource1.DataSet:=Table1; // K\yavdhfihg_glh\ 7DEOH)LOWHU (GLW7H[WMklZgh\dZnbevljZ Table1.Filtered:=Checkbox1.Checked; 7DEOH2SHQHldjulb_lZ[ebpu end; 1: begin 'DWD6RXUFH'DWD6HW 4XHU\K\yavq_j_aaZijhk Query1.CORVHAZdjulb_aZijhkZ Query1.Sql.Clear; // HqbkldZl_dklZaZijhkZ Query1.Sql.Add(Combobox2.Text); AZg_k_gb_\l_dklhlj_^Zdlbjh\Zgghckljhdb 4XHU\)LOWHU (GLW7H[WMklZgh\dZnbevljZ Query1.Filtered:=Checkbox1.Checked; 4XHU\2SHQ
30
6. Ijbeh`_gb_ ]hlh\h Ihkdhevdm gZ wlZi_ jZajZ[hldb aZijhkug_kha^Z \Zebkv ijhkfhlj_lv bo j_amevlZlu fh`gh lhevdh ihke_ dhfibeypbb b \uihe g_gby 7. Baf_gbl_ ijbeh`_gb_ bkihevamy ^ey j_^Zdlbjh\Zgby aZijhkZ dhfih g_glTMemo. 3.2. >bgZfbq_kdb_aZijhku JZkkfhlj_ggu_\ur_kihkh[uihkljh_gbyaZijhkh\bf_xlg_^hklZldbAZijhk \kljh_gguc \ TQuery gZ wlZi_ jZajZ[hldb, g_evay \b^hbaf_gblv \h \j_fy \u iheg_gbyZjZ[hlZkaZijhkhfj_^Zdlbjm_fuf\h\j_fy\uiheg_gby, kebrdhf keh`gZldlj_[m_lhlihevah\Zl_eyagZgbySQL.
IjbhldjulbbaZijhkZiZjZf_ljZf:p1, :p2, … [m^mlijbk\h_gug_dhlhju_ agZq_gbyAgZq_gbyiZjZf_ljh\^he`gu[ulvaZ^Zgukihfhsvxf_lh^ZParamByName dhfihg_glZTQuery. Wlhlf_lh^\ha\jZsZ_lkkuedmgZh[t_dlTParam, Zkkhpbbjm_fuc k aZ^Zgguf iZjZf_ljhf b kha^Z\Z_fuc ijb hldjulbb aZijhkZ. >ey ^hklmiZ d agZq_gbx iZjZf_ljZ kem`Zl k\hckl\Z TParam, lZdb_ dZd Value: Variant, AsString: String, AsInteger: integer. GZijbf_j Query1.ParamByName(‘P2’).Value:=Edit1.Text; Query1.ParamByName(‘P2’).AsString:=Edit1.Text;
H^gZdhg_kfhljygZ\g_rgxxkoh`_klvkh[t_dlZfbTField, lbiiZjZf_l jZa^_kviheghklvxhij_^_ey_lkyijbk\Zb\Z_fufagZq_gb_f<^Zgghfijbf_j_ wlh kljhdh\uc lbi ohly ih kfukem aZijhkZ iZjZf_lj gZ kZfhf ^_e_ fh`_l bf_lv^jm]hcg_kh\f_klbfuclbiqlhijb\_^_ldhrb[d_\h\j_fy\uiheg_gby ijh]jZffu Hq_\b^ghlZd`_qlhgZwlZi_ijh_dlbjh\Zgbydh]^ZagZq_gbyiZjZf_ljh\ _s_g_ijbk\h_gulZdhcaZijhkhldjulvg_evay Ihwlhfm j_dhf_g^m_lky gZ wlZi_ ijh_dlbjh\Zgby y\gh q_j_a bgki_dlhj h[t_dlh\ hij_^_eylvlbih[t_dlh\TParam; kh\iZ^_gb_lbih\ijbijbk\h_gbb agZq_gbciZjZf_ljZf[m^_ldhgljhebjh\Zlvkydhfibeylhjhfqlhkgbabl\blh]_ \_jhylghklvhrb[dbijb\uiheg_gbb < dZq_kl\_ ijbf_jZ gZibr_f ke_^mxs__ ijhkl_cr__ ijbeh`_gb_ bk ihevamxs__^bgZfbq_kdb_aZijhku 1. GZ nhjf_ jZaf_klbl_ dhfihg_glu TQuery, TDataSource, TDBgrid. K\y `bl_boklZg^Zjlgufh[jZahfBkihevamcl_ZebZk Zakpar.K\hckl\hActive mklZ
31
gh\bl_ \ False. Kha^Zcl_ h[t_dlu Edit1, Edit2: TEdit ^ey \\h^Z agZq_gby iZjZ f_ljh\bdghidmButton1. 2. AZg_kbl_\k\hckl\hSQL h[t_dlZTQuerykljhdm SELECT * FROM cd WHERE Total
>
:p1 and Data= :p2
3.
Jbk 4. <h[jZ[hlqbdkh[ulbyOnClick ^eydghidbButton1aZibrbl_ Query1.Close;I_j_^baf_g_gb_faZijhkh[yaZl_evghgZ^haZdjulv Query1.ParamByName(‘p1’).AsInteger:=StrToInt(Edit1.text); Query1.ParamByName(‘p2’).AsDate:= StrToDate(Edit1.text); Query1.Open;
Ijbeh`_gb_]hlh\h Wnn_dlb\gufijb_fhf^eyiZjZf_ljbaZpbbaZijhkZy\ey_lkybkihevah\Z gb_k\hckl\ZDataSource dhfihg_glZTQuery. ?keb\fhf_glhldjulbyaZijhkZ ijbeh`_gb_h[gZjm`blqlhmh^gh]hbaiZjZf_ljh\hlkmlkl\m_lagZq_gb_lh\ dZq_kl\_g_]h[_j_lkyagZq_gb_h^ghbf_ggh]hiheybagZ[hjZ^Zgguobfydhf ihg_glZTDataSource dhlhjh]hmdZaZgh\k\hckl\_DataSource dhfihg_glZ TQuery. GZijbf_j\dZq_kl\_agZq_gbyg_hij_^_e_ggh]hiZjZf_ljZnd \aZijh k_ SELECT * FROM cd WHERE cd.nd =
:nd
[m^_lijbgbfZlvkyagZq_gb_iheynd l_dms_caZibkb ^jm]hclZ[ebpuCust?k l_kl\_ggh_ lj_[h\Zgb_: G> ^ey lZ[ebpu Cust ^he`_g [ulv hldjul jZgvr_, q_faZijhkkiZjZf_ljhfnd.
32
3.2.2. Nhjfbjm_fu_aZijhku Wlhlkihkh[y\ey_lky[he__mgb\_jkZevguf, ghf_g__[ukljufA^_kvfh`ghg_ lhevdh aZ^Z\Zlv agZq_gby iZjZf_ljh\ gh b \b^hbaf_gylv nhjfm aZijhkZ, \\h ^blv ^hihegbl_evgu_ mkeh\by kem`_[gu_ keh\Z b l^ >ey wlh]h g_h[oh^bfh dhgkljmbjh\ZlvaZijhkkihfhsvxkj_^kl\jZ[hlukhkljhdZfbyaudZPascal, gZ ijbf_jQuery1.Sql.Add(µKljhdZ¶(GLWWH[W). EZ[hjZlhjgZyjZ[hlZkZfhklhyl_evgZy Kha^Zcl_ ijbeh`_gb_ ^ey ijhba\hevgh]h dhgkljmbjh\Zgby ijhklh]h aZ ijhkZ, kh^_j`Zs_]h eh]bq_kdh_ \ujZ`_gb_ Ijbf_jguc \b^ ]eZ\ghc nhjfu ijbeh`_gbyihdZaZggZjbk
Jbk Hlf_lbf qlh kbglZdkbk nhjfbjm_fh]h aZijhkZ ijh\_jy_lky dZ`^uc jZa \h\j_fy\uiheg_gbyqlhijbqZklhf\uiheg_gbbaZf_^ey_ljZ[hlmIZjZf_l jbq_kdb_aZijhkua^_kvbf_xlij_bfms_kl\hldhgbnhjfbjmxlkyh^bgjZa ihwlhfm bo fh`gh hldhfibebjh\Zlv \ bkihegy_fuc dh^ Z \ ^Zevg_cr_f g_ ijh\_jylvaZgh\hZlhevdhih^klZ\eylvgh\u_iZjZf_lju>eyih^]hlh\dbdlZ dhfmbkihevah\ZgbxiZjZf_ljbq_kdboaZijhkh\kem`blf_lh^Prepare, dhlhjuc j_dhf_g^m_lkyh^bgjZa\ua\Zlv\gZqZe_jZ[hluijbeh`_gbygZijbf_j\h[ jZ[hlqbd_OnCreate nhjfu J_^Zdlbjh\Zgb_j_amevlZlh\aZijhkZ Hkgh\gufbgkljmf_glhfSQL ^eyj_^Zdlbjh\Zgby[Za^Zgguoy\eyxlkyhi_jZ lhju UPDATE, INSERT, DELETEkf[4]).Qlh[ukboihfhsvxbaf_gblvagZq_
33
gby ihe_c g_h[oh^bfh ^ey dZ`^h]h lZdh]h hi_jZlhjZ aZ\_klb hl^_evguc dhf ihg_glTQuery bhldju\Zlv_]hf_lh^hfExecSQL. H^gZdh,fh`ghb©gZijyfmxª, dZdh[uqgmxlZ[ebpmj_^Zdlbjh\Zlv gZ[hj ^Zgguo \ha\jZsZ_fuc dhfihg_glhf TQuery kh^_j`Zsbf hi_jZlhj SELECT. >_ckl\bl_evgh TQuery hlghkblky d deZkkm TDataSet, ihwlhfm d g_fm fh`gh ijbf_gblvihqlb\k_f_lh^ubaeh`_-ggu_\jZa^_e_JZkkfhljbfg_dhlhju_ hkh[_gghklbwlh]hkihkh[Z Qlh[uaZijhkfh`gh[uehj_^Zdlbjh\Zlvg_h[oh^bfhkgZqZeZmklZgh\blv k\hckl\h RequestLive dhfihg_glZ TQuery \ True Ih mfheqZgbx hgh jZ\gh False). Ghwlhihfh]Z_lg_\k_]^ZlZddZdgZkZfhf^_e_g_\kydbcaZijhkfh `_l[ulvhlj_^Zdlbjh\ZgG_evayj_^Zdlbjh\ZlvaZijhkukh^_j`Zsb_Z]j_]Zl gu_ nmgdpbb hi_jZlhju JOIN, UNION, ij_^eh`_gby GROUP BY, DISTINCT, \u[hjdb ba g_kdhevdbo lZ[ebp LZdbf aZijhkZf Delphi ijbk\Zb\Z_l Zljb[ml ©lhevdh^eyql_gbyªk\hckl\hCanModify dhfihg_glZ TQuery ijbgbfZ_lagZq_ gb_ False, aZij_sZxs__ j_^Zdlbjh\Zgb_ IjbqbgZ khklhbl \ lhf qlh ijb bk ihevah\Zgbbmihfygmluohi_jZlhjh\hl^_evgufiheyfaZijhkZfh`_lg_khhl \_lkl\h\Zlv gb h^ghc aZibkb j_Zevghc lZ[ebpu eb[h gZijhlb\ khhl\_lkl\h \Zlvg_kdhevdhjZaguoaZibk_c. QZklbqgh h[hclb wlb aZij_lu fh`gh k bkihevah\Zgb_f dhfihg_glZ TUpdateSQL. Kmlv_]hjZ[hlukhklhbl\ke_^mxs_fNZdlbq_kdb^eyj_^Zdlbjh \Zgby[m^ml\uau\ZlvkySQL-aZijhkuUPDATE, INSERT, DELETE, ^eydhlhjuo f_gvr_©ij_]jZ^ª.(gZ ijbf_jijbihfhsbTDBGrid)khojZgyxlky\ehdZevghfijhf_`mlhqghf[mn_ j_gZdeb_glkdhcfZrbg_f_oZgbafdwrbjh\Zgbybaf_g_gbc Zmihfygmlu_aZ ijhkudhjj_dlghi_j_ghkyl\g_k_ggu_baf_g_gbyba[mn_jZ\j_ZevgmxlZ[ebpm gZk_j\_j_ EZ[hjZlhjgZyjZ[hlZ JZaf_klbl_ gZ nhjf_ jbk dhfihg_glu TQuery, TDataSource, TDBGrid, TUpdateSQL bk\y`bl_bo >eyTQuery mklZgh\bl_k\hckl\Z: Active True DatabaseName ZakPar CachedUpdates -7UXHJZaj_rZ_ldwrbjh\Zggu_baf_g_gby RequestLive -7UXHJZaj_rZ_lj_^Zdlbjh\ZlvaZijhk UpdateObject -8SGDWH64/KkuedZgZwda_fieyj78pdateSQL. SQL - SELECT name, price, sum(rest) FROM detal GROUP BY name, price
Ihke_^gbcaZijhkijh\h^bl\uqbke_gb_hklZldZgZkdeZ^_^eylh\Zjh\k h^bgZdh\ufbgZa\Zgbyfbbp_ghc
34
SQL. <j_amevlZl_ihemqZlkyaZijhku^eyh[gh\e_gbym^Ze_gbyb\klZ\dbaZib k_cGZijbf_jaZijhk^eyh[gh\e_gby[m^_lbf_lv\b^ UPDATE detal SET name = :name,price = :price WHERE name = :OLD_name AND price = :OLD_price
Ijb_]h\uiheg_gbb\f_klhiZjZf_ljh\:name, :price[m^mlih^klZ\e_guagZ q_gbyh^ghbf_gguoihe_cba[mn_jZ>Ze__wlbagZq_gby[m^mlijbk\h_guih eyf l_o aZibk_c nbabq_kdhc lZ[ebpu ^ey dhlhjuo agZq_gby dexq_\uo ihe_c kh\iZ^Zxl kh klZjufb agZq_gbyfb bf_\rbfbky ^h \uiheg_gby aZijhkZ Ih ke_^gb_agZq_gby\l_dkl_aZijhkZhlebqZxlkyijbklZ\dhc:OLD_. >ey \uiheg_gby knhjfbjh\Zgguo aZijhkh\ UPDATE, INSERT, DELETE kem`blf_lh^dhfihg_glZTUpdateSQL procedure Apply (UpDateKind: TUpDateKind);
IZjZf_ljm UpDateKind gZ^h ij_^\Zjbl_evgh ijbk\hblv dhgklZglm h[h agZqZxsmxlbiaZijhkZ, ukModify, ukInsert, ukDelete. 3. JZaf_klbl_ ^\_ dghidb b dhfihg_glu TTable, TDataSource, TDBGrid ^eyijhkfhljZbaf_g_gbc\lZ[ebp_Detal. 4. Kha^Zcl_h[jZ[hlqbdbkh[ulbc OnClick ^eydghihd: procedure TForm1.Button1Click(Sender: TObject); begin Table1.Close; Table1.Open; end; procedure TForm1.Button2Click(Sender: TObject); begin Query1.Close; Query1.Open; end;
OnAfterPost ^eyQuery1: procedure TForm1.Query1AfterPost(DataSet: TDataSet); begin try UpdateSql1.Apply(ukModify); //
>h[Z\vl_kZfhklhyl_evgh\hafh`ghklv\klZ\dbbm^Ze_gby I_j_^\uiheg_gb_fijbeh`_gbyj_dhf_g^m_lky\uclbbakj_^u Delphi. J_amev lZl[m^_lbf_lv\b^jbk
35
Jbk DZd\b^ghbajbkmgdZh^ghcaZibkb=\ha^v\G>Query1 (\gb`g_cqZklb nhjfu [m^_lkhhl\_lkl\h\Zlv^\_aZibkb=\ha^v\G>Table1 \\_jom ?kebba f_gblv\Query1p_gm]\ha^yPrice gZ23 bgZ`Zlvdghidm©H[gh\blvlZ[ebpmª lhwlhgh\h_agZq_gb_ihy\blkykjZam\^\mokljhdZo\_jog_clZ[ebpu Ih^q_jdg_fqlh 1) dhfihg_glTUpdateSQL fh`_lijbf_gylvkydZddehdZevguflZdbd m^Ze_gguf;>, 2) kh[kl\_ggh ^ey dwrbjh\Zgby baf_g_gbc DB hg dZd ijZ\beh g_ gm`_g DBbkihevamxlky^eymkdhj_gbyjZ[hlu\k_lbA^_kv^hklZlhqghf_lh ^h\ ApplyUpdates nbdkZpby baf_g_gbc gZ k_j\_j_ , CommitUpdates hqbkldZ dwrZhlaZnbdkbjh\Zgguobaf_g_gbc bk\hckl\Z CachedUpdates: Boolean jZa j_r_gb_dwrbjh\Zgbybaf_g_gbc dhfihg_glZTQuery. BlZddhfihg_glTUpdateSQL g_y\ey_lkyh[yaZl_evgufbj_Zevghlj_[m _lky ebrv ijb g_h[oh^bfhklb j_^Zdlbjh\Zlv aZijhku ©lhevdh ^ey ql_gbyª TUpdateSQL bf__l©hkh[_gghklbª>Z`_\ijhklhfijb\_^_gghf\ur_ijbf_j_ Z\lhjmihlj_[h\Zekyh[oh^ghcfZg_\jgZclbbh[tykgblvdhlhjucdnhjfZlmInterBase.
4. JZ[hlZkk_j\_jhfInterBase InterBase – wlhijhfure_ggZyKM;>ij_^gZagZq_ggZy^eyjZ[hlu\kj_^_©deb _gl-k_j\_jª<ijhp_kk_h[mq_gbyfh`ghbkihevah\ZlvdZdihegmx\_jkbxInterBaselZdbehdZevguch^ghihevah\Zl_evkdbck_j\_j\oh^ysbc\dhfie_dlih klZ\db Delphi, ijb]h^guc ^ey \_^_gby ehdZevguo ;> b ^ey ij_^\Zjbl_evghc hleZ^db ijbeh`_gbc ^ey kj_^u ©deb_gl-k_j\_jª gZ ehdZevghc W
36
lh^bdZjZ[hlukInterBase hibkZgZ\[5]A^_kv[he__ih^jh[ghjZkkfZljb\Zxlky g_dhlhju_hkh[_gghklbkha^Zgbyijbeh`_gbchlebqZxsb_InterBasehlehdZev guoKM;> 4.1. Dhfihg_glTDataBase Wda_fieyj dhfihg_glZ TDataBase Z\lhfZlbq_kdb g_aZ\bkbfh hl `_eZgby ijh ]jZffbklZkha^Z_lky\ijbeh`_gbb^eydZ`^hchldjulhc;>IjbjZ[hl_\kj_ ^_deb_gl-k_j\_jj_dhf_g^m_lky_]hkha^Z\Zlvy\ghi_j_ghkykhhl\_lkl\mxsbc dhfihg_glgZnhjfmbeb\fh^mev^ZgguoY\gh_kha^Zgb_h[_ki_qb\Z_l^hklmi dk\hckl\Zfbf_lh^ZfTDataBase. Hkgh\gu_aZ^ZqbTDataBase: mijZ\e_gb_kh _^bg_gb_fk;>mijZ\e_gb_ljZgaZdpbyfbj_]bkljZpbyihevah\Zl_eygZk_j\_ j_ G_dhlhju_hkgh\gu_k\hckl\Zbf_lh^u PropertyAliasName: string; Property DataBaseName: string; Property LoginPrompt: Boolean; PropertyParams: TStrings; Property Connected: Boolean Procedure StartTransaction; procedure Commit; procedure RollBack; property IsTransaction: Boolean; procedure ApplyUpdates (const DataSets: array of TDataSet) property TransIsolation: TTransIsolation;
AZ^Z_lZebZk;> AZ^Z_lehdZevgucik_\^hgbfbkihevam_fuc^Ze__\ k\hckl\_DataBaseNamedhfihg_glZoTDataSet. TruehagZqZ_lqlhbfyihevah\Zl_eybiZjhev\k_]^Z [m^ml aZijZrb\Zlvky ijb kh_^bg_gbb k ;> False – [m^mlkqblu\Zlvkybak\hckl\ZParams. Kibkhd iZjZf_ljh\ kh_^bg_gby k ;> < qZklghklb a^_kvmdZau\Zxlkymq_lgh_bfybiZjhev MdZau\Z_lbf__lebdhfihg_glZdlb\gh_kh_^bg_gb_ k;> Ihke_\uah\Z\k_baf_g_gby\ghkbfu_\;>kqblZ xlkyhlghkysbfbkydl_dms_cZdlb\ghcljZgaZdpbb AZ\_jrZ_l \uiheg_gb_ l_dms_c ljZgaZdpbb b nbd kbjm_l\k_baf_g_gby\;> HldZlljZgaZdpbb Khh[sZ_lbf__lkyebZdlb\gZyljZgaZdpby Ih^l\_j`^Z_l dwrbjh\Zggu_ baf_g_gby \ g_kdhev dbo G> i_j_qbke_gguo \ hldjulhf fZkkb\_ DataSets. AZ^Z_lmjh\_gvbaheypbbljZgaZdpbcgZk_j\_j_ [1,2].
Ijbf_qZgby 1). <ijhkl_cr_fkemqZ_^hklZlhqghbkihevah\Zlv k\hckl\ZAliasname, DataBaseName.
37
2). J_^Zdlbjh\Zgb_k\hckl\kh_^bg_gbyParams j_dhf_g^m_lkykihfhsvx j_^ZdlhjZ\uau\Z_fh]h^\hcgufs_eqdhfihdhfihg_glm 3)GZwlZi_hleZ^dbj_dhf_g^m_lkyih^Z\blvaZijZrb\Zgb_mq_lgh]hbf_ gbbiZjheybkihevamyk\hckl\Z LoginPromptbParams. 4)<k\hckl\_DataBaseName dhfihg_glh\ TDataSet l_i_jv mdZau\Z_lkyg_ ZebZk;>ZagZq_gb_k\hckl\Z DataBaseName dhfihg_glZ TDataBase. 4.2=_g_jZlhju <lZ[ebpZoParadox ^eyojZg_gbyagZq_gbcmgbdZevguoi_j\bqguodexq_cbk ihevamxlkyiheyAutoIncrementh[_ki_qb\Zxsb_ Z\lhfZlbq_kdh_ijbjZs_gb_ agZq_gby ihey ijb ^h[Z\e_gbb gh\hc aZibkb<InterBase \f_klhwlh]hbkihev amxlky ]_g_jZlhju =_g_jZlhj – ojZgbfuc gZ k_j\_j_ f_oZgbaf \ha\jZsZx sbcijbh[jZs_gbbdg_fmgh\h_mgbdZevgh_agZq_gb_ Kha^Zgb_]_g_jZlhjZ: &5($7(*(1(5$725Bfy=_g_jZlhjZ
MklZgh\dZgZqZevgh]hagZq_gby:
6(7*(1(5$725Bfy=_g_jZlhjZ72GZqAgZq_gb_
Kha^Zgb_bmklZgh\dZ\uihegy_lkyeb[hkihfhsvxhl^_evguoaZijhkh\eb[h\ ^bZeh]h\hfj_`bf_kihfhsvxmlbebluSQL Explorer. >eyh[jZs_gbyd]_g_jZlhjmkem`blnmgdpby: GEN_ID Bfy=_g_jZlhjZIjbjZs_gb_
Kihkh[uh[jZs_gbyd]_g_jZlhjm 1. C ihfhsvxhi_jZlhjZINSERT. GZijbf_jjZaf_klbl_gZnhjf_g_kdhevdhkljhdj_^Zdlbjh\Zgbyk\yaZg gu_ dhfihg_glu Query1, DataSource1, DBGrid1 b ^hihegbl_evgh hl^_evguc Query2<k\hckl\hSQL Query1 aZibrbl_
SELECT * FROM cust
Z\Query2 INSERT
INTO
cust(nc,
name,
address) VALUES (GEN_ID(G1,1), Edit1.Text, Edit2.Text)
A^_kvG1 – bfyjZg__kha^Zggh]hh[Z\blvaZibkvªaZibrbl_ Query2.ExecSql; Query1.Close; Query1.Open;
Kihfhsvxljb]]_jZ. Kha^Zcl_bkihevamymlbeblmWISQL bebSQL Explorerljb]]_j CREATE TRIGGER by_nc FOR cust BEFORE INSERT AS BEGIN new.nc=gen_id(g1,1); END
38
=_g_jZlhj[m^_lZ\lhfZlbq_kdb\uau\Zlvkyijbj_^Zdlbjh\Zgbbi_j_^kh [ulb_faZihfbgZgbygh\hcaZibkbDexq_\h_ihe_nd ihevah\Zl_e_fg_\\h^bl ky; hghaZihegy_lky]_g_jZlhjhf AZf_qZgby: Wlhl f_lh^ ijb]h^_g lhevdh ^ey j_^Zdlbjh\Zgby G>, \ha\jZsZ_fuo dhfihg_glhf TQuery. Ijbbkihevah\ZgbbTTable ]_g_jZlhjuke_^m_l\uau\Zlv baojZgbfuoijhp_^mj 2) <hi_jZlhj_INSERT, bkihevam_fhfdZdkZfhklhyl_evghlZdb\khklZ\_ dhfihg_glZ TUpdateSQL dexq_\h_ ihe_ ^ey dhlhjh]h ihkljh_g ]_g_jZlhj ^he`gh[ulvhims_gh 3. KihfhsvxojZgbfhc ijhp_^mju CREATE PROCEDURE Get_Num RETURNS (n INTEGER) AS BEGIN n = gen_id(g1,1); END
Ijbf_j JZkiheh`bl_ ljb k\yaZgguo dhfihg_glZ Table1, DataSource1, DBGrid1 b h^bg dhfihg_gl SP1: TStoredProc. AZibrbl_ \ k\hckl\_ DatabaseName ZebZk;>Z\k\hckl\hStoredProcName bfyojZgbfhcijhp_^mju (Get_Num). Ijhkfhljbl_ k\hckl\h Params b m[_^bl_kv qlh iZjZf_lj n ojZgb fhcijhp_^mjulZfijbkmlkl\m_lbhibkZgijZ\bevgh : procedure TForm1.Table1AfterInsert(DataSet: TDataSet); begin Sp1.Close; Sp1.Prepare; Sp1.ExecProc; Table1.FieldByName('nd').Value := Sp1.ParamByName('n').Value; Sp1.Close; end;
gZk_j\_j_b\uau\Z_fucbaijbeh`_gbcQZklhbkihev am_fu_ lbih\u_ SQL-aZijhku d k_j\_jm j_dhf_g^m_lky hnhjfeylv \ \b^_ ojZ gbfuo ijhp_^mj lZd dZd wlh ih\urZ_l [ukljh^_ckl\b_ kbkl_fu OjZgbfu_ ijhp_^mju kha^Zxlky\kj_^_WISQL bebSQL Explorer. NhjfZlojZgbfhcijh p_^mju: &5($7(352&('85(BfyIjhp_^mju>
39
Ijbeh`_gb_ h[f_gb\Z_lky bgnhjfZpb_c k ojZgbfhc ijhp_^mjhc q_j_a kibkhd\oh^guob\uoh^guoiZjZf_ljh\dZdkh[uqghcijhp_^mjhcgZPascal’e.
?keb\ojZgbfhcijhp_^mj_bkihevamxlkyehdZevgu_i_j_f_ggu_lh\k_ hgb^he`gu[ulvh[ty\e_gu:
'(&/$5(9$5,$%/(BfyI_j_f_gghcLbi
KbglZdkbk yaudZ \h fgh]hf ZgZeh]bq_g Pascal. Ijb gZibkZgbb l_eZ ojZ gbfhcijhp_^mjufh]mlbkihevah\Zlvky: hi_jZlhjijbk\Zb\ZgbyBfyI_j_f_gghc \ujZ`_gb_; hi_jZlhjgu_kdh[dbBEGIN …END, hi_jZlhjIF(<mkeh\b_>)THEN ELSE , hi_jZlhjpbdeZ WHILE (<mkeh\b_>) DO bg_dhlhju_^jm]b_[1]. OjZgbfZyijhp_^mjZfh`_lkh^_j`ZlvjZaebqgu_SQL-hi_jZlhjuHi_jZ lhjSELECTbkihevam_lky\jZkrbj_gghcj_^Zdpbb<g_]h^h[Z\ey_lkyij_^eh `_gb_INTO :i_j_f_ggZy[, :i_j_f_ggZy]. <i_j_qbke_ggu_i_j_f_ggu_beb\u oh^gu_iZjZf_lju[m^mlaZibkZguagZq_gby\ha\jZsZ_fu_hi_jZlhjhf SELECT. OjZgbfu_ijhp_^mju^_eylkygZijhp_^mju^_ckl\bybijhp_^mjuhl[h jZ Ijhp_^mju ^_ckl\by g_ \ha\jZsZxl iZjZf_ljh\ beb \ha\jZsZxl h^bg wd a_fieyj iZjZf_ljh\ Ih^ wda_fieyjhf ihgbfZ_lky kljhdZ \ j_amevlbjmxs_f gZ[hj_^ZgguoIjhp_^mjuhl[hjZ\ha\jZsZxlg_kdhevdhwda_fieyjh\>ey\u ah\Zijhp_^mj^_ckl\by\InterBase ijbf_gy_lkydhfihg_glTStoredProc, ^ey\u ah\Zijhp_^mjhl[hjZ–dhfihg_glTQuery. EZ[hjZlhjgZyjZ[hlZZakGdb ojZgbfmxijhp_^mjm:
CREATE PROCEDURE MAXIM (dname CHAR(10)) RETURNS (max_total integer) AS BEGIN SELECT max(cd.Total) FROM cd, detal WHERE (cd.nd=detal.nd)and (detal.name= :dname) into :max_total; END
2. JZaf_klbl_gZnhjf_dhfihg_gluDataBase1: TDataBase, Query1, DataSource1, DBGrid1 bStoredProc1. GZkljhcl_DataBase1 gZZebZkZakGdb blZ[eb
40
lZ[ebpm Detal b hij_^_ebl_ ehdZevguc ZebZk db1. Kh_^bgbl_ i_j\u_ q_luj_ dhfihg_glZMklZgh\bl_k\hckl\ZStoredProc1: Name - Sp1 StoredProcName - Maxim DatabaseName - Db1 <h[jZ[hlqbd_kh[ulbys_eqdZihyq_cd_lZ[ebpuDBGrid1 aZibrbl_ procedure TForm1.DBGrid1CellClick(Column: TColumn); begin Sp1.Unprepare; // AZ^Zgb_\oh^gh]hiZjZf_ljZojZgbfhcijhp_^mju: Sp1.ParamByName('Dname').AsString:= table1.FieldByName('Name').AsString; Sp1.Prepare; // K\yau\Zgb_iZjZf_ljh\Sp1 biZjZf_ljh\OI Sp1.ExecProc; //
Jbk Fh^bnbpbjmcl_aZijhk^ey\u^ZqbfZdkbfZevgh]hfbgbfZevgh]hb kj_^g_]haZdZaZ EZ[hjZlhjgZyjZ[hlZ
A^_kv hi_jZlhj SUSPEND \uihegy_lky ^ey dZ`^hc kljhdb \ha\jZs_gghc hi_ jZlhjhfSELECT. Hi_jZlhj SUSPEND i_j_^Z_lagZq_gby\uoh^guoiZjZf_ljh\ \uau\Zxs_fm ijbeh`_gbx b ijbhklZgZ\eb\Z_l jZ[hlm ojZgbfhc ijhp_^mju
41
ihdZ ijbeh`_gb_ g_ aZijhkbl ke_^mxsmx ihjpbx iZjZf_ljh\ Ihke_ wlh]h mijZ\e_gb_kgh\Zi_j_^Z_lkyhi_jZlhjmSELECT. Baijbeh`_gby ojZgbfZyijhp_^mjZhl[hjZ\uau\Z_lkyhi_jZlhjhf 6(/(&7 )520BfyOI!kibkhd\oh^guoiZjZf_ljh\!
Kha^Zcl_ojZgbfmxijhp_^mjm CREATE PROCEDURE zakazy (dname CHAR(10)) RETURNS (out_nc INTEGER, out_data DATE, out_total INTEGER) AS BEGIN FOR SELECT cd.nc, cd.data, cd.total FROM cd, detal WHERE (cd.nd=detal.nd) and (detal.name= :dname) INTO :out_nc, out_data, out_total DO SUSPEND; END
>ZggZyijhp_^mjZ\u\h^blbgnhjfZpbxhaZdZaZogZba^_eb_i_j_^Z\Z_ fh_\h\oh^ghfiZjZf_lj_ JZkiheh`bl_^\_ljhcdbdhfihg_glh\TQuery, TDataSource, TDBGrid b h^bgDataBase1: TDataBase.K\y`bl_bok;>ZakGdb (kfjbk
Jbk <k\hckl\hSQL ^eyQuery1 aZibrbl_ select * from detal
Z\k\hckl\hSQL ^eyQuery2 select * from zakazy (:dname)
H[jZs_gb_dojZgbfhcijhp_^mj_ zakazy (:dname) mdZau\Z_lkyihke_ from\f_ klhbf_gblZ[ebpu H[jZ[hlqbd^eyDBGrid1: procedure TForm1.DBGrid1CellClick(Column: TColumn); begin
42
Query2.Close; Query2.ParamByName('Dname').asstring:= Query1.FieldByName('Name').asstring; Query2.open; end;
GZi_j\uc\a]ey^^eyih^h[gh]hmklZgh\e_gbyk\ya_cf_`^mlZ[ebpZfb m^h[g__bkihevah\Zlvk\hckl\Zdhfihg_glh\TTablekfi h^gZdh\©deb _gl-k_j\_jguoªijbeh`_gbyoih^h[gu_gZ\b]Zpbhggu_ijb_fug_j_dhf_g^m xlky Ljb]]_ju Ljb]]_j – wlh ojZgbfZy gZ k_j\_j_ hkh[Zy ijhp_^mjZ Z\lhfZlbq_kdb \uau\Z_ fZyijbgZklmie_gbbdZdh]h-eb[hkh[ulby\;><dZq_kl\_kh[ulbcjZkkfZljb \Zxlky baf_g_gb_ m^Ze_gb_ beb ^h[Z\e_gb_ aZibkb D ljb]]_jm g_evay h[jZ lblvkybaijbdeZ^ghcijh]jZffumg_]hhlkmlkl\mxl\oh^gu_b\uoh^gu_iZ jZf_ljuKihfhsvxljb]]_jh\h[uqghj_Zebamxlky[bag_k-ijZ\beZaZ^Zxsb_ eh]bdmjZ[hlmk;>gZijbf_j]_g_jZlhju^eyih^^_j`ZgbymgbdZevguoagZq_ gbcdexq_\uoihe_cdZkdZ^gu_\ha^_ckl\by^eyh[_ki_q_gbykkuehqghcp_eh klghklb\_^_gb_j_]bkljZpbhgguo`mjgZeh\gZdZieb\Zgb_klZlbklbdbbli Ljb]]_jkha^Z_lkyhi_jZlhjhf &5($7(75,**(5BfyLjb]]_jZ)25BfyLZ[ebpu [ACTIVE | INACTIVE] {BEFORE | AFTER} {DELETE | INSERT | UPDATE} $6L_ehljb]]_jZ!
ACTIVE|INACTIVEmdZau\Z_lZdlb\_gljb]]_jbebg_lIhmfheqZgbx^_ckl\m_l ACTIVE. BEFORE | AFTERmdZau\Z_lfhf_gl\uiheg_gbyljb]]_jZ^hbebihke_aZihfb gZgbybaf_g_gbc\;> DELETE | INSERT | UPDATEmdZau\Z_llbikh[ulbygZdhlhjh_j_Z]bjm_lljb] ]_j NhjfZll_eZljb]]_jZbZe]hjblfbq_kdbcyaudlZdb_`_dZdmojZgbfuo ijhp_^mjHlebqb_khklhbl\\hafh`ghklbh[jZs_gbydklZjufbgh\ufagZq_ gbyfklhe[ph\lZ[ebpuAZibkvOLD.BfyKlhe[pZhagZqZ_lh[jZs_gb_dkh klhygbxklhe[pZ^h\g_k_gby\hafh`guobaf_g_gbcAZibkvNEW.BfyKlhe[pZ – dkhklhygbxklhe[pZihke_\g_k_gby\hafh`guobaf_g_gbc Ijbf_jljb]]_jZ^eyih^^_j`Zgbykkuehqghcp_ehklghklbiml_fdZkdZ^ guobaf_g_gbc\k\yaZgguolZ[ebpZo CREATE TRIGGER by_nc FOR cust ACTIVE BEFORE UPDATE AS BEGIN
43
IF (old.nc <> new.nc) THEN UPDATE cd SET nc = new.nc WHERE nc=old.nc END
Ljb]]_j^eydZkdZ^gh]hm^Ze_gbyaZibk_cgZibrbl_kZfhklhyl_evgh AZf_qZgb_: i_j_^bkihevah\Zgb_flZdh]hjh^Zljb]]_jh\g_h[oh^bfhm^Zeblvba ;>h]jZgbq_gbykkuehqghcp_ehklghklb_kebhgbbf_xlky
AZ^Zgby^eykZfhklhyl_evghcjZ[hlu AZ^Zqb ih ijh_dlbjh\Zgbx [Za ^Zgguo ^ey dhgdj_lguo ij_^f_lguo h[eZkl_c kf\f_lh^bq_kdbomdZaZgbyo [4,5]. Ijbf_jgu_aZ^ZqbgZihkljh_gb_SQL-aZijhkh\J_r_gb_dZ`^hcaZ^Zqb^he` ghbf_lv\b^aZdhgq_ggh]hijbeh`_gbyg_h[oh^bfu_iZjZf_lju^he`gu\\h ^blkykihfhsvx\bamZevguodhfihg_glh\J_r_gb_ij_^klZ\ey_lky\^\mo\Z jbZglZo: gZ hkgh\_ deb_glkdbo aZijhkh\ b k bkihevah\Zgb_f ojZgbfuo ijhp_ ^mj. 1. <lZ[ebpZocust, detal, cd \u\_klbnZfbebbihdmiZl_e_caZ^Zggh]hlh\ZjZaZ aZ^Zgguc ijhf_`mlhd \j_f_gb Ih\lhjyxsboky ihdmiZl_e_c ba kibkdZ bk dexqblv 2. GZclbaZdZaqbdh\mdhlhjuobf_xlkyihdmidb^Zggh]hlh\ZjZ\dhebq_kl\_ ij_\urZxs_fkj_^gbch[t_fihdmihd^Zggh]hlh\ZjZ 3. < lZ[ebpZo cust, detal, cd \u\_klb gZa\Zgby ^_lZe_c dmie_gguo mdZaZgguf aZdZaqbdhfaZmdZaZggmx^Zlm 4.
44
12.GZclbaZdZaqbdh\qZs_\k_]hihdmiZ\rbomdZaZgguclh\Zj 13.GZclbkmffmaZdZah\k^_eZgguogZmdZaZgguclh\ZjaZ^Zgguci_jbh^ 14.GZclb gZa\Zgby ]hjh^h\ ba dhlhjuo qZs_\k_]h^_eZebkvaZdZauaZ^Zgguc i_jbh^\j_f_gb 15.GZclb aZdZaqbdZ ba mdZaZggh]h ]hjh^Z dmib\r_]h kZfuc ^_r_\uc lh\Zj ba \\_^_gghcp_gh\hc]jmiiu 16.K ihfhsvx ljb]]_jh\ j_Zebah\Zlv \_^_gb_ `mjgZeZ klZlbklbdb ijh^Z` ih dZ`^hfm]hjh^mblh\Zjm 17.Kha^Zlvljb]]_ju^eyh[_ki_q_gbydZkdZ^guobaf_g_gbc\;>©AZdZauª 18.Kha^Zlvljb]]_j^ey\_^_gby`mjgZeZbaf_g_gbc^eylZ[ebpu©>_lZebª 19.>ey ;> ©IhebdebgbdZª gZibkZlv ljb]]_j ^ey \_^_gby klZlbklbdb aZ[he_\Z gbc^eyjZaguo\hajZklguo]jmii Ke_^mxsb_aZ^Zqbj_rblvkbkihevah\Zgb_fbg^_dkh\bnbevljh\ 20.Ih^kqblZlvkj_^gbch[t_fk^_ehdgZ^Zgguclh\ZjaZ^Zgguci_jbh^ 21.Ih^kqblZlvkmffmaZdZah\k^_eZgguobamdZaZggh]h]hjh^ZaZ^Zgguci_jb h^ 22.Ih^kqblZlvqbkehaZdZaqbdh\ba^Zggh]h]hjh^Zdmib\rbo^Zgguclh\Zj 23.<;>©GZmqgZydhgn_j_gpbyªih^kqblZlvkmffm\g_k_gguohj]\aghkh\^hd eZ^qbdZfbba^Zggh]h]hjh^Z 24.GZibkZlvnhjfm^eyaZg_k_gbybgnhjfZpbb\lZ[ebpmDetal. I_j_^aZg_k_gb _fijh\_jblvbf__lkyeb^Zgguclh\Zjm`_gZkdeZ^_ 25.GZibkZlvnhjfm^eyaZg_k_gbybgnhjfZpbb\lZ[ebpm©Dhgn_j_gpbyª
Keh\Zjvl_jfbgh\ :ebZk Mkeh\gh_ gZbf_gh\Zgb_ dZlZeh]Z ]^_ gZoh^blky;>:ebZkuj_]bkljb jmxlkybbkihevamxlkyBDE. ;ZaZ^Zgguo. GZ[hj\aZbfhk\yaZgguolZ[ebp hihegbl_evguc bg^_dk kljhysbcky ih ex[hfm dexqm djhf_i_j\bqgh]hdexqZ Bg^_dkKljmdlmjZaZ^ZxsZyeh]bq_kdbcihjy^hdaZibk_c\lZ[ebp_hlebqguc hlnbabq_kdh]hihjy^dZ DeZkkH[t_dlh\uclbii_j_f_gguo DexqIhe_ihdhlhjhfmijhbkoh^blkhjlbjh\dZbebihbkd Dhfihg_gl JZagh\b^ghklv deZkkZ kihkh[gZy \bamZevgh i_j_ghkblvky \ ijh ]jZffm Dwrbjh\Zggu_ baf_g_gby F_oZgbaf ^hklmiZ ijb dhlhjhf \k_ baf_g_gby \ lZ[ebp_aZihfbgZxlky\[mn_j_gZehdZevghcW
45
Fh^mev ^ZgguoG_hlh[jZ`Z_fZynhjfZdhgl_cg_j^eydhfihg_glh\^hklmiZ d^Zgguf H[t_dlWda_fieyjdeZkkZ. I_j\bqgucbg^_dk. Bg^_dkihkljh_ggucihi_j\bqghfmdexqm. I_j\bqguc dexq Ihe_ mgbdZevguf h[jZahf b^_glbnbpbjmxs__ aZibkv \ lZ[ebp_ LjZgaZdpby. Eh]bq_kdZy_^bgbpZbaf_g_gbc^Zgguoi_j_\h^ysZy;>bah^gh ]hp_ehklgh]hkhklhygby\^jm]h_ KhklZ\ghcdexq. Dexqkhklhysbcbag_kdhevdboihe_c L_dmsZyaZibkvAZibkv^hklmigZy^eyj_^Zdlbjh\Zgby NhjfZ
Ijbeh`_gb_ IKljmdlmjZnjZ]f_glZ;>©AZdZauª (nhjfZl Paradox) LZ[ebpZCust (©AZdZaqbdbª) Ihe_ Lbi >ebgZ nc AutoIncrement Name Alpha kbf\hev 20 guc AdAlpha kbf\hev 20 dress guc LZ[ebpZDetal (©>_lZebª) nd AutoIncrement Name Alpha kbf\hev guc Price Number Rest Long Integer
20
LZ[ebpZCD (©@mjgZeaZdZah\ª) no AutoIncrement Nc Long Integer Nd Long Integer Kolvo Long Integer Total Number Data Date
HibkZgb_ Dh^aZdZaqbdZi_j\bqgucdexq BfyaZdZaqbdZ\lhjbqgucdexq :^j_kaZdZaqbdZ
Dh^ ba^_ebyi_j\bqgucdexq Bfyba^_eby\lhjbqgucdexq P_gZ_^bgbpulh\ZjZm_ HklZlhdgZkdeZ^_rlmd Ghf_jaZdZaZi_j\bqgucdexq Dh^aZdZaqbdZ Dh^ba^_eby H[t_faZdZaZrlmd H[t_faZdZaZm_ >ZlZaZdZaZ
46
ILbiuihe_cParadox Lbiih H[h OjZgbfu_agZq_gby ey -ag Alpha A Kbf\hevgu_agZq_gby^ebghc^hkbf\heh\ Number N QbkeZkieZ\Zxs_clhqdhc\^bZiZahg_–10307 … 10 308. LhqghklvagZqZsbopbnj Money $ :gZeh]bq_gNumberghqbkehagZdh\ihke_aZiylhc– 2. h kbf\heh\fh`_lojZgblvky\lZ[ebp_hklZevgu_hl^_evgh \MB-nZce_ Lh`_ghojZgbll_dklunhjfZlbjh\Zggu_rjbnlhfp\_ Format- F lhfbli ted Memo =jZnbq_kdb_bah[jZ`_gby\nhjfZl_nZceh\.bmp, .pcx, .tif, Graph- G .gif, .epsOjZgylky\hl^_evguonZceZo ics Fields OLE O BgnhjfZpbyh[h[t_dlZoOLE (Object Linking and Embedding). Logical L Eh]bq_kdb_agZq_gby‘True’, ‘False’. AutoIn- ± P_eu_qbkeZlhevdh^eyql_gbykZ\lhfZlbq_kdbfijbjZs_ crement gb_fgZijb^h[Z\e_gbbgh\hcaZibkbBkihevamxlky\ dZq_kl\_i_j\bqgh]hdexqZ Binary B Ijhba\hevgu_^\hbqgu_agZq_gbybgl_jij_lbjm_fuijh (Blob) ]jZffhcihevah\Zl_eyOjZgylkyhl^_evgh\F<-nZce_ Bytes Y Lh`_ghojZgylky\f_kl_klZ[ebp_c ILbiuihe_cInterBase Lbiihey JZaf_j OjZgbfu_agZq_gby [Zcl SmallInt 2 P_eu_qbkeZ\^bZiZahg_–32767 … 32767. Integer 4 P_eu_qbkeZ\^bZiZahg_–2147 483648 … 2147483647.
47
Float
4
Double precision Char(n) VarChar(n) Date Blob
8 0-32767 0-32767 8 I_j_f
QbkeZkieZ\Zxs_clhqdhc\^bZiZahg_–3,4 ⋅1038 … 3,4 ⋅10 38^h7agZqZsbopbnj QbkeZkieZ\Zxs_clhqdhc\^bZiZahg_ –1,7 ⋅10307 … 1,7⋅ 10 308 lhqghklvx^hagZqZsbopbnj Kbf\hevgucklhe[_p^ebghcn kbf\heh\. Kbf\hevgucklhe[_pi_j_f_gghc ^ebgukh^_j`Zsbc ^hn kbf\heh\. >ZlZ\ij_^_eZohl^h.12.5491b\j_fy Ex[hclbi^\hbqguo^Zgguo.
Ebl_jZlmjZ 1. RmfZdh\ I< Delphi 3 b jZajZ[hldZ ijbeh`_gbc [Za ^Zgguo – F ©Gh eb^`ª–k 2. >ZjZo\_eb^a_ I= FZjdh\ ?I Delphi 4. - KI[ «BHV-KZgdl-I_l_j[mj]ª 1999. -k 3. LxdZq_\G:K\bjb^h\XLIjh_dlbjh\Zgb_[Za^Zgguo\Delphi. – hklmi d ;> \ Delphi / Khkl.: F<;ZdeZgh\, G:LxdZq_\, XLK\bjb^h\; BamqbkZfijh]jZffbjh\Zgb_[Za^Zgguo\Delphi 2.0 k_]h^gyFg©Ihimjjbª-k 7. >Zgl_fZgg>Fbr_e>L_cehj>Ijh]jZffbjh\Zgb_\kj_^_Delphi. - D ©>bZKhnlEl^ª-k 8. ?iZg_rgbdh\ : ?iZg_rgbdh\ < Ijh]jZffbjh\Zgb_ \ kj_^_ Delphi 2.0. QZklv2. - F«>B:EH=-FBNB», 1997. -k 9. JZajZ[hldZ Windows-ijbeh`_gbc Delphi / Khkl: <=Jm^Ze_\;
48
KH>?J@:GB? IJ?>BKEH
F?LH>BD: KHA>:GBY IJBEH@?GBC ............................................................................. 3 <>?GB?.................................................................................................................................... 3 HKGHM L:;EBP:FB ...................................................................... 8 FH>MEB >:GGUO .................................................................................................................... 10 G:HKLMI D ;> ...................................................................................... 11 J:;HL: K IHEYFB G:;HJ: >:GGUO .................................................................................... 11
Kha^Zgb_ h[t_dlh\-ihlhfdh\ ............................................................................. 12 J_^Zdlhj ihe_c ................................................................................................................. 12 H[jZs_gb_ d ihex ............................................................................................................ 13 Ihemq_gb_ bgnhjfZpbb h iheyo..................................................................................... 15
7)LHOG
G::GGUO .......................................................................................... 17 >?CKL L?DMS?C A:IBKVX ..................................................................................... 18 NBEVLJ:PBY G:;HJ: >:GGUO ............................................................................................. 19 BG>?DKU B BG>?DKGUC IHBKD ........................................................................................... 21
2.5.1 Kha^Zgb_ bg^_dkZ .............................................................................................................. 21 Ihemq_gb_ bgnhjfZpbb h[ bg^_dk_ ............................................................................... 22 Bg^_dkguc ihbkd .............................................................................................................. 23
3. SQL-HJB?GLBJH<:GGUC >HKLMI D ;> ........................................................................ 26
BKIHEVAH<:GB? SQL ............................................................................................................ 26 >BG:FBQ?KDB? A:IJHKU ..................................................................................................... 30
IZjZf_ljbaZpby aZijhkh\ .............................................................................................. 30 Nhjfbjm_fu_ aZijhku ..................................................................................................... 32
J?>:DLBJH<:GB? J?AMEVL:LH< A:IJHK: .......................................................................... 32 J:;HL: K K?JMJU ......................................................................................................... 38 LJB==?JU.................................................................................................................................. 42 A:>:GBY >EY K:FHKLHYL?EVGHC J:;HLU.................................................................. 43
,17(5%$6(
KEH<:JV L?JFBGH<................................................................................................................... 44 IJBEH@?GB?................................................................................................................................. 45 I KLJMDLMJ: NJ:=F?GL: ;> A:D:AU» (NHJF:L PARADOX)............................................ 45 I LBIU IHE?C PARADOX ........................................................................................................... 46 I LBIU IHE?C INTERBASE ........................................................................................................ 46 EBL?J:LMJ: ................................................................................................................................... 47
©
KH>?J@:GB? ......................................................... HRB;D: A:DE:>D: G? HIJ?>?E?G: KhklZ\bl_evJm^Ze_\