SlideShare a Scribd company logo
មេម ៀនទី៨៖
Thin Client-Server System
Development
1
១. SQL Server៖
SQL Server គឺជា DBMS Server ដែលត្រូវបាន
បង្កើរង ើ្ងោយត្រុមហ៊ុន Microsoft សំរាប់អភិវឌ្ឍនូវ
Client-Server Systems។ ត្គប់ែំង ើ រត្បរិបរតិរន៊ុ្
SQL Server ត្រូវបានអន៊ុវរតរន៊ុ្ទំរ្់ Request​ និ្
Respond មានន័យថា Client ងសនើងៅកាន់ Server តាម
រយៈ Request របស់វា ចំដនរឯ Server ង្លើយរបមរ
កាន់ Client វិញតាមរយៈ Respond របស់វាដែរ។
2
១.១. ការបង្កើរ Database៖
ងៅរន៊ុ្ SQL Server ង ោះ Database មានរដនល្សំរាប់
ផ្ទ៊ុរទិននន័យ រដនល្សំរាប់សរងសរត្បូត្កាមនិ្រដនល្សំរាប់ផ្ទ៊ុរនូវ
ព័រ៌មានននែំង ើ រត្បរិបរតិងផ្េ្ៗ។ ងហរ៊ុងនោះ Database របស់
SQL Server មានទំ រ់ទំន្ជាមួយនឹ្ Files ចំនួនពីរែូចខា្
ងត្កាម៖
▪ Data File: មាន ទីផ្ទ៊ុរនូវ Database Objects មួយចំនួនែូច
ជា Tables, Views, Programmability (Stored Procedures,
Functions,…) និ្ Security ជាងែើម។ ជាទូងៅ Data File មាន
លរខ ៈសំគាល់គឺ .mdf។
3
▪ Log File: មាន ទីផ្ទ៊ុរនូវព័រ៌មាននន Transactions
ទំ្ឡាយដែលត្រូវអន៊ុវរតទរ់ទ្ជាមួយនឹ្ Data File ែូច
ជាព័រ៌មានននការបញ្
ចូ លទិននន័យ ការទញយរទិននន័យ ការ
ដរដត្បនិ្ការល៊ុប Record ងោយមានកាលបរិងចេទ
ចាស់លាស់ងាយស្សួលងោយ DBA ង្វើការ Backup និ្
Restore ងៅតាមព័រ៌មានទំ្ង ោះ។ ជាទូងៅ Log File មាន
លរខ ៈសំគាល់ .ldf។
ងហរ៊ុងនោះងៅងពលដែលងយើ្បង្កើរ Database មួយរន៊ុ្
SQL Server ង ោះងយើ្ត្រូវរំ រ់លរខ ៈរបស់ Files ទំ្ពីរ
ងនោះែូចជារំ រ់ទំហំចាប់ងផ្តើម (Initial Size) អត្តារំង ើ នជា
សវ័យត្បវរតិ (Autogrowth) ងហើយនិ្ទីតាំ្របស់​
​ File ដែលត្រូវ
សថិរងៅរន៊ុ្ Hard disk ងោយត្រូវរំ រ់រន៊ុ្ដផ្នរ Path។
4
១.២. ការបង្កើរតារា្ (Table)៖
ងៅរន៊ុ្ SQL Server មានត្បងភទទិននន័យមួយចំនួនសំ
រាប់ Field ឬ Column របស់ Table ែូចជា៖
❖ ចំង ោះចំនួនងលខមានែូចជា៖
▪ tinyint (ែូច​Byte ងៅរន៊ុ្​MS-Access)
▪ smallint (ែូច​Integer ងៅរន៊ុ្​MS-Access)
▪ int (ែូច​Long ងៅរន៊ុ្​MS-Access)
▪ bigint
▪ float (ែូច​Single ងៅរន៊ុ្​MS-Access)
▪ real
▪ decimal
▪ money (ែូច​Currency ងៅរន៊ុ្​MS-Access រ៏ប៊ុដនតវាមិន
មាន​Currency Symbol ង ើយ)
5
❖ចំង ោះអរេរមានែូចជា៖
▪ char(n) សំរាប់​ASCII Code ជា​Fixed Length
▪ nchar(n) សំរាប់​Unicode ជា​Fixed Length
▪ varchar(n) សំរាប់​
​ASCII Code ជា​Variable Length
▪ nvarchar(n) សំរាប់​Unicode ជា Variable Length
ដែល​n គឺជាចំនួនននរួអរេរចាប់ពី១ង ើ្ងៅ។
❖ ចំង ោះ Binary Data មានែូចជា៖
▪ binary(50)
▪ varbinary(50)
▪ varbinary(MAX)
▪ image សំរាប់ផ្ទ៊ុររូបភាព
6
❖ចំង ោះកាលបរិងចេទនិ្ងពលងវលាមានែូចជា៖
▪ smalldatetime សំរាប់​Year<= 2099 ងហើយងពលងវលាចង ល ោះ
00:00:00 ែល់ 23:59:59។
▪ datetime សំរាប់​Year<=9999 ងហើយងពលងវលាចង ល ោះ
00:00:00 ែល់ 23:59:59។
▪ time(7) សំរាប់ផ្ទ៊ុរងពលងវលាចង ល ោះ 00:00:00 ែល់ 23:59:59។
▪ date សំរាប់ផ្ទ៊ុរកាលបរិងចេទដែល Year<=9999
❖ ចំង ោះ​Boolean Data គឺ​bit សំរាប់ផ្ទ៊ុររំនល​True (1) ឬ​False
(0)។
❖ ចំង ោះអរថបទដវ្មានែូចជា៖
▪ Text (សំរាប់​
​ASCII code)
▪ nText (សំរាប់​Unicode)
7
ឧទហរ ៍ ៖ ងយើ្ោចបង្កើរ Tables មួយចំនួនតាមរយៈ
SQL Statement ែូចខា្ងត្កាម៖
Create Table tbStudent(StuID int Primary Key,
StuName varchar(30), Sex char(1), BirthDate Date,
Phone varchar(20), ParentPhone varchar(20),
ContactAddress varchar(200))
Go
Create Table tbSubject(SubjectID tinyint Primary Key,
SubjectName varchar(100))
Go
8
Create Table tbExam(StuID int, SubjectID tinyint,
FirstExamScore tinyint, SecondExamScore tinyint,
Constraint FKStuID Foreign Key(StuID) References
tbStudent(StuID) On Delete Cascade On Update
Cascade, Constraint FKSubjectID Foreign
Key(SubjectID) References tbSubject(SubjectID)
On Delete Cascade On Update Cascade, Constraint
PKStuIDSubjectID Primary Key(StuID,SubjectID))
9
១.៣. Transaction-SQL (T-SQL)៖
T-SQL គឺជា Programming language របស់ SQL Server សំរាប់
ែំង ើ រត្បរិបរតិ Business Logic របស់ System ងៅឯ Server Computer។
ងោយ SQL Statement គា
ា ន Variable និ្គា
ា ន Control Structure ងហើយមិន
ដមនជា Procedural Language ងទើបងគបង្កើរ T-SQL ងនោះង ើ្ងោយ៖
T-SQL = SQL + Procedure + Variables + Control Structures
T-SQL គា
ា នរដនល្បញ្
ចូ លរំនលនិ្រដនល្បងា
ា ញលទធផ្លសំរាប់
End User ង ើយ រ៏ប៊ុដនត DBA (Database Administrator) ោចង្វើងរសតសារ
លប្រន៊ុ្ការបញ្
ចូ លរំនលនិ្បងា
ា ញលទធផ្លបាន។
10
១.៣.១. ការត្បកាសអងេរ៖
ងែើមបីត្បកាសអងេរងៅរន៊ុ្​T-SQL ងយើ្ោចងត្បើតាម​
Syntax ែូចខា្ងត្កាម:
Syntax:
Declare @varName Datatype[(size)]
Declare @varName1 Datatype[(size)], @varName2
Datatype[(size)]
ឧទហរ ៍ ៖
Declare @x smallint, @y float
Declare @st varchar(50)
Declare @d date
11
១.៣.២. ការងផ្ទររំនលងៅងោយអងេរ៖
គឺជាការរំនរ់រំនលនិ្ងផ្ទររំនលងៅងោយអងេរមួយ
ដែលរំនលទំ្ង ោះោចជារំនល្មាតា​
ឬជារំនលរបស់ Field
រន៊ុ្ Table ណា មួយ។
❖ ការរំនរ់រំនលឬងផ្ទររំនល្មាតាងៅងោយអងេរ:
Syntax: Select ​ @VarName = Expression
ឬ Set @VarName = Expression
ឧទហរ ៍ ៖
Declare ​ @x smallint, @y float, @d date
Select @x = 5 ឬ​​​​Set @x = 5
Select @y = @y+10.5 ឬ​
​
​
​​​​Set @y = @y+10.5
Select @d = ‘10/Jan/2011’​​ឬ​
​
​
​​​​Set @d = ‘10/Jan/2011’
12
❖ ការរំនរ់រំនលឬងផ្ទររំនលរបស់​Field ងៅងោយអងេរ:
Syntax:
Set @VarName = (Select FieldName From...)
ឬ​ Select @VarName =​ FieldName From....
ចំណាំ៖ ងយើ្ោចទញយររំនលងចញពី Fields ទំ្អស់របស់
Table មរផ្ទ៊ុររន៊ុ្អងេរតាម Syntax ែូចខា្ងត្កាម៖
Syntax:
Select @var1 = FieldName1, …, @varN = FieldNameN
From TableName/JoinTableExpression
Where GeneralCondition
Group By FieldName Having GroupCondition
Order By FieldName ASC/DESC;
13
ឧទហរ ៍ ៖ ងគមាន Table មួយគឺ៖
tbStaff (StaffID, StaffName, Gender, BirthDate, Phone,
smallint varchar(30) char(1) date varchar(20)
StaffAddress, StaffPosition, Salary, HiredDate)
varchar(200) varchar(50) money date
ងយើ្ោចសរងសរ T-SQL ងែើមបីទញរំនលងចញពី Fields មួយ
ចំនួនមរផ្ទ៊ុររន៊ុ្អងេរែូចខា្ងត្កាម៖
Declare @sn varchar(35), @g char(1)
Declare @pos varchar(50), @sal Money
Select @sn = StaffName, @g = Gender, @pos =
StaffPosition, @sal = Salary
From tbStaff Where StaffID = 2
Print 'StaffName = ' + @sn + ', Gender = ' + @g +
​​​​​ ', Position = ' + @pos + ', Salary = ' +
convert(varchar(10), @sal)
14
១.៣.៣. Control Structure៖
រ. If Statement៖
Syntax1:
If Condition
Statement
Syntax2:
If Condition
Begin
Statement1
.
.
StatementN
End
15
Syntax 3:
If Condition
Statement
Else
Statement
Syntax 4:
If Condition
Begin
Statement(s)
End
Else
Begin
Statement(s)
End
16
Syntax 5:
If Condition1
Begin
Statement(s)
End
Else If Condition2
Begin
Statement(s)
End
…
Else
Begin
Statement(s)
End
17
ខ. Case statement៖
Syntax1:
Set @VarName = Case Expression
When Value1 Then returnvalue1
When Value2 Then returnvalue2
…
When ValueN Then returnValueN
Else
returnvalue
End
18
ឧទហរ ៍ ៖
Declare @m tinyint, @y smallint, @days tinyint
Set @m = MONTH(GETDATE())
Set @y = YEAR(GETDATE())
If (@m=2)
Begin
If (@y%4=0 And @y%100<>0) Or @y%400=0
Set @days = 29
Else
Set @days = 28
End
19
Else
Begin
Set @days = Case @m
When 4 Then 30
When 6 Then 30
When 9 Then 30
When 11 Then 30
Else
31
End
End
Print 'This month has ' + Convert(varchar(3), @days) + ' days'
20
Syntax2:
Case When Condition1 Then returnvalue1
When Condition2 Then returnvalue2
…
When ConditionN Then returnvalueN
Else
returnvalue
End
ឧទហរ ៍ ៖​តាមរយៈ​Table ង្
ា ោះ​tbStudent, tbSubject និ្​
tbExam ងយើ្ោចសរងសរ​T-SQL រន៊ុ្ការរំ រ់និងទទសសំរាប់
ពិនទ៊ុរបស់និសេិរមា
ន រ់ៗែូចខា្ងត្កាម៖
21
Select StuName, Sex, SubjectName, FirstExamScore,
CaseWhen FirstExamScore<50Then 'F'
When FirstExamScore<60Then 'E'
When FirstExamScore <70Then 'D'
When FirstExamScore <80Then 'C'
When FirstExamScore <90Then 'B'
Else
'A'
End As FirstGrade
From tbSubject B Inner Join(tbExam E Inner Join tbStudent S On
E.StuID=S.StuID) On B.SubjectID=E.SubjectID
22
គ. While៖ បល៊ុរនន Statement(s) ត្រូវែំង ើ រការសារច៊ុោះសារ
ង ើ្រន៊ុ្ខ ៈដែល Condition ពិរ។
Syntax
While (Condition)
Begin
Statement(s)
End
23
១.៤. Views ៖ គឺជា Database Object មួយរបស់ SQL Server ដែលត្រូវបាន
ងត្បើសំរាប់ទញយរទិននន័យងចញពី Table មួយឬងត្ចើនងោយងត្បើ Select
Statement រន៊ុ្លរខខ ឌ រំនរ់ជារ់លារ់។ ងែើមបីបង្កើរ View ង ោះងយើ្ត្រូវ
ងត្បើ Syntax ែូចខា្ងត្កាម៖
Syntax:
Create View ViewName As Select Statement
ចំណាំ៖ ងែើមបីសរងសរ Code សំរាប់បង្កើរ View ខា្ងលើងនោះ ងយើ្ត្រូវ Click
ងលើ New Query ននDatabase មាន Tables ទំ្ឡាយដែលងយើ្ត្រូវទញ
ទិននិន័យ ប ទ ប់មរសរងសរ Code ែូចទំរ្់ Syntax ខា្ងលើ រួចច៊ុចងលើ
Execute ងពលង ោះវានឹ្បង្កើរ View មួយដែលមានង្
ា ោះងៅតាមការរំនរ់
រន៊ុ្ Code សថិរងៅរន៊ុ្ដផ្នរ Views Object។
24
ឧទហរ ៍ ៖​តាមរយៈ​Table ង្
ា ោះ​tbStaff
រ. ចូរបង្កើរ​View មួយសំរាប់រំនរ់យរ​ID និ្ង្
ា ោះរបស់​Staff ទំ្​​​​​អ
ស់។
Create View vAllStaff As Select StaffID, StaffName From tbStaff
ងយើ្ោចងៅ View ងនោះមរែំង ើ រការតាមរយៈ Select Statement គឺ
៖ Select * From dbo.vAllStaff Order By StaffName;
ខ. ចូរបង្កើរ View ងែើមបីទញយរ​StaffPosition រ៊ុំងោយសទួនគា
ន ។
Create View vAllPosition As Select Distinct StaffPosition
From tbStaff
ងយើ្ោចងៅ View ងនោះមរែំង ើ រការតាមរយៈ Select Statement គឺ
៖
Select * From dbo.vAllPosition Order By StaffPosition
25
១.៥. Stored Procedure​ ៖
គឺជា Program ដែលងយើ្ត្រូវបង្កើរង ើ្ ងែើមបីងោោះ
ស្សាយបញ្ហ
ា រន៊ុ្ DBMS​ Server ែូចជា SQL Server ជា
ងែើម សំរាប់អភិវឌ្ឍ Thin Client-Server Systems។ ងយើ្
ោចបង្កើរ Stored Procedure សំរាប់ការងារមួយចំនួនែូច
ខា្ងត្កាម៖
+ Stored Procedure សំរាប់ទញយរទិននន័យងចញពី
Table មួយឬងត្ចើន៖
Syntax:
Create Procedure ProcedureName ParameterList
As Select Statement
26
ដែល​Parameter មានពីរត្បងភទ៖
- Input Parameter: គឺជា Parameter សំរាប់ទទួលរំនលពី Argument ងៅ
ងពល Call Stored Procedure ងនោះ។ ងែើមបីរំនរ់ Input Parameter ងយើ្ត្រូវ
សរងសររន៊ុ្ត្ទ្់ត្ទយែូចខា្ងត្កាម៖
@ParameterName Datatype Input
ឬ​@ParameterName Datatype
- Output Parameter: គឺជា Parameter សំរាប់បញ្
ជូ នរំនលងៅងោយ Output
Argument (ជាអងេរ) ងៅងពល Call Stored Procedure ងនោះ។ ងែើមបីរំ រ់
Output Parameter ងយើ្ត្រូវសរងសររន៊ុ្ត្ទ្់ត្ទយែូចខា្ងត្កាម៖
@ParameterName Datatype Output
27
ងែើមបី​Call Stored Procedure មរែំង ើ រការ​ងយើ្ត្រូវងត្បើ​Call Statement
ែូចខា្ងត្កាម៖
Exec ProcedureName ArgumentList
ដែល​Argument រ៏មានពីរត្បងភទដែរែូចជា៖
-Input Argument: គឺជាអងេរ​រឺចំនួនងេរ​
​ឬរ៏រងនោមគ ​ដែលត្រូវបញ្
ចូ ន
រំនលងៅងោយ​Input Parameter។
-Output Argument: គឺជាអងេរ ងោយមានសញ្ហ
ា @ ងៅជាប់ពីម៊ុខ និ្ រយ
Output ពីងត្កាយ សំរាប់ទទួលរំនលពី Output Parameter។
28
ឧទហរ ៍ ៖ តាមរយៈតារា្ tbCustomer ងយើ្ោចបង្កើរ
Stored Procedure សំរាប់ដសវ្ររព័រ៌មានរបស់អរិេិជនងៅតាម
រំនលរបស់ CusID រន៊ុ្ត្ទ្់ត្ទយែូចខា្ងត្កាម៖
Create Procedure spSearchCustomer (@id int) As
Begin
Select * From tbCustomer Where CusID = @id
End
ងយើ្ោចងៅ​Stored Procedure ងនោះមរែំង ើ រការរន៊ុ្
ត្ទ្់ត្ទយែូចខា្ងត្កាម៖
Exec spSearchCustomer 1
29
+ Stored Procedure សំរាប់បន្ថែម Record ថ្មីចូលក្នុង
Table មាថទ្រង់ទ្ាយដូចខាងក្ទ្ោម៖
Syntax:
Create Procedure ProcedureName ParameterList As
Begin
T-SQL
Insert Into TableName (FieldName1,…, FieldNameN)
Values (@Par1,..., @ParN)
End
30
ឧាហរណ
៍ ៖ ក្យីងមាថតារាងមួយគឺ
tbCustomer(CusID, CusName, Phone, ContactAddress)
int varchar(30) varchar(20) varchar(200)
ឧបមាថា CusID ទ្រូវបាថក្ំណរ់ក្ោយក្ក្ីថរំលល១ជាសវ័យទ្បវរតិ
ក្ ោះក្យីងោចបក្ងកីរ Stored Procedure សំរាប់បន្ថែម Record ថ្មីចូល
ក្ៅក្នុងតារាងក្ថោះតាមទ្រង់ទ្ាយដូចខាងក្ទ្ោម៖
Create Procedure spCustomerInserted @cn varchar(30),
@ph varchar(20), @ad varchar(200) As
Begin
Insert Into tbCustomer(CusName, Phone,
ContactAddress) Values(@cn, @ph, @ad)
End
31
+ Stored Procedure សំរាប់ន្ក្រំលលរបស់ Field មួយឬក្ទ្ចីថក្នុង
Table មួយក្ៅតាមរំលលរបស់ Primary Key៖
Syntax:
Create Procedure ProcedureName ParameterList As
Begin
T-SQL
Update TableName Set FieldName2 = @Par2, …,
FieldNameN = @ParN Where PKFieldName = @Par1
End
32
ឧាហរណ
៍ ៖ តាមរយៈតារាង tbCustomer ក្យីងោចបក្ងកីរ
Stored Procedure សំរាប់ន្ក្ន្ទ្បព័រ៌មាថរបស់អរិថ្ិជថក្ៅ
តាមរំលលរបស់ CusID ក្នុងទ្រង់ទ្ាយដូចខាងក្ទ្ោម៖
Create Procedure spCustomerUpdated @id int, @cn
varchar(30), @ph varchar(20), @ad varchar(200) As
Begin
Update tbCustomer Set CusName = @cn,
Phone = @ph, ContactAddress = @ad
Where CusID = @id
End
33
+ Stored Procedure សំរាប់លុប Record ក្ចញពី Table
មួយក្ៅតាមរំលលរបស់ Primary Key៖
Syntax:
Create Procedure ProcedureName @Par1 Datatype As
Begin
T-SQL
Delete From TableName Where PKFieldName = @Par1
End
34
ឧាហរណ
៍ ៖ តាមរយៈតារាង tbCustomer ក្យីងោចបក្ងកីរ
Stored Procedure សំរាប់លុបព័រ៌មាថរបស់អរិថ្ិជថក្ៅតាម
រំលលរបស់ CusID ក្នុងទ្រង់ទ្ាយដូចខាងក្ទ្ោម៖
Create Procedure spCustomerDeleted @id int As
Begin
Delete From tbCustomer Where CusID = @id
End
ក្យីងោចក្ៅ Stored Procedure ក្ថោះមក្ដំក្ណ
ី រោរ សំរាប់
លុបព័រ៌មាថរបស់អរិថ្ិជថន្ដលមាថ CusID = 1 ក្យីងទ្រូវអថុ
វរតតាមទ្រង់ទ្ាយដូចខាងក្ទ្ោម៖
Exec spCustomerDeleted 1
35
១.៦. Function ៖
ក្. Function ន្ដល Return រំលលជា Scalar៖
គឺជា Function ន្ដល Return រំលលជាចំថួថក្លខ អក្សរឬរំក្រៀប
លថរួអក្សរជាក្ដីម។ ក្ដីមបីបក្ងកីរ Function ទ្បក្េរក្ថោះក្យីងទ្រូវអថុវរត
តាមទ្រង់ទ្ាយដូចខាងក្ទ្ោម៖
Create Function FunctionName (ParameterList) Returns
Datatype As
Begin
T-SQL
Return Expression
End
ន្ដល Expression ោចជាចំថួថក្ថ្រ អក្ថ្រឬក្ក្ថោមគណ ។
36
ឧាហរណ
៍ ៖ ក្យីងមាថតារាងមួយគឺ
tbCustomer(CusID, CusName, Phone, ContactAddress)
int varchar(30) varchar(20) varchar(200)
ក្យីងោចបក្ងកីរ Function សំរាប់ាញយក្ក្្
ម ោះរបស់អរិថ្ិជថក្ៅតាម
រំលលរបស់ CusID ក្នុងទ្រង់ទ្ាយដូចខាងក្ទ្ោម៖
Create Function getCusName (@id int) Returns
varchar(30) As
Begin
Declare @cn varchar(30)
Select @cn = CusName From tbCustomer
Where CusID = @id
Return @cn
End
37
ខ. Function ន្ដល Return ជា Table៖
ក្ដីមបីបក្ងកីរ Function ន្ដល Return ជា Table ក្ ោះក្យីង
ទ្រូវអថុវរតតាមទ្រង់ទ្ាយដូចខាងក្ទ្ោម៖
Create Function FunctionName (ParameterList)
Returns Table As
Begin
T-SQL
Return (Select Statement)
End
ចំណំ៖ ទ្បសិថក្បីក្ៅក្នុងដងខលួថរបស់ Function មាថ Return
Statement ន្រមួយគរ់ ក្ ោះក្យីងមិថទ្រូវដាក្់ Begin End ក្ ីយ។ 38
ឧាហរណ
៍ ៖ ក្យីងមាថតារាងមួយគឺ
tbCustomer(CusID, CusName, Phone, ContactAddress)
int varchar(30) varchar(20) varchar(200)
ក្យីងោចបក្ងកីរ Function សំរាប់ាញយក្ព័រ៌មាថរបស់អរិថ្ិជថក្ៅ
តាមរំលលរបស់ CusID ក្នុងទ្រង់ទ្ាយដូចខាងក្ទ្ោម៖
Create Function searchCustomer (@id int) Returns Table
As Return (Select * From tbCustomer Where CusID = @id)
ក្ដីមបីក្ៅ Function ខាងក្លីក្ថោះមក្ដំក្ណ
ី រោរ សំរាប់ន្សវងរក្ព័រ៌មាថ
របស់អរិថ្ិជថន្ដលមាថ CusID = 1 ក្ ោះក្យីងទ្រូវអថុវរតតាមទ្រង់ទ្ាយ
ដូចខាងក្ទ្ោម៖
Select * From dbo.searchCustomer(1)
39
១.៧. Cursor ៖
គឺជាទ្បក្េររិថនថ័យមួយរបស់ T-SQL ន្ដលមាថលក្ខណៈ
ទ្សក្ដៀងក្ៅថឹង RecordSet ក្នុង VBA ឬ VB6.0។ អក្ថ្រន្ដលមាថ
ទ្បក្េររិថនថ័យជា Cursor មាថ រីចងអុលក្ៅោថ់ Record ន្ដល
ាញក្ចញពី Table មួយរ ឺក្ទ្ចីថតាមរយៈ Select Statement។
ក្ដីមបីទ្បោសអក្ថ្រមាថទ្បក្េររិថនថ័យជា Cursor សំរាប់
ចងអុលក្ៅោថ់ Record ក្ ោះក្យីងទ្រូវអថុវរតតាម Syntax ដូចខាង
ក្ទ្ោម៖
Syntax:
Declare CursorVarName Cursor
Scroll ScrollType For Select Statement
40
ន្ដល៖
❖ CursorVarName: គឺជាក្្
ម ោះរបស់អក្ថ្រន្ដលក្យីងទ្រូវ
ក្ំថរ់ក្ោយមាថទ្បក្េររិថនថ័យជា Cursor សំរាប់ចងអុលក្ៅ
ោថ់ Record ាញក្ចញពី Table មួយរ ឺក្ទ្ចីថ។
❖ Scroll: គឺជា keyword សំរាប់ក្ំថរ់ឱ្យ CursorVarName
ផ្ល
ល ស់រីពី record មួយក្ៅោថ់ record មួយក្សសងក្រៀរក្ៅ
តាម Scrolltype ថីមួយៗដូចខាងក្ទ្ោម៖
▪ Forward_Only: សំរាប់ក្ំថរ់ក្ោយ CursorVarName
ោចផ្ល
ល ស់រីក្ៅោថ់ record ក្ទ្ោយប ា ប់បុក្ណ
ណ ោះក្ដាយ
មិថោចបក្ក្ទ្ោយបាថក្ ីយ។
41
▪ Static: សំរាប់ក្ំថរ់ក្ោយ CursorVarName ផ្ល
ល ស់រីក្ៅ
មុខថិងក្ៅក្ទ្ោយបាថក្៏បុន្ថតវាសាុក្រិថនថ័យសងថិង Address
របស់រិថនថ័យសង។
▪ Dynamic: មាថលក្ខណៈទ្សក្ដៀង Static ន្ដរទ្ាថ់ន្រ
CursorVarName សាុក្ន្រ Address សំរាប់ចងអុលក្ៅោថ់
record ន្របុក្ណ
ណ ោះ។
ប ា ប់ពីក្យីងបាថទ្បោសថិងក្ំថរ់ CursorVarName
រូចក្ហីយក្ ោះក្យីងទ្រូវក្បីក្CursorVarName ក្ថោះ ក្ដាយក្ទ្បី
statement មូយគឺ Open CursorVarName។
42
ក្ដីមបីាញរលមលរបស់ Field ាំងឡាយទ្រង់ Record
ន្ដល CursorVarName ក្ំពុងចងអុលក្ៅសាុក្ក្នុងអក្ថ្រមួយ
ចំថួថន្ដលក្យីងបាថទ្បោសរួចក្ហីយ ក្ ោះក្យីងទ្រូវអថុវរត
តាម Statement ដូចខាងក្ទ្ោម៖
▪ Fetch First From CursorVarName Into
@Var1,…,@VarN
▪ Fetch Next From CursorVarName Into
@Var1,…,@VarN
▪ Fetch Prior From CursorVarName Into
@Var1,…,@VarN
▪ Fetch Last From CursorVarName Into
@Var1,…,@VarN
43
ក្ដីមបីពិថិរយក្មីលោរាញយក្រលមលក្ចញពី CursorVarName បាថ
រ ឺមិថបាថ ក្ ោះក្យីងទ្រូវក្មីលរលមលរបស់ System Variable មួយគឺ
@@Fetch_Status ក្បីវាក្សមី 0 ក្ ោះមាថថ័យថាវាោចាញរលមលក្ចញពី
CursorVarName បាថ ក្៏បុន្ថតក្បី System Variable ក្ថោះមាថរលមលខុសពី
0 ក្ ោះមាថថ័យថាវាមិថោចាញរលមលបាថរ ឺក្នុង Cursor ា
ម ថ record។
ោរក្ំថរ់លក្ខខណ
ឌ ក្នុងោរទ្រួរពិថិរយក្មីលក្ៅក្លីរលមលរបស់
@@Fetch_Status ទ្រូវក្ំថរ់ប ា ប់ពីក្យីងបាថក្ទ្បី Fetch Statement
រួចក្ហីយ។
ក្ដីមបីបិរ Cursor រួចលុប Record ក្ចញពី RAM ក្ ោះក្យីងទ្រូវក្ទ្បី
Statement ចំថួថពីរតាមលំដាប់ដូចជា៖
Close CursorVarName
Deallocate CursorVarName
44
ឧាហរណ
៍ ៖ តាមរយៈ Table ក្្
ម ោះ tbCustomer ក្យីងោចក្ំណរ់ Cursor ក្ដីមបីាញ
យក្រំលលរបស់ CusID, CusName, Phone ថិង ContactAddress មក្ដាក្់ក្នុងអក្ថ្រ
មួយចំថួថសំរាប់បង្ហ
ា ញ។
Declare @cid int, @cn varchar(30), @ph varchar(20),
@ad varchar(200)
Declare csCustomer Cursor Scroll Dynamic
For Select * From tbCustomer
Open csCustomer
Fetch First From csCustomer Into @cid, @cn, @ph, @ad
While(@@Fetch_Status=0)
Begin
Print 'CusID = ' + Convert(varchar(6), @cid) + ' CusName = ' +
@cn + ', Phone = ' + @ph + ', Address = ' + @ad
Fetch Next From csCustomer Into @cid, @cn, @ph, @ad
End
Close csCustomer
Deallocate csCustomer
45
២. Crystal Report ៖
គឺជា Application program មួយ ន្ដលក្យីងោច
បក្ងកីររបាយោរណ
៍ ក្សសងៗបាថ។ Crystal Report មាថ
Components មួយចំថួថសំរាប់ Design Report ដូចជា៖
+ Database Expert: មាថ រីភ្ជ
ា ប់រំ ក្់រំថងជាមួយថឹង
Database ក្ដីមបីាញ Database Objects មួយចំថួថដូច
ជា Tables, Views, Stored Procedure ឬ Function មក្
ក្្វីជាទ្បេពរិថនថ័យរបស់ Report។
46
+ Field Explorer: មាថ រីសាុក្ថូវ Fields ាំងឡាយរបស់
Report ន្ដលាញក្ចញពី Tables ឬក្៏ Fields ន្ដលបក្ងកីរ
ក្ ីងក្ដាយក្ក្ថោមរូបមថតក្ហីយថិង Fields ពិក្សសមួយចំថួថ
ន្ដលមាថទ្ាប់ក្ៅក្នុង Crystal Report។ ក្ៅក្នុង Field
Explorer រួមមាថ៖
 Database Fields: មាថ រីសាុក្ថូវ Fields ាំងឡាយន្ដល
ាញក្ចញពី Table មួយឬក្ទ្ចីថរបស់ Database ណមួយ
ន្ដលក្យីងបាថភ្ជ
ា ប់រំ ក្់រំថងឬក្៏ DataSet ណមួយលថ
Programming Interface មួយចំថួថដូចជា VB.Net, C#
ថិង Java ជាក្ដីម។
47
 Formula Fields: មាថ រីបក្ងកីរ Field ក្ដាយក្ទ្បីក្ក្ថោម
រូបមថត្មមតា។
 Parameter Fields: មាថ រីបក្ងកីរ Parameter Field(s)
សំរាប់ររួលរំលលក្ចញពី User Interface (Text Box ថិង
Combo Box) មក្បង្ហ
ា ញក្ៅក្លី Report ឬសំរាប់ក្្វីជា
លក្ខខណ
ឌ ក្ដីមបីាញយក្រិថនថ័យក្ៅតាមលក្ខខណ
ឌ ក្ ោះ។
 Running Total Fields: មាថ រីបក្ងកីរ Fields ន្ដលក្ក្ីរ
ក្ ីងក្ដាយក្ក្ថោមរូបមថតក្ទ្បីទ្បាស់ Aggregate Function
(SUM, COUNT, AVG, MIN, MAX)។
48
 Group Name Fields: មាថ រីសាុក្ Field ណមួយ ន្ដល
ទ្រូវបាថក្ំណរ់ក្្វីជា Group Header/Footer។
 Special Fields: មាថ រីសាុក្ Fields ពិក្សសមួយចំថួថ
ន្ដលមាថទ្ាប់របស់ Crystal Report ដូចជា Page
Number, Record Number,…។
49

More Related Content

Featured

Everything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTEverything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPT
Expeed Software
 
Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsProduct Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage Engineerings
Pixeldarts
 
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental Health
ThinkNow
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
marketingartwork
 
Skeleton Culture Code
Skeleton Culture CodeSkeleton Culture Code
Skeleton Culture Code
Skeleton Technologies
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024
Neil Kimberley
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
contently
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
Albert Qian
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
Kurio // The Social Media Age(ncy)
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
Search Engine Journal
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
SpeakerHub
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next
Tessa Mero
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Lily Ray
 
How to have difficult conversations
How to have difficult conversations How to have difficult conversations
How to have difficult conversations
Rajiv Jayarajah, MAppComm, ACC
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data Science
Christy Abraham Joy
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best Practices
Vit Horky
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project management
MindGenius
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
RachelPearson36
 
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Applitools
 

Featured (20)

Everything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTEverything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPT
 
Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsProduct Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage Engineerings
 
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental Health
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
 
Skeleton Culture Code
Skeleton Culture CodeSkeleton Culture Code
Skeleton Culture Code
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
 
How to have difficult conversations
How to have difficult conversations How to have difficult conversations
How to have difficult conversations
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data Science
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best Practices
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project management
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
 
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
 

Chapter8 thin client server system development

  • 2. ១. SQL Server៖ SQL Server គឺជា DBMS Server ដែលត្រូវបាន បង្កើរង ើ្ងោយត្រុមហ៊ុន Microsoft សំរាប់អភិវឌ្ឍនូវ Client-Server Systems។ ត្គប់ែំង ើ រត្បរិបរតិរន៊ុ្ SQL Server ត្រូវបានអន៊ុវរតរន៊ុ្ទំរ្់ Request​ និ្ Respond មានន័យថា Client ងសនើងៅកាន់ Server តាម រយៈ Request របស់វា ចំដនរឯ Server ង្លើយរបមរ កាន់ Client វិញតាមរយៈ Respond របស់វាដែរ។ 2
  • 3. ១.១. ការបង្កើរ Database៖ ងៅរន៊ុ្ SQL Server ង ោះ Database មានរដនល្សំរាប់ ផ្ទ៊ុរទិននន័យ រដនល្សំរាប់សរងសរត្បូត្កាមនិ្រដនល្សំរាប់ផ្ទ៊ុរនូវ ព័រ៌មានននែំង ើ រត្បរិបរតិងផ្េ្ៗ។ ងហរ៊ុងនោះ Database របស់ SQL Server មានទំ រ់ទំន្ជាមួយនឹ្ Files ចំនួនពីរែូចខា្ ងត្កាម៖ ▪ Data File: មាន ទីផ្ទ៊ុរនូវ Database Objects មួយចំនួនែូច ជា Tables, Views, Programmability (Stored Procedures, Functions,…) និ្ Security ជាងែើម។ ជាទូងៅ Data File មាន លរខ ៈសំគាល់គឺ .mdf។ 3
  • 4. ▪ Log File: មាន ទីផ្ទ៊ុរនូវព័រ៌មាននន Transactions ទំ្ឡាយដែលត្រូវអន៊ុវរតទរ់ទ្ជាមួយនឹ្ Data File ែូច ជាព័រ៌មានននការបញ្ ចូ លទិននន័យ ការទញយរទិននន័យ ការ ដរដត្បនិ្ការល៊ុប Record ងោយមានកាលបរិងចេទ ចាស់លាស់ងាយស្សួលងោយ DBA ង្វើការ Backup និ្ Restore ងៅតាមព័រ៌មានទំ្ង ោះ។ ជាទូងៅ Log File មាន លរខ ៈសំគាល់ .ldf។ ងហរ៊ុងនោះងៅងពលដែលងយើ្បង្កើរ Database មួយរន៊ុ្ SQL Server ង ោះងយើ្ត្រូវរំ រ់លរខ ៈរបស់ Files ទំ្ពីរ ងនោះែូចជារំ រ់ទំហំចាប់ងផ្តើម (Initial Size) អត្តារំង ើ នជា សវ័យត្បវរតិ (Autogrowth) ងហើយនិ្ទីតាំ្របស់​ ​ File ដែលត្រូវ សថិរងៅរន៊ុ្ Hard disk ងោយត្រូវរំ រ់រន៊ុ្ដផ្នរ Path។ 4
  • 5. ១.២. ការបង្កើរតារា្ (Table)៖ ងៅរន៊ុ្ SQL Server មានត្បងភទទិននន័យមួយចំនួនសំ រាប់ Field ឬ Column របស់ Table ែូចជា៖ ❖ ចំង ោះចំនួនងលខមានែូចជា៖ ▪ tinyint (ែូច​Byte ងៅរន៊ុ្​MS-Access) ▪ smallint (ែូច​Integer ងៅរន៊ុ្​MS-Access) ▪ int (ែូច​Long ងៅរន៊ុ្​MS-Access) ▪ bigint ▪ float (ែូច​Single ងៅរន៊ុ្​MS-Access) ▪ real ▪ decimal ▪ money (ែូច​Currency ងៅរន៊ុ្​MS-Access រ៏ប៊ុដនតវាមិន មាន​Currency Symbol ង ើយ) 5
  • 6. ❖ចំង ោះអរេរមានែូចជា៖ ▪ char(n) សំរាប់​ASCII Code ជា​Fixed Length ▪ nchar(n) សំរាប់​Unicode ជា​Fixed Length ▪ varchar(n) សំរាប់​ ​ASCII Code ជា​Variable Length ▪ nvarchar(n) សំរាប់​Unicode ជា Variable Length ដែល​n គឺជាចំនួនននរួអរេរចាប់ពី១ង ើ្ងៅ។ ❖ ចំង ោះ Binary Data មានែូចជា៖ ▪ binary(50) ▪ varbinary(50) ▪ varbinary(MAX) ▪ image សំរាប់ផ្ទ៊ុររូបភាព 6
  • 7. ❖ចំង ោះកាលបរិងចេទនិ្ងពលងវលាមានែូចជា៖ ▪ smalldatetime សំរាប់​Year<= 2099 ងហើយងពលងវលាចង ល ោះ 00:00:00 ែល់ 23:59:59។ ▪ datetime សំរាប់​Year<=9999 ងហើយងពលងវលាចង ល ោះ 00:00:00 ែល់ 23:59:59។ ▪ time(7) សំរាប់ផ្ទ៊ុរងពលងវលាចង ល ោះ 00:00:00 ែល់ 23:59:59។ ▪ date សំរាប់ផ្ទ៊ុរកាលបរិងចេទដែល Year<=9999 ❖ ចំង ោះ​Boolean Data គឺ​bit សំរាប់ផ្ទ៊ុររំនល​True (1) ឬ​False (0)។ ❖ ចំង ោះអរថបទដវ្មានែូចជា៖ ▪ Text (សំរាប់​ ​ASCII code) ▪ nText (សំរាប់​Unicode) 7
  • 8. ឧទហរ ៍ ៖ ងយើ្ោចបង្កើរ Tables មួយចំនួនតាមរយៈ SQL Statement ែូចខា្ងត្កាម៖ Create Table tbStudent(StuID int Primary Key, StuName varchar(30), Sex char(1), BirthDate Date, Phone varchar(20), ParentPhone varchar(20), ContactAddress varchar(200)) Go Create Table tbSubject(SubjectID tinyint Primary Key, SubjectName varchar(100)) Go 8
  • 9. Create Table tbExam(StuID int, SubjectID tinyint, FirstExamScore tinyint, SecondExamScore tinyint, Constraint FKStuID Foreign Key(StuID) References tbStudent(StuID) On Delete Cascade On Update Cascade, Constraint FKSubjectID Foreign Key(SubjectID) References tbSubject(SubjectID) On Delete Cascade On Update Cascade, Constraint PKStuIDSubjectID Primary Key(StuID,SubjectID)) 9
  • 10. ១.៣. Transaction-SQL (T-SQL)៖ T-SQL គឺជា Programming language របស់ SQL Server សំរាប់ ែំង ើ រត្បរិបរតិ Business Logic របស់ System ងៅឯ Server Computer។ ងោយ SQL Statement គា ា ន Variable និ្គា ា ន Control Structure ងហើយមិន ដមនជា Procedural Language ងទើបងគបង្កើរ T-SQL ងនោះង ើ្ងោយ៖ T-SQL = SQL + Procedure + Variables + Control Structures T-SQL គា ា នរដនល្បញ្ ចូ លរំនលនិ្រដនល្បងា ា ញលទធផ្លសំរាប់ End User ង ើយ រ៏ប៊ុដនត DBA (Database Administrator) ោចង្វើងរសតសារ លប្រន៊ុ្ការបញ្ ចូ លរំនលនិ្បងា ា ញលទធផ្លបាន។ 10
  • 11. ១.៣.១. ការត្បកាសអងេរ៖ ងែើមបីត្បកាសអងេរងៅរន៊ុ្​T-SQL ងយើ្ោចងត្បើតាម​ Syntax ែូចខា្ងត្កាម: Syntax: Declare @varName Datatype[(size)] Declare @varName1 Datatype[(size)], @varName2 Datatype[(size)] ឧទហរ ៍ ៖ Declare @x smallint, @y float Declare @st varchar(50) Declare @d date 11
  • 12. ១.៣.២. ការងផ្ទររំនលងៅងោយអងេរ៖ គឺជាការរំនរ់រំនលនិ្ងផ្ទររំនលងៅងោយអងេរមួយ ដែលរំនលទំ្ង ោះោចជារំនល្មាតា​ ឬជារំនលរបស់ Field រន៊ុ្ Table ណា មួយ។ ❖ ការរំនរ់រំនលឬងផ្ទររំនល្មាតាងៅងោយអងេរ: Syntax: Select ​ @VarName = Expression ឬ Set @VarName = Expression ឧទហរ ៍ ៖ Declare ​ @x smallint, @y float, @d date Select @x = 5 ឬ​​​​Set @x = 5 Select @y = @y+10.5 ឬ​ ​ ​ ​​​​Set @y = @y+10.5 Select @d = ‘10/Jan/2011’​​ឬ​ ​ ​ ​​​​Set @d = ‘10/Jan/2011’ 12
  • 13. ❖ ការរំនរ់រំនលឬងផ្ទររំនលរបស់​Field ងៅងោយអងេរ: Syntax: Set @VarName = (Select FieldName From...) ឬ​ Select @VarName =​ FieldName From.... ចំណាំ៖ ងយើ្ោចទញយររំនលងចញពី Fields ទំ្អស់របស់ Table មរផ្ទ៊ុររន៊ុ្អងេរតាម Syntax ែូចខា្ងត្កាម៖ Syntax: Select @var1 = FieldName1, …, @varN = FieldNameN From TableName/JoinTableExpression Where GeneralCondition Group By FieldName Having GroupCondition Order By FieldName ASC/DESC; 13
  • 14. ឧទហរ ៍ ៖ ងគមាន Table មួយគឺ៖ tbStaff (StaffID, StaffName, Gender, BirthDate, Phone, smallint varchar(30) char(1) date varchar(20) StaffAddress, StaffPosition, Salary, HiredDate) varchar(200) varchar(50) money date ងយើ្ោចសរងសរ T-SQL ងែើមបីទញរំនលងចញពី Fields មួយ ចំនួនមរផ្ទ៊ុររន៊ុ្អងេរែូចខា្ងត្កាម៖ Declare @sn varchar(35), @g char(1) Declare @pos varchar(50), @sal Money Select @sn = StaffName, @g = Gender, @pos = StaffPosition, @sal = Salary From tbStaff Where StaffID = 2 Print 'StaffName = ' + @sn + ', Gender = ' + @g + ​​​​​ ', Position = ' + @pos + ', Salary = ' + convert(varchar(10), @sal) 14
  • 15. ១.៣.៣. Control Structure៖ រ. If Statement៖ Syntax1: If Condition Statement Syntax2: If Condition Begin Statement1 . . StatementN End 15
  • 16. Syntax 3: If Condition Statement Else Statement Syntax 4: If Condition Begin Statement(s) End Else Begin Statement(s) End 16
  • 17. Syntax 5: If Condition1 Begin Statement(s) End Else If Condition2 Begin Statement(s) End … Else Begin Statement(s) End 17
  • 18. ខ. Case statement៖ Syntax1: Set @VarName = Case Expression When Value1 Then returnvalue1 When Value2 Then returnvalue2 … When ValueN Then returnValueN Else returnvalue End 18
  • 19. ឧទហរ ៍ ៖ Declare @m tinyint, @y smallint, @days tinyint Set @m = MONTH(GETDATE()) Set @y = YEAR(GETDATE()) If (@m=2) Begin If (@y%4=0 And @y%100<>0) Or @y%400=0 Set @days = 29 Else Set @days = 28 End 19
  • 20. Else Begin Set @days = Case @m When 4 Then 30 When 6 Then 30 When 9 Then 30 When 11 Then 30 Else 31 End End Print 'This month has ' + Convert(varchar(3), @days) + ' days' 20
  • 21. Syntax2: Case When Condition1 Then returnvalue1 When Condition2 Then returnvalue2 … When ConditionN Then returnvalueN Else returnvalue End ឧទហរ ៍ ៖​តាមរយៈ​Table ង្ ា ោះ​tbStudent, tbSubject និ្​ tbExam ងយើ្ោចសរងសរ​T-SQL រន៊ុ្ការរំ រ់និងទទសសំរាប់ ពិនទ៊ុរបស់និសេិរមា ន រ់ៗែូចខា្ងត្កាម៖ 21
  • 22. Select StuName, Sex, SubjectName, FirstExamScore, CaseWhen FirstExamScore<50Then 'F' When FirstExamScore<60Then 'E' When FirstExamScore <70Then 'D' When FirstExamScore <80Then 'C' When FirstExamScore <90Then 'B' Else 'A' End As FirstGrade From tbSubject B Inner Join(tbExam E Inner Join tbStudent S On E.StuID=S.StuID) On B.SubjectID=E.SubjectID 22
  • 23. គ. While៖ បល៊ុរនន Statement(s) ត្រូវែំង ើ រការសារច៊ុោះសារ ង ើ្រន៊ុ្ខ ៈដែល Condition ពិរ។ Syntax While (Condition) Begin Statement(s) End 23
  • 24. ១.៤. Views ៖ គឺជា Database Object មួយរបស់ SQL Server ដែលត្រូវបាន ងត្បើសំរាប់ទញយរទិននន័យងចញពី Table មួយឬងត្ចើនងោយងត្បើ Select Statement រន៊ុ្លរខខ ឌ រំនរ់ជារ់លារ់។ ងែើមបីបង្កើរ View ង ោះងយើ្ត្រូវ ងត្បើ Syntax ែូចខា្ងត្កាម៖ Syntax: Create View ViewName As Select Statement ចំណាំ៖ ងែើមបីសរងសរ Code សំរាប់បង្កើរ View ខា្ងលើងនោះ ងយើ្ត្រូវ Click ងលើ New Query ននDatabase មាន Tables ទំ្ឡាយដែលងយើ្ត្រូវទញ ទិននិន័យ ប ទ ប់មរសរងសរ Code ែូចទំរ្់ Syntax ខា្ងលើ រួចច៊ុចងលើ Execute ងពលង ោះវានឹ្បង្កើរ View មួយដែលមានង្ ា ោះងៅតាមការរំនរ់ រន៊ុ្ Code សថិរងៅរន៊ុ្ដផ្នរ Views Object។ 24
  • 25. ឧទហរ ៍ ៖​តាមរយៈ​Table ង្ ា ោះ​tbStaff រ. ចូរបង្កើរ​View មួយសំរាប់រំនរ់យរ​ID និ្ង្ ា ោះរបស់​Staff ទំ្​​​​​អ ស់។ Create View vAllStaff As Select StaffID, StaffName From tbStaff ងយើ្ោចងៅ View ងនោះមរែំង ើ រការតាមរយៈ Select Statement គឺ ៖ Select * From dbo.vAllStaff Order By StaffName; ខ. ចូរបង្កើរ View ងែើមបីទញយរ​StaffPosition រ៊ុំងោយសទួនគា ន ។ Create View vAllPosition As Select Distinct StaffPosition From tbStaff ងយើ្ោចងៅ View ងនោះមរែំង ើ រការតាមរយៈ Select Statement គឺ ៖ Select * From dbo.vAllPosition Order By StaffPosition 25
  • 26. ១.៥. Stored Procedure​ ៖ គឺជា Program ដែលងយើ្ត្រូវបង្កើរង ើ្ ងែើមបីងោោះ ស្សាយបញ្ហ ា រន៊ុ្ DBMS​ Server ែូចជា SQL Server ជា ងែើម សំរាប់អភិវឌ្ឍ Thin Client-Server Systems។ ងយើ្ ោចបង្កើរ Stored Procedure សំរាប់ការងារមួយចំនួនែូច ខា្ងត្កាម៖ + Stored Procedure សំរាប់ទញយរទិននន័យងចញពី Table មួយឬងត្ចើន៖ Syntax: Create Procedure ProcedureName ParameterList As Select Statement 26
  • 27. ដែល​Parameter មានពីរត្បងភទ៖ - Input Parameter: គឺជា Parameter សំរាប់ទទួលរំនលពី Argument ងៅ ងពល Call Stored Procedure ងនោះ។ ងែើមបីរំនរ់ Input Parameter ងយើ្ត្រូវ សរងសររន៊ុ្ត្ទ្់ត្ទយែូចខា្ងត្កាម៖ @ParameterName Datatype Input ឬ​@ParameterName Datatype - Output Parameter: គឺជា Parameter សំរាប់បញ្ ជូ នរំនលងៅងោយ Output Argument (ជាអងេរ) ងៅងពល Call Stored Procedure ងនោះ។ ងែើមបីរំ រ់ Output Parameter ងយើ្ត្រូវសរងសររន៊ុ្ត្ទ្់ត្ទយែូចខា្ងត្កាម៖ @ParameterName Datatype Output 27
  • 28. ងែើមបី​Call Stored Procedure មរែំង ើ រការ​ងយើ្ត្រូវងត្បើ​Call Statement ែូចខា្ងត្កាម៖ Exec ProcedureName ArgumentList ដែល​Argument រ៏មានពីរត្បងភទដែរែូចជា៖ -Input Argument: គឺជាអងេរ​រឺចំនួនងេរ​ ​ឬរ៏រងនោមគ ​ដែលត្រូវបញ្ ចូ ន រំនលងៅងោយ​Input Parameter។ -Output Argument: គឺជាអងេរ ងោយមានសញ្ហ ា @ ងៅជាប់ពីម៊ុខ និ្ រយ Output ពីងត្កាយ សំរាប់ទទួលរំនលពី Output Parameter។ 28
  • 29. ឧទហរ ៍ ៖ តាមរយៈតារា្ tbCustomer ងយើ្ោចបង្កើរ Stored Procedure សំរាប់ដសវ្ររព័រ៌មានរបស់អរិេិជនងៅតាម រំនលរបស់ CusID រន៊ុ្ត្ទ្់ត្ទយែូចខា្ងត្កាម៖ Create Procedure spSearchCustomer (@id int) As Begin Select * From tbCustomer Where CusID = @id End ងយើ្ោចងៅ​Stored Procedure ងនោះមរែំង ើ រការរន៊ុ្ ត្ទ្់ត្ទយែូចខា្ងត្កាម៖ Exec spSearchCustomer 1 29
  • 30. + Stored Procedure សំរាប់បន្ថែម Record ថ្មីចូលក្នុង Table មាថទ្រង់ទ្ាយដូចខាងក្ទ្ោម៖ Syntax: Create Procedure ProcedureName ParameterList As Begin T-SQL Insert Into TableName (FieldName1,…, FieldNameN) Values (@Par1,..., @ParN) End 30
  • 31. ឧាហរណ ៍ ៖ ក្យីងមាថតារាងមួយគឺ tbCustomer(CusID, CusName, Phone, ContactAddress) int varchar(30) varchar(20) varchar(200) ឧបមាថា CusID ទ្រូវបាថក្ំណរ់ក្ោយក្ក្ីថរំលល១ជាសវ័យទ្បវរតិ ក្ ោះក្យីងោចបក្ងកីរ Stored Procedure សំរាប់បន្ថែម Record ថ្មីចូល ក្ៅក្នុងតារាងក្ថោះតាមទ្រង់ទ្ាយដូចខាងក្ទ្ោម៖ Create Procedure spCustomerInserted @cn varchar(30), @ph varchar(20), @ad varchar(200) As Begin Insert Into tbCustomer(CusName, Phone, ContactAddress) Values(@cn, @ph, @ad) End 31
  • 32. + Stored Procedure សំរាប់ន្ក្រំលលរបស់ Field មួយឬក្ទ្ចីថក្នុង Table មួយក្ៅតាមរំលលរបស់ Primary Key៖ Syntax: Create Procedure ProcedureName ParameterList As Begin T-SQL Update TableName Set FieldName2 = @Par2, …, FieldNameN = @ParN Where PKFieldName = @Par1 End 32
  • 33. ឧាហរណ ៍ ៖ តាមរយៈតារាង tbCustomer ក្យីងោចបក្ងកីរ Stored Procedure សំរាប់ន្ក្ន្ទ្បព័រ៌មាថរបស់អរិថ្ិជថក្ៅ តាមរំលលរបស់ CusID ក្នុងទ្រង់ទ្ាយដូចខាងក្ទ្ោម៖ Create Procedure spCustomerUpdated @id int, @cn varchar(30), @ph varchar(20), @ad varchar(200) As Begin Update tbCustomer Set CusName = @cn, Phone = @ph, ContactAddress = @ad Where CusID = @id End 33
  • 34. + Stored Procedure សំរាប់លុប Record ក្ចញពី Table មួយក្ៅតាមរំលលរបស់ Primary Key៖ Syntax: Create Procedure ProcedureName @Par1 Datatype As Begin T-SQL Delete From TableName Where PKFieldName = @Par1 End 34
  • 35. ឧាហរណ ៍ ៖ តាមរយៈតារាង tbCustomer ក្យីងោចបក្ងកីរ Stored Procedure សំរាប់លុបព័រ៌មាថរបស់អរិថ្ិជថក្ៅតាម រំលលរបស់ CusID ក្នុងទ្រង់ទ្ាយដូចខាងក្ទ្ោម៖ Create Procedure spCustomerDeleted @id int As Begin Delete From tbCustomer Where CusID = @id End ក្យីងោចក្ៅ Stored Procedure ក្ថោះមក្ដំក្ណ ី រោរ សំរាប់ លុបព័រ៌មាថរបស់អរិថ្ិជថន្ដលមាថ CusID = 1 ក្យីងទ្រូវអថុ វរតតាមទ្រង់ទ្ាយដូចខាងក្ទ្ោម៖ Exec spCustomerDeleted 1 35
  • 36. ១.៦. Function ៖ ក្. Function ន្ដល Return រំលលជា Scalar៖ គឺជា Function ន្ដល Return រំលលជាចំថួថក្លខ អក្សរឬរំក្រៀប លថរួអក្សរជាក្ដីម។ ក្ដីមបីបក្ងកីរ Function ទ្បក្េរក្ថោះក្យីងទ្រូវអថុវរត តាមទ្រង់ទ្ាយដូចខាងក្ទ្ោម៖ Create Function FunctionName (ParameterList) Returns Datatype As Begin T-SQL Return Expression End ន្ដល Expression ោចជាចំថួថក្ថ្រ អក្ថ្រឬក្ក្ថោមគណ ។ 36
  • 37. ឧាហរណ ៍ ៖ ក្យីងមាថតារាងមួយគឺ tbCustomer(CusID, CusName, Phone, ContactAddress) int varchar(30) varchar(20) varchar(200) ក្យីងោចបក្ងកីរ Function សំរាប់ាញយក្ក្្ ម ោះរបស់អរិថ្ិជថក្ៅតាម រំលលរបស់ CusID ក្នុងទ្រង់ទ្ាយដូចខាងក្ទ្ោម៖ Create Function getCusName (@id int) Returns varchar(30) As Begin Declare @cn varchar(30) Select @cn = CusName From tbCustomer Where CusID = @id Return @cn End 37
  • 38. ខ. Function ន្ដល Return ជា Table៖ ក្ដីមបីបក្ងកីរ Function ន្ដល Return ជា Table ក្ ោះក្យីង ទ្រូវអថុវរតតាមទ្រង់ទ្ាយដូចខាងក្ទ្ោម៖ Create Function FunctionName (ParameterList) Returns Table As Begin T-SQL Return (Select Statement) End ចំណំ៖ ទ្បសិថក្បីក្ៅក្នុងដងខលួថរបស់ Function មាថ Return Statement ន្រមួយគរ់ ក្ ោះក្យីងមិថទ្រូវដាក្់ Begin End ក្ ីយ។ 38
  • 39. ឧាហរណ ៍ ៖ ក្យីងមាថតារាងមួយគឺ tbCustomer(CusID, CusName, Phone, ContactAddress) int varchar(30) varchar(20) varchar(200) ក្យីងោចបក្ងកីរ Function សំរាប់ាញយក្ព័រ៌មាថរបស់អរិថ្ិជថក្ៅ តាមរំលលរបស់ CusID ក្នុងទ្រង់ទ្ាយដូចខាងក្ទ្ោម៖ Create Function searchCustomer (@id int) Returns Table As Return (Select * From tbCustomer Where CusID = @id) ក្ដីមបីក្ៅ Function ខាងក្លីក្ថោះមក្ដំក្ណ ី រោរ សំរាប់ន្សវងរក្ព័រ៌មាថ របស់អរិថ្ិជថន្ដលមាថ CusID = 1 ក្ ោះក្យីងទ្រូវអថុវរតតាមទ្រង់ទ្ាយ ដូចខាងក្ទ្ោម៖ Select * From dbo.searchCustomer(1) 39
  • 40. ១.៧. Cursor ៖ គឺជាទ្បក្េររិថនថ័យមួយរបស់ T-SQL ន្ដលមាថលក្ខណៈ ទ្សក្ដៀងក្ៅថឹង RecordSet ក្នុង VBA ឬ VB6.0។ អក្ថ្រន្ដលមាថ ទ្បក្េររិថនថ័យជា Cursor មាថ រីចងអុលក្ៅោថ់ Record ន្ដល ាញក្ចញពី Table មួយរ ឺក្ទ្ចីថតាមរយៈ Select Statement។ ក្ដីមបីទ្បោសអក្ថ្រមាថទ្បក្េររិថនថ័យជា Cursor សំរាប់ ចងអុលក្ៅោថ់ Record ក្ ោះក្យីងទ្រូវអថុវរតតាម Syntax ដូចខាង ក្ទ្ោម៖ Syntax: Declare CursorVarName Cursor Scroll ScrollType For Select Statement 40
  • 41. ន្ដល៖ ❖ CursorVarName: គឺជាក្្ ម ោះរបស់អក្ថ្រន្ដលក្យីងទ្រូវ ក្ំថរ់ក្ោយមាថទ្បក្េររិថនថ័យជា Cursor សំរាប់ចងអុលក្ៅ ោថ់ Record ាញក្ចញពី Table មួយរ ឺក្ទ្ចីថ។ ❖ Scroll: គឺជា keyword សំរាប់ក្ំថរ់ឱ្យ CursorVarName ផ្ល ល ស់រីពី record មួយក្ៅោថ់ record មួយក្សសងក្រៀរក្ៅ តាម Scrolltype ថីមួយៗដូចខាងក្ទ្ោម៖ ▪ Forward_Only: សំរាប់ក្ំថរ់ក្ោយ CursorVarName ោចផ្ល ល ស់រីក្ៅោថ់ record ក្ទ្ោយប ា ប់បុក្ណ ណ ោះក្ដាយ មិថោចបក្ក្ទ្ោយបាថក្ ីយ។ 41
  • 42. ▪ Static: សំរាប់ក្ំថរ់ក្ោយ CursorVarName ផ្ល ល ស់រីក្ៅ មុខថិងក្ៅក្ទ្ោយបាថក្៏បុន្ថតវាសាុក្រិថនថ័យសងថិង Address របស់រិថនថ័យសង។ ▪ Dynamic: មាថលក្ខណៈទ្សក្ដៀង Static ន្ដរទ្ាថ់ន្រ CursorVarName សាុក្ន្រ Address សំរាប់ចងអុលក្ៅោថ់ record ន្របុក្ណ ណ ោះ។ ប ា ប់ពីក្យីងបាថទ្បោសថិងក្ំថរ់ CursorVarName រូចក្ហីយក្ ោះក្យីងទ្រូវក្បីក្CursorVarName ក្ថោះ ក្ដាយក្ទ្បី statement មូយគឺ Open CursorVarName។ 42
  • 43. ក្ដីមបីាញរលមលរបស់ Field ាំងឡាយទ្រង់ Record ន្ដល CursorVarName ក្ំពុងចងអុលក្ៅសាុក្ក្នុងអក្ថ្រមួយ ចំថួថន្ដលក្យីងបាថទ្បោសរួចក្ហីយ ក្ ោះក្យីងទ្រូវអថុវរត តាម Statement ដូចខាងក្ទ្ោម៖ ▪ Fetch First From CursorVarName Into @Var1,…,@VarN ▪ Fetch Next From CursorVarName Into @Var1,…,@VarN ▪ Fetch Prior From CursorVarName Into @Var1,…,@VarN ▪ Fetch Last From CursorVarName Into @Var1,…,@VarN 43
  • 44. ក្ដីមបីពិថិរយក្មីលោរាញយក្រលមលក្ចញពី CursorVarName បាថ រ ឺមិថបាថ ក្ ោះក្យីងទ្រូវក្មីលរលមលរបស់ System Variable មួយគឺ @@Fetch_Status ក្បីវាក្សមី 0 ក្ ោះមាថថ័យថាវាោចាញរលមលក្ចញពី CursorVarName បាថ ក្៏បុន្ថតក្បី System Variable ក្ថោះមាថរលមលខុសពី 0 ក្ ោះមាថថ័យថាវាមិថោចាញរលមលបាថរ ឺក្នុង Cursor ា ម ថ record។ ោរក្ំថរ់លក្ខខណ ឌ ក្នុងោរទ្រួរពិថិរយក្មីលក្ៅក្លីរលមលរបស់ @@Fetch_Status ទ្រូវក្ំថរ់ប ា ប់ពីក្យីងបាថក្ទ្បី Fetch Statement រួចក្ហីយ។ ក្ដីមបីបិរ Cursor រួចលុប Record ក្ចញពី RAM ក្ ោះក្យីងទ្រូវក្ទ្បី Statement ចំថួថពីរតាមលំដាប់ដូចជា៖ Close CursorVarName Deallocate CursorVarName 44
  • 45. ឧាហរណ ៍ ៖ តាមរយៈ Table ក្្ ម ោះ tbCustomer ក្យីងោចក្ំណរ់ Cursor ក្ដីមបីាញ យក្រំលលរបស់ CusID, CusName, Phone ថិង ContactAddress មក្ដាក្់ក្នុងអក្ថ្រ មួយចំថួថសំរាប់បង្ហ ា ញ។ Declare @cid int, @cn varchar(30), @ph varchar(20), @ad varchar(200) Declare csCustomer Cursor Scroll Dynamic For Select * From tbCustomer Open csCustomer Fetch First From csCustomer Into @cid, @cn, @ph, @ad While(@@Fetch_Status=0) Begin Print 'CusID = ' + Convert(varchar(6), @cid) + ' CusName = ' + @cn + ', Phone = ' + @ph + ', Address = ' + @ad Fetch Next From csCustomer Into @cid, @cn, @ph, @ad End Close csCustomer Deallocate csCustomer 45
  • 46. ២. Crystal Report ៖ គឺជា Application program មួយ ន្ដលក្យីងោច បក្ងកីររបាយោរណ ៍ ក្សសងៗបាថ។ Crystal Report មាថ Components មួយចំថួថសំរាប់ Design Report ដូចជា៖ + Database Expert: មាថ រីភ្ជ ា ប់រំ ក្់រំថងជាមួយថឹង Database ក្ដីមបីាញ Database Objects មួយចំថួថដូច ជា Tables, Views, Stored Procedure ឬ Function មក្ ក្្វីជាទ្បេពរិថនថ័យរបស់ Report។ 46
  • 47. + Field Explorer: មាថ រីសាុក្ថូវ Fields ាំងឡាយរបស់ Report ន្ដលាញក្ចញពី Tables ឬក្៏ Fields ន្ដលបក្ងកីរ ក្ ីងក្ដាយក្ក្ថោមរូបមថតក្ហីយថិង Fields ពិក្សសមួយចំថួថ ន្ដលមាថទ្ាប់ក្ៅក្នុង Crystal Report។ ក្ៅក្នុង Field Explorer រួមមាថ៖  Database Fields: មាថ រីសាុក្ថូវ Fields ាំងឡាយន្ដល ាញក្ចញពី Table មួយឬក្ទ្ចីថរបស់ Database ណមួយ ន្ដលក្យីងបាថភ្ជ ា ប់រំ ក្់រំថងឬក្៏ DataSet ណមួយលថ Programming Interface មួយចំថួថដូចជា VB.Net, C# ថិង Java ជាក្ដីម។ 47
  • 48.  Formula Fields: មាថ រីបក្ងកីរ Field ក្ដាយក្ទ្បីក្ក្ថោម រូបមថត្មមតា។  Parameter Fields: មាថ រីបក្ងកីរ Parameter Field(s) សំរាប់ររួលរំលលក្ចញពី User Interface (Text Box ថិង Combo Box) មក្បង្ហ ា ញក្ៅក្លី Report ឬសំរាប់ក្្វីជា លក្ខខណ ឌ ក្ដីមបីាញយក្រិថនថ័យក្ៅតាមលក្ខខណ ឌ ក្ ោះ។  Running Total Fields: មាថ រីបក្ងកីរ Fields ន្ដលក្ក្ីរ ក្ ីងក្ដាយក្ក្ថោមរូបមថតក្ទ្បីទ្បាស់ Aggregate Function (SUM, COUNT, AVG, MIN, MAX)។ 48
  • 49.  Group Name Fields: មាថ រីសាុក្ Field ណមួយ ន្ដល ទ្រូវបាថក្ំណរ់ក្្វីជា Group Header/Footer។  Special Fields: មាថ រីសាុក្ Fields ពិក្សសមួយចំថួថ ន្ដលមាថទ្ាប់របស់ Crystal Report ដូចជា Page Number, Record Number,…។ 49