· 6 years ago · Jun 12, 2019, 03:54 PM
1/* Raise waring message. I intend to use in debug in trigger or procedure.
2 * The function will show message 'st' and stop running.
3 *
4 * @author Wutikrai
5 * @since 14/6/2012
6 * PostgreSQL : 02-11-2013
7 */
8
9-- set @TBS_StopWhenError = 1;
10select var('TBS_StopWhenError',1);
11select var('session.userid',1); -- Default user
12
13-- drop procedure if exists sysRaiseWarning;
14create or replace function "dbSys".sysRaiseWarning( st text ) returns void as $$
15declare
16 -- msg text;
17 StopWhenError int;
18
19BEGIN
20 -- msg := st;
21 StopWhenError = "dbSys".varInt('TBS_StopWhenError');
22
23 if (StopWhenError is null ) or (StopWhenError =1 ) then
24 raise exception '%s' ,st;
25 -- signal sqlstate '45000' set message_text=msg;
26 else
27 raise notice '%' , st;
28 end if;
29end $$ LANGUAGE plpgsql;
30
31drop table if exists "dbSys".tbErrLog cascade;
32drop table if exists "dbSys".tbErrMsg cascade ;
33
34drop type if exists "dbSys".ExceptionType ;
35create type "dbSys".ExceptionType as enum ('Default','Error');
36
37drop sequence if exists "dbSys".tbErrMsg_Seq;
38create sequence "dbSys".tbErrMsg_Seq;
39
40CREATE TABLE IF NOT EXISTS "dbSys".tbErrMsg (
41 ID int not null default nextval('"dbSys".tbErrMsg_Seq') primary key,
42 Msg text not null,
43 Description text null,
44 tablename text null,
45 Proc text null,
46 Kind "dbSys".ExceptionType default 'Default' ,
47 UID varchar(20) null,
48 UPD timestamp null
49 ,sqlstate text null
50 ,unique(msg)
51) ;
52
53alter SEQUENCE "dbSys".tbErrMsg_Seq owned by "dbSys".tbErrMsg.ID;
54comment on column "dbSys".tbErrMsg.UID is 'Who create this error id';
55comment on column "dbSys".tbErrMsg.UPD is 'Date create this error id';
56comment on table "dbSys".tbErrMsg is 'Warning message';
57
58drop table if exists "dbSys".tbErrLog;
59drop sequence if exists "dbSys".tbErrLog_Seq;
60create sequence "dbSys".tbErrLog_Seq;
61CREATE TABLE IF NOT EXISTS "dbSys".tbErrLog (
62 ID int not null default nextval('"dbSys".tbErrLog_Seq') primary key,
63 PID int not null,
64 TableName text null,
65 RecordID int null,
66 UID varchar(20) null,
67 UPD timestamp null default now() ,
68 foreign key( PID) references "dbSys".tbErrMsg(ID) on delete cascade on update cascade
69);
70alter sequence "dbSys".tbErrLog_Seq owned by "dbSys".tbErrLog.ID;
71
72--* Error Constant
73select var('ERR_SerialNoDoesNotExist','SerialNo does not exist' );
74
75/*****************************************
76 Sysetem Error Code
77
78
79 insert into "dbSys".tbErrMsg (msg, description,tablename,proc,kind, uid, upd) values
80 ('จำนวนคอลัมป์เกิน','' , '','', 'Error','Wutikrai', '2016-05-16' ) -- 85
81 ;
82******************************************/
83
84-- delete from tbErrMsg;
85--* select * from "dbSys".tbErrMsg order by id desc;
86insert into "dbSys".tbErrMsg (msg, description,tablename,proc,kind, uid, upd) values
87( ' ไม่มีที่อยู่ทะเบียนบ้าน','ฟิลด์ tbContact.HomeAddr ไม่ได้กำหนดค่า หรือ มีค่าเป็น null การกำหนดพื้นที่ที่รับผิดชอบจำเป็นต้องใช้ที่อยู่ตามทะเบียนของ Contact','tbPostArea','PostArea_HaveRegAddr','Default', 'Wutikrai' ,null ), -- 1
88( 'ประเภทเอกสารถูกใช้อยู่','มีประเภทเอกสารที่อยู่ภายใต้เอกสารนี้ tbDocType.id ถูกอ้างโดย pid','tbDocType',null,'Default','Wutikrai' ,null ),
89( 'กลุ่มผู้ติดต่อที่เป็น My Contact มีอยู่แล้ว', 'กลุ้มผู้ติดต่อเป็น My Contact มีได้เพียง 1 กลุ่มเท่านั้น กลุ่มนี้ถูกกำหนดเป็นข้อมูลของระบบ','tbContType', 'tbContType_AppendData', 'Error','Wutikrai', '2013-09-28' ),
90( 'รหัสไปรษณีย์ไม่ได้กำหนดค่า', 'ไม่พบรหัสไปรษณีย์ของที่อยู่ ตามทะเบียน(Home)ของผู้ติดต่อ ' , 'tbPostArea','PostArea_UpdateAreaName_bfIns', 'Error','Wutikrai', '2013-10-01' )
91,('ไม่มีที่อยู่บ้าน(ทะเบียน)', 'ที่อยู่ของผู้ที่ติดต่อแบบ Home อาจไม่ได้กำหนดไว้' ,'tbPostArea', 'PostArea_UpdateAreaName_bfIns', 'Error','Wutikrai', '2013-10-01' )
92,(' หมายเลขโทรศัพท์ ประเภท Custom ต้องกำหนดชื่อ', 'Type Custom ต้องระบุชื่อหรือรายละเอียดว่าเป็นอะไร' ,'tbContPhone', 'tbContPhone_BeforeInsert', 'Error','Wutikrai', '2013-10-01' )
93,(' ที่อยู่ ประเภท Custom ต้องกำหนดชื่อ', 'Type Custom ต้องระบุชื่อหรือรายละเอียดว่าเป็นอะไร' ,'tbContAddr', 'tbContAddr_BeforeInsert', 'Error','Wutikrai', '2013-10-01' )
94,(' อีเมล ประเภท Custom ต้องกำหนดชื่อ', 'Type Custom ต้องระบุชื่อหรือรายละเอียดว่าเป็นอะไร' ,'tbContEmail', 'tbContEmail_BeforeInsert', 'Error','Wutikrai', '2013-10-01' )
95,(' กลุ่มบคุคล ประเภท Custom ต้องกำหนดชื่อ', 'Type Custom ต้องระบุชื่อหรือรายละเอียดว่าเป็นอะไร' ,'tbContGrp', 'tbContGrp_BeforeInsert', 'Error','Wutikrai', '2013-10-01' )
96,(' เลขที่ ประเภท Custom ต้องกำหนดชื่อ', 'Type Custom ต้องระบุชื่อหรือรายละเอียดว่าเป็นอะไร' ,'tbContNumber', 'tbContNumber_BeforeInsert', 'Error','Wutikrai', '2013-10-02' ) -- 10
97,(' ชื่อผู้ติดต่อ ประเภท Custom ต้องกำหนดชื่อ', 'Type Custom ต้องระบุชื่อหรือรายละเอียดว่าเป็นอะไร' ,'tbContNumber', 'tbContNumber_BeforeInsert', 'Error','Wutikrai', '2013-10-02' )
98,(' วันที่ ประเภท Custom ต้องกำหนดชื่อ', 'Type Custom ต้องระบุชื่อหรือรายละเอียดว่าเป็นอะไร' ,'tbContDate', 'tbContDate_BeforeInsert', 'Error','Wutikrai', '2013-10-07' )
99,(' บุคคล ประเภท Custom ต้องกำหนดชื่อ', 'Type Custom ต้องระบุชื่อหรือรายละเอียดว่าเป็นอะไร' ,'tbContContact', 'tbContContact_BeforeInsert', 'Error','Wutikrai', '2013-10-14' )
100,('ขั้นตอนคดีที่ Active มีอยู่แล้ว', 'ขั้นตอนคดีที่ Active มีได้อนเดียว ต้องไปกำหนดขั้นตอนดังกล่าวให้ Inactive ก่อน' ,'trcasetranStep', 'trcasetranStep_BeforeUpdate', 'Error','Wutikrai', '2013-10-27' ) -- 14
101,('ประเภทของเหตุการณ์ซ้ำ', 'ประเภทของเหตุการณ์นอกเหนือ Custom มีได้เพียงเหตุการเดียว' ,'tbLGStepProItemEven', 'tbLGStepProItemEven_BeforeUpdate', 'Error','Wutikrai', '2013-10-28' ) -- 15
102,('ไม่สามารถรหัสสินค้าหรือบริการไม่ได้', 'ไม่สามารถเปลี่ยนรหัสสินค้าหรือบริการไม่ได้' ,'trppayitem', 'PPayItem_ProdByReq', 'Error','Wutikrai', '2014-03-23' ) -- 16
103
104,('คดีได้ดำเนินการแล้ว แ้ไขประเภทคดีไม่ได้', 'trcasetranStep มี 1 record ที่ Active = true แล้ว' ,'trcasetran', 'trcasetran_DefaultProfileStep', 'Error','Wutikrai', '2014-04-30' ) -- 17
105,('ไม่สามารถลบรายการหลักได้', 'รายการ Principal,Interest,Find และ Total ที่เป็นยอดหลัก ต้องมีอย่างนี้อย 1 รายการ', 'tbCaseAmt', '"dbLegal".tbCaseAmt_PreserveTitle', 'Error','Wutikrai', '2014-05-01' ) -- 18
106,('ไม่สามารถรบทนายที่เป็นหัวหน้าทีมได้', 'ทหายที่เป็น หน จะแสดงในหน้าบันทึกโจทก์หรือจำเลย ดังนั้นข้อมูลใน child ต้องมีเพื่อให้สัมพันธ์กัน หากจะลบต้องกำหนดให้ ไม่มเป็น หน.ทีม ( active = false) ก่อน' , 'trcasetranDCLawyer', '"dbLegal".trcasetranDCLawyer_CannotDeleteActive()', 'Error','Wutikrai', '2014-05-08' ) -- 19
107
108,('ทนายนี้ถูกมอบหมายให้กับลูกความที่อยู่ต่างกลุ่มจำเลยหรือโจทก์ในคดีนี้แล้ว', 'ทนายในกลุ่มเดียวกันซ้ำกันได้ แต่ต้องไม่มีในกลุ่มอื่น ของคดีเดียวกัน กลุ่มได้แก่ โจกท์ หรือ จำเลย ' , 'trcasetranDCLawyer', '"dbLegal".trcasetranDCLawyer_IsInOtherGroup()', 'Error','Wutikrai', '2014-05-09' ) -- 20
109,('ไม่สามารถลบรายการที่ไม่ใช่สุดท้ายได้', 'ลบได้เฉพาะรายการที่อยู่ล่าสุดเท่านั้น เพราะ มีการคืนค่าจากข้อมูลเดิม' , 'trcaseassetCalc', '"dbLegal".trcaseassetCalc_ReverseAmount()', 'Error','Wutikrai', '2014-05-18' ) -- 21
110,('ไม่สามารถเพิ่ม,แก้ไขหรือลบทุนทรัพย์ได้', 'เนื่องจาก มีรายการคำนวณและกำหนดภาระของทุนทรัพย์แล้ว การเปลียนแปลงรายการรับเรื่องจะไปเปลียนแปลงทุนทรัพย์ดังกล่าว ' , 'trcasetranAsset', '"dbLegal".trcasetranAsset_NoCaseCalc()', 'Error','Wutikrai', '2014-05-20' ) -- 22
111
112,('Approve แล้ว', 'รายการที่ได้รับการอนุมัติแล้ว หรือ อยู่ระหว่างการตรวจสอบ จะไม่สามารถ submit ซ้ำได้' , null, '"dbSysWKF".trigger_tbwkfrecord_CannotResubmit', 'Error','Wutikrai', '2014-10-07' ) -- 23
113,('อยู่ระหว่างการ Review', 'รายการที่ได้รับการอนุมัติแล้ว หรือ อยู่ระหว่างการตรวจสอบ จะไม่สามารถ submit ซ้ำได้' , null, '"dbSysWKF".trigger_tbwkfrecord_CannotResubmit', 'Error','Wutikrai', '2014-10-08' ) -- 24
114,('Must refere job card of Fligh Desk', 'LRU must have job card open before sending for reparing' , null, '"acAATC".LRU_MustReferJC', 'Error','Wutikrai', '2014-10-12' ) -- 25
115,('Serial No does not exist', null , null,null, 'Error','Wutikrai', '2014-11-10' ) -- 26
116,('Serial state is "In"/"Out" already', null , null,null, 'Error','Wutikrai', '2014-11-10' ) -- 27
117
118,('Only %s service is allowed','AATC only','"acAATC".tbworkorder_Only1Service()' ,'"acAATC".tbworkordervw_test4.sql' ,'Error' ,'Wutikrai', '2014-12-07' ) -- 28
119,('User %L is not Supervisor/higher, can not %s','Only user with privilege of Supervisor or above can approve' , null,'"dbSysWKF".SubmitApproval()', 'Error','Wutikrai', '2015-01-19' ) -- 29
120,('Can not change, have serials %s already','Once having serial, cannot change stock item/qty since it affect serial state' , '"dbInventory".trstrecitem_PROC.sql','"dbInventory".trstrecitem_CannotChangeInven_WhenHaveSerial() ', 'Error','Wutikrai', '2015-01-22' ) -- 30
121
122,('No user id %s','The user id does not exist in "dbUserAcc".tbUser' , '"dbUserReg".tbUserRegVW.sql','"dbUserReg".tbUserRegVW_UpdData()', 'Error','Wutikrai', '2015-03-14' ) -- 31
123,('User %s(%s) is not "Admin"','Only "Admin" can insert/update/delete' , '"dbUserReg".tbUserRegVW.sql','"dbUserReg".tbUserRegVW_UpdData()', 'Error','Wutikrai', '2015-03-14' ) -- 32
124,('User %s(%s) is not registered user','No registered data for this user id' , '"dbUserReg".tbUserRegVW.sql','"dbUserReg".tbUserRegVW_UpdData()', 'Error','Wutikrai', '2015-03-18' ) -- 33
125,('Cannot delete the last Admin, %s(%s)','Users must have at least 1 Admin' , '"dbUserReg".tbUserReg_PROC.sql','"dbUserReg".tbUserReg_CannotDeleteLastAdmin() ', 'Error','Wutikrai', '2015-03-18' ) -- 34
126,('ไม่สามารถลบหรือแก้ไชข้อมูลระบบได้','This data is duplicated from system one. It can be changed, but no delete' , '"dbSys".fnView.sql','"dbSys".tbViewRegis_Cannot_del_system_data()', 'Error','Wutikrai', '2015-04-02' ) -- 35
127,('"%s(%s)" สำหรับ "%s(%s)" มียอด "%s" ซึ่งเกินที่กำหนดไว้ "%s(%s)"','Invoice fee cannot be over limit set by fee of topmost step' , '"dbLegal".tbpnvitem_proc','"dbLegal".trpinvitem_Check_fee_limit()', 'Error','Wutikrai', '2015-05-24' ) -- 36
128
129,('Can not change original modified contact','To keep its changes to the original one' , '"dbContact".tbContactRegVW','"dbContact".tbContactRegVW_UpdData()', 'Error','Wutikrai', '2015-05-29' ) -- 37
130,('ขั้นตอนคดีที่เป็นปัจจุบันยังไม่ได้กำหนด','ต้องกำหนดให้ขั้นตอนคดีใด active ก่อนการบันทึกเหตุการณืใดๆ' , '"dbLegal".trcasetranEvent_PROC','"dbLegal".trcasetranEvent_StepMustActive()', 'Error','Wutikrai', '2015-06-01' ) -- 38
131,('ไม่สามารถเปลียนเช็คหรือตั๋วเงินได้','หากต้องการเปลียนให้ลบรายการนั้นออกไปแล้วป้อนรายการใหม่' , '"dbFinance".trppaychq_PROC2_WKF.sql','"dbFinance".trppaychq_ChqLog_ChqChanged()', 'Error','Wutikrai', '2015-06-30' ) -- 39
132,('ไม่ได้กำหนดงานคดี','เอกสารการเงินต้องกำหนดงานคดี' ,null,null, 'Default','Wutikrai', '2015-07-03' ) -- 40
133,('ไม่มีขึ้นตอนคดีที่แอคทีฟ','เอกสารการเงินต้องกำหนดว่าเป็นของขั้นคดีใหน' ,null,null, 'Default','Wutikrai', '2015-07-03' ) -- 41
134,('ตั๋วเงิน %s เลขที่ %I จำนวนเงิน %I น้อยกว่ายอดที่ใช้ %I','ยอดเงินอาจถูกใช้ไปด้วยรายการอื่นหรือรายการอื่นมีการ approve แล้วแต่รายการนี้มา approve ทีหลัง' ,null,'"dbFinance".tbCheq_BalanceNotNegative()', 'Default','Wutikrai', '2015-07-04' ) -- 42
135--,('%s เลขที่ %I จำนวนเงิน %I น้อยกว่ายอดทำจ่าย %I','การชอเบิกนี้อาจถูกชำระด้วยรายการจ่ายอื่น หรือ รายการจ่ายที่ได้ approve ก่อนรายการจ่ายนี้' ,null,'"dbFinance".tbCheq_BalanceNotNegative()', 'Default','Wutikrai', '2015-07-04' ) -- 43
136,('ยอดชำระเกิน, %s เลขที่ %I ยอด %I น้อยกว่ายอดชำระ %I','การชอเบิกนี้อาจถูกชำระด้วยรายการจ่ายอื่น หรือ รายการจ่ายที่ได้ approve ก่อนรายการจ่ายนี้' ,null,'"dbFinance".tbCheq_BalanceNotNegative()', 'Default','Wutikrai', '2015-07-04' ) -- 43
137
138
139,('คดีเลขที่ %I เรื่อง %I ยังไม่กำหนดลูกค้า','การออกอินวอยซืเพื่อเรียกเก็บเงินต้องระบุลูกค้าในงานคดีก่อน' ,null,'"dbLegal".trpinv_CaseMustHaveCustomer()', 'Default','Wutikrai', '2015-07-08' ) -- 44
140,('เรียกเก็บลูกค้า "%s(%s)" ซึ่งไม่ตรงกับลูกค้าในข้อมูลคดี "%s(%s)"','ลูกค้าที่เรียกเก็บเงินต้องตรงกับลูกค้าที่ระบุในข้อมูลคดี' ,null,'"dbLegal".trpinv_CaseMustHaveCustomer()', 'Default','Wutikrai', '2015-07-09' ) -- 45
141
142
143,('%sเลขที่ %I จำนวนเงิน %I น้อยกว่ายอดตั้งเบิก %I','การตั้งเบิกต้องไม่เกินจำนวนเงินในเอกสาร' ,null,'"dbFinance".trpinv_CollectMustNotOver()', 'Default','Wutikrai', '2015-07-10' ) -- 46
144,('ไม่สามารถแก้ไขสถานะ มีการอ้างอิงแล้ว ( %s,%s.%s=%s)', '' ,null,'"dbSysWKF".cannot_change_app_when_refered()', 'Default','Wutikrai', '2015-07-10' ) -- 47
145,('ต้องระบุสาเหตุหรือรายละเอียดของเหตุการณ์', '' ,null,'"dbLegal".trcasetranEvent_MustRemark()', 'Default','Wutikrai', '2015-07-13' ) -- 48
146,('ไม่สามารถแก้ไขสถานะ/ข้อมูล( "%s"เปลียนค่า"%s"->"%s"), ถูกอ้างอิงโดย%s (%s.%s=%s)', '' ,null,'"dbSysWKF".cannot_change_app_when_refered()', 'Default','Wutikrai', '2015-07-20' ) -- 49
147,('%s %s ทุนทรัพย "%s" ไม่ตรงกับ %s ที่มีอยู่ ((%s)', '' ,null,'"dbLegal".trcasetranAsset_CreateDelete_DC()', 'Default','Wutikrai', '2015-07-22' ) -- 50
148,('Data "%s" was entirely used already("%s".%s,#%s)', '' ,null,'"dbSysWKF".cannot_post_exceed_limit()', 'Default','Wutikrai', '2015-08-29' ) -- 51
149
150,('Data was not approved("%s".%s,#%s)', '' ,null,'"dbSysWKF".cannot_post_exceed_limit()', 'Default','Wutikrai', '2015-08-30' ) -- 52
151,('"%s" ต้องระบุรายละเอียด', 'ขั้นตอนต้องระบุรายละเอียดเมือกำหนดให้แอคทีฟ หรือมีการเลือก เช่น การถอนฟ้องต้องระบุรายละเอียดว่าทำไมจึงถอนฟ้อง' ,null,'"dbLegal".trcasetranStep_description_require()', 'Default','Wutikrai', '2015-09-22' ) -- 53
152
153,('ไม่ได้ใส่วันที่', 'Event data is null' ,null,'', 'Default','Wutikrai', '2015-09-22' ) -- 54
154
155
156, ('ค่าใช้จ่ายที่กำหนดไว้ทั้งหมดมีค่าศูนย์, ขั้นตอน "%s", โพรไฟล์เก็บเงิน "%s"' ,'สร้างอินวอยซ์ก็ต่อเมื่อรายการค่าใช้จ่ายที่กำหนดไว้ในโพรไฟล์มีค่ารวมกันแล้วมากกว่าศูนย์',null, '"dbLegal".tbCaseCollect_GenInvoice()', 'Default','Wutikrai', '2015-10-02' ) -- 55
157
158, ('ช่วงวันที่ไม่ถูกต้อง ,เริ่ม="%s",สิ้นสุด="%s"' ,'วันที่สิ้นสุดต้องไม่น้อยกว่าวันที่เริ่มต้น',null, '"dbLegal".trcaseassetDate_ValidStartEndDate()', 'Default','Wutikrai', '2015-10-03' ) -- 56
159
160, ('ไม่สามารถเลือก "%s" เพราะเป็นกลุ่มสิ้นค้า' ,'','ต้องเลือกสินค้าที่อยู่ภายในกลุ่มนั้นๆ ', '"dbUserAccReg".tbUserProd_AddProd()', 'Default','Wutikrai', '2015-10-18' ) -- 57
161, ('ผู้ใช้ "%s"ยัญชี "%s",ไม่สามารถเพิ่มแก้ไขหรือลบข้อมูลต่างบัญชี "%s" ได้' ,'ผู้ใช้ที่สามารถแก้ไขข้อมูลต้องอยู่ในบัญชีเดียวกับข้อมูล','', '"dbSys".priv_OnlySameAccCanChange()', 'Default','Wutikrai', '2015-10-20' ) -- 58
162
163, ('Can not change product "%s" to "%s"' ,'Only changing edition is allowed','', '"dbUserAccReg".tbUserProd_CanNOTChangeProduct()', 'Default','Wutikrai', '2015-10-21' ) -- 59
164, ('ไม่สามารถเพิ่มหรือแก้ไขข้อมูลได้ , "%s" ไม่ใช่ ผู้ลงทะเบียน' ,'เฉพาะผู้ลงทะเบียนเท่านีั้นแก้ไชสินค้าได้','', '"dbUserAccReg".tbUserProd_OnlyOwnerCanAddEdit()', 'Default','Wutikrai', '2015-10-21' ) -- 60
165
166, ('User "%s" is terminated' ,'','', '"dbSys".create_userPriv()', 'Default','Wutikrai', '2015-10-24' ) -- 61
167, ('Product Menu "%s" is "%s"' ,'','', '"dbSys".create_userPriv()', 'Default','Wutikrai', '2015-10-24' ) -- 62
168, ('User Menu "%s" for user "%s" is terminated' ,'','', '"dbSys".create_userPriv()', 'Default','Wutikrai', '2015-10-24' ) -- 63
169
170, ( 'UID is null' ,'','', '"dbSys".user_priv () ', 'Default','Wutikrai', '2015-10-25' ) -- 64
171, ( '"%s" do not have role "%s"' ,'','', '"dbSys".user_priv () ', 'Default','Wutikrai', '2015-10-25' ) -- 65
172
173, ( 'User "%s" have no privilege "%s"' ,'','', '"dbSys".user_priv () ', 'Default','Wutikrai', '2015-10-25' ) -- 66
174, ( 'Menu "%s" have no privilege "%s"' ,'','', '"dbSys".user_priv () ', 'Default','Wutikrai', '2015-10-25' ) -- 67
175, ( 'User menu "%s" have no privilege "%s"' ,'','', '"dbSys".user_priv () ', 'Default','Wutikrai', '2015-10-25' ) -- 68
176, ( '"%s" is not for edition "%s" ' ,'','', '"dbSys".create_userPriv()', 'Default','Wutikrai', '2015-10-29 04:06' ) -- 69
177, ( 'Can not %s data created by system user' ,'','', '"dbSys".create_userPriv()', 'Default','Wutikrai', '2015-11-27 17:23' ) -- 70
178, ( 'Can not edit system data %s' ,'','', '"dbSys".tbViewRegis_edit_system_data()', 'Default','Wutikrai', '2015-12-12 13:37' ) -- 71
179
180, ( '"%s" มากกว่า "%s" ของหลักประกันเลขที่ "%s"' ,'','', '"dbLegal".trcaseasset_gua_NotOver()', 'Default','Wutikrai', '2015-12-18' ) -- 72
181
182, ( '%s "%s" มากกว่า %s "%s"' ,'','"dbLegalEDU".trcasetranEvent_PROC2', '"dbLegal".trcasetranEvent_DateOrder()', 'Default','Wutikrai', '2016-01-03' ) -- 73
183, ( '%s "%s" น้อยกว่า %s "%s"' ,'','"dbLegalEDU".trcasetranEvent_PROC2', '"dbLegal".trcasetranEvent_DateOrder()', 'Default','Wutikrai', '2016-01-03' ) -- 74
184, ( 'ไม่สามารถลบ/แก้ไข เมื่อเกิน %s วัน นับแต่ "%s"' ,'','', '"dbUserAccReg".tbUserProd_CannotRemoveEditWhenOver30days()', 'Default','Wutikrai', '2016-06-06' ) -- 75
185, ( '"%s" ไลเซนท์หมดอายุ %s วันที่แล้ว ตั้งแต่ "%s"' ,'"%s" have license expire %s days ago,since "%s"','', '"dbSys".user_priv ()', 'Default','Wutikrai', '2016-06-06' ) -- 76
186
187, ( 'ข้อมูลซ้ำ! "%s" มีอยู่แล้ว' ,'Duplicate!"%s" does exist','', '"dbContact".tbContact_AppendData()', 'Default','Wutikrai', '2016-01-11' ) -- 77
188
189, ( 'ไม่สามารถเพิ่มยูสเซอร์ เนื่องจากยังไม่ได้เลือกสินค้า/บริการ' ,'Can not add user,no product selected','', ' "dbUserReg".tbUserReg_CannotAddUserIfNoProdSelecte()', 'Default','Wutikrai', '2016-01-13' ) -- 78
190, ( '"%s" ไม่ใช่ของ "%s"' ,'The branch is not belings to the bank','', '"dbFinance".tbCheq_BranchOfBank()', 'Default','Wutikrai', '2016-01-19' ) -- 79
191, ( 'แก้ไขชื่ไม่ได้ กำหนดโดยโพรไฟล์' ,'Can not change title, from profile','', '"dbLegal".trcasetranEvent_cannot_change_title()', 'Default','Wutikrai', '2016-01-20' ) -- 80
192
193,('"%s(%s)" เอกสาร "%s(%s)" มียอด "%s" ซึ่งเกินที่กำหนดไว้ "%s(%s)"','Invoice fee cannot be over limit set by fee of topmost step' , '"dbLegal".tbpnvitem_proc','"dbLegal".trpinvitem_Check_fee_limit()', 'Error','Wutikrai', '2015-05-24' ) -- 81
194,('ไม่มี ประเภทหรือกลุ่ม "%s"','Not valid contact type' , '','"dbContact".tbContGrp_AddGroups()', 'Error','Wutikrai', '2016-03-22' ) -- 82
195
196
197,('ไม่สามารถแก้ไขหรือลบเหตุการณ์ของระบบได้. เหตุการณ์ "%s"','Can not change/delete it is system event "%s"' , '','"dbLegal".tbLGStepProItemEventVW_UpdData()', 'Error','Wutikrai', '2016-03-30' ) -- 83
198,('จำนวนคอลัมป์ไม่ครบ','' , '','"dbSysRPT".Import_Txt2Temp()', 'Error','Wutikrai', '2016-05-15' ) -- 84
199,('จำนวนคอลัมป์เกิน','' , '','"dbSysRPT".Import_Txt2Temp()', 'Error','Wutikrai', '2016-05-16' ) -- 85
200,('เมนูนี้ยังไม่กำหนดให้ใช้งาน','This menu is not authorized' , 'May the product is not set','', 'Error','Wutikrai', '2016-05-19' ) -- 86
201,('ตัวเลขไม่ถูกต้อง','Invalid numeric' , '','', 'Error','Wutikrai', '2016-05-25' ) -- 87
202,('ไม่มีข้อมูล','ข้อมูลว่างไม่สามารถนำเข้าระบบได้' , '','"dbSysRPT".Import_ValidateData()', 'Error','Wutikrai', '2016-05-29' ) -- 88
203,('ข้อกำหนด "%s" มีแล้ว , "%s"' ,null, '','', 'Error','Wutikrai', '2016-08-24' ) -- 89
204,('Dummy' ,null, '','', 'Error','Wutikrai', '2016-10-24' ) -- 90 25' ) -- 90
205
206,('No custom value' ,null, '','"dbSys".fnMetaData_title_tcustom()', 'Error','Wutikrai', '2016-10-24' ) -- -- 91
207,('โปรแกรม "%s" สำหรับ %s เท่านั้น' ,null, '',')', 'Error','Wutikrai', '2017-01-05' ) -- 92
208,('ไม่สามารถลบรายการที่ไม่แอกทีพได้' ,null, '"dbLegal".trcaseassetCalc_DeleteDebtCalc()','', 'Error','Wutikrai', '2017-01-06' ) -- 93
209,('ผู้ใช้ "%s" ไม่มีสิทธิ์การใช้งาน ( License)' ,null, '','', 'Error','Wutikrai', '2017-02-18' ) -- 94
210,('ชื่อเอกสารว่าง' ,null, '','"dbDoc".tbDocVW_UpdData()', 'Error','Wutikrai', '2017-03-25' ) -- 95
211,('ข้อมูลนำเข้ามีอยู่ในระบบแล้ว' ,null, '','"dbLegalEDU".imCaseAsset00_STD_Temp2Data()', 'Error','Wutikrai', '2017-06-27' ) -- 96
212,('ไม่ได้เลือกดำเนินการ' ,null, '','"dbLegal".rpIndict_validate', 'Error','Wutikrai', '2017-07-02' ) -- 97
213,('"%s" เป็นชื่อกลุ่มไม่สามารถเลือกได้' ,null, '','"dbLegal".trcasetran_Defaul_valid_lgtype()', 'Error','Wutikrai', '2017-07-11' ) -- 98
214,('ไม่ได้กำหนดวันที่รับงาน' ,null, '','', 'Error','Wutikrai', '2017-07-18' ) -- 99
215,('ไม่สามารถกำหนดสิทธิ์ให้ "%s" เนื่องจากกำหนดสิทธิ์ระดับโปรแกรมเป็น "%s" แล้ว' ,'Can not set privilege to "%s", it has program privilege "%s" already', '"dbUserAccReg".tbUserPrdMenu_set_priv()','', 'Error','Wutikrai', '2017-07-19' ) -- 100
216, ( 'User "%s"(group "%s") have no privilege "%s"' ,'','', '"dbSys".user_priv () ', 'Default','Wutikrai', '2017-07-21' ) -- 101
217, ( '"%s" เป็นสมาชิกของ "%s" อยู่แล้ว ' ,'','', '"dbLegal".tbLawyerVW_UpdData()', 'Default','Wutikrai', '2017-08-04' ) -- 102
218, ( 'ไม่มีข้อมูลโปรไฟล์ของเอกสาร,โพรไฟล์คดี "%s",ประเภทคดี "%s"' ,'','', '"dbLegal".tbcasetrdisaud_doc2casedoc()', 'Default','Wutikrai', '2017-09-10' ) -- 103
219,( 'ไม่มีกลุ่ม "%s"','No asset group' , '' ,'"dbContact".tbContGrp_AddGroups()', 'Error','Wutikrai', '2016-03-22' ) -- 104
220
221,( 'ไม่สามารถแก้ไขข้อมูลได้เนื่องจากไม่ได้กำหนดให้รันเลขที่', '' , '' ,'"dbLegal".tbLGStepProItemDocType_FormatRunno()', 'Error','Wutikrai', '2017-11-15' ) -- 105
222,( 'ไม่กำหนดโพรไฟล์', '' , '' ,'"dbLegal".rpNotice_validate()', 'Error','Wutikrai', '2017-11-17' ) -- 106
223,( 'ไม่มีโปรเจก,pid "%s"', '' , '' ,'"dbPM".tbTask_CreateCalenTask()', 'Error','Wutikrai', '2017-12-05' ) -- 107
224
225,( 'ไม่กำหนดผู้รับ', '' , '' ,'"dbFinance".trppqt_RefreshPayerPayeeType()', 'Error','Wutikrai','2017-12-07' ) -- 108
226,( 'ไม่กำหนดผู้จ่าย', '' , '' ,'"dbFinance".trppqt_RefreshPayerPayeeType()', 'Error','Wutikrai','2017-12-07' ) -- 109
227,( 'ไม่มีข้อมูลหลักเอกสาร "%s",โพรไฟล์ "%s"', '' , '' ,'"dbLegal".rpNotice_BeforeInsert()', 'Error','Wutikrai','2017-12-16' ) -- 110
228,( 'คดี "%s"มีโพรไฟล์"%s" ไม่ตรงกับตัวเลือกโพรไฟล์"%s"', '' , '' ,'"dbLegal".rpNotice_BeforeInsert()', 'Error','Wutikrai','2017-12-18' ) -- 111
229,( 'ไม่สามารถแก้ไข/ลบข้อมูลศาลได้ ,กรุณาติดต่่อบริษัท', '' , '' ,'"dbLegal".tbCourtVW_UpdData()', 'Error','Wutikrai','2018-07-14' ) -- 112
230,( 'ไม่สามารถแก้ไขทุนทรัพย์ได้ เนื่องจากมีการบันทึกยอดทุนทรัพย์โดยตรงแล้ว', '' , '' ,'"dbLegal".trcasetran_UpdateAmount()', 'Error','Wutikrai','2019-09-02' ) -- 113
231,( 'ยอดที่ใช้ไปรวม "%s" เกินยอดที่มีอยู่ "%s"' , '' , '' ,'"dbLegal".trcaseasset_caseamt_over_total() ', 'Error','Wutikrai','2019-09-12' ) -- 114
232,( '"%s" จำเป็นต้องมีข้อมูล' , '' , '' ,'"dbLegal".trcaseassetattr_RequireData()', 'Error','Wutikrai','2018-11-08' ) -- 115
233,( 'ประเภท%s ต้้องอ้างถึง%s ที่ต้องการเปลียนแปลง่' , '' , '' ,'"dbLegal".trcasetranVW_UpdData() ', 'Error','Wutikrai','2019-01-17' ) -- 116
234,( 'ลบไม่ได้ กรุ๊ป "%s" มียูสเซอร์ %s คน่' , '' , '' ,'"dbUserReg".tbUserRegVW_UpdData()', 'Error','Wutikrai','2019-02-11' ) -- 117
235,( 'เข็คเลขที่ %s วันที่ %s จำนวนเงิน %s ถูกใข้หมดแล้ว่' , '' , '' ,'"dbFinance".trppaychq_SaveChqData()', 'Error','Wutikrai','2019-02-15' ) -- 118
236--119
237,( 'ไม่สามารถลบ "%", "%s" อ้างอิงอย่' , '' , '' ,'"dbLegal".trcasetranevent_cannot_del_trail() ', 'Error','Wutikrai','2019-04-13' ) -- 120
238,( 'ไม่สามารถลบได้ "%s" จำเป็นหลังมีหลัง "%s"่' , '' , '' ,'"dbLegal".trcasetranevent_cannot_del_trail() ', 'Error','Wutikrai','2019-04-13' ) -- 121
239,( 'ไม่สามารถลบกลุ่มของระบบได้ "%s"่' , '' , '' ,'"dbLegal".trcasetrangrp_cannot_del_system() ', 'Error','Wutikrai','2019-04-30' ) -- 122
240,( 'ไม่สามารถลบได้ มีคดีแทรกเลขดำ"%s",เลขแดง"%s",ขั้นตอน"%s",id"%s"' , '' , '' ,'"dbLegal".trcasetranStep_cannot_del_ircase() ', 'Error','Wutikrai','2019-04-30' ) -- 123
241,( 'ไม่สามารถลบได้เป็นคดีแทรกของคดี เลขดำ"%s",เลขแดง"%s",ขั้นตอน"%s",id"%s"' , '' , '' ,'"dbLegal".trcasetran_cannot_del_ircase() ', 'Error','Wutikrai','2019-04-30' ) -- 124
242
243;
244
245-- insert into "dbSys".tbErrMsg (msg, description,tablename,proc,kind, uid, upd) values ( 'ประเภท%s ต้้องอ้างถึง%s ที่ต้องการเปลียนแปลง่่' , '' , '' ,'"dbLegal".trcasetrn020VW_UpdData2() ', 'Error','Wutikrai','2019-01-17' ) -- 116;
246-- insert into "dbSys".tbErrMsg (msg, description,tablename,proc,kind, uid, upd) values ( 'ลบไม่ได้ กรุ๊ป "%s" มียูสเซอร์ %s คน่' , '' , '' ,'"dbUserReg".tbUserRegVW_UpdData()', 'Error','Wutikrai','2019-02-11' ); -- 117
247-- insert into "dbSys".tbErrMsg (msg, description,tablename,proc,kind, uid, upd) values ( 'เข็คเลขที่ %s วันที่ %s จำนวนเงิน %s ถูกใข้หมดแล้ว่' , '' , '' ,'"dbFinance".trppaychq_SaveChqData()', 'Error','Wutikrai','2019-02-15' ) ; -- 118
248-- insert into "dbSys".tbErrMsg (msg, description,tablename,proc,kind, uid, upd,id) values ( 'ไม่สามารถลบ "%s","%s" อ้างอิงอยู่' , '' , '' ,'"dbLegal".trcasetranevent_cannot_del_trail() ', 'Error','Wutikrai','2019-04-13',120 ) -- 120
249 -- delete from "dbSys".tbErrMsg where id=120;
250-- insert into "dbSys".tbErrMsg (msg, description,tablename,proc,kind, uid, upd,id) values ( 'ไม่สามารถลบได้ "%s" จำเป็นหลังมีหลัง "%s"่' , '' , '' ,'"dbLegal".trcasetranevent_cannot_del_trail() ', 'Error','Wutikrai','2019-04-13', 121 ) -- 121
251-- insert into "dbSys".tbErrMsg (msg, description,tablename,proc,kind, uid, upd,id) values ( 'ไม่สามารถลบกลุ่มของระบบได้ "%s"่' , '' , '' ,'"dbLegal".trcasetrangrp_cannot_del_system() ', 'Error','Wutikrai','2019-04-30' ,122) -- 122
252 -- update "dbSys".tbErrMsg set msg = 'ไม่สามารถลบกลุ่มของระบบได้ "%s"่' where id = 122;
253 -- select * from "dbSys".tbErrMsg where msg = 'ไม่สามารถลบกลุ่มของระบบได้ "%s"่' ;
254-- insert into "dbSys".tbErrMsg (msg, description,tablename,proc,kind, uid, upd,id) values ( 'ไม่สามารถลบได้ มีคดีแทรกเลขดำ"%s",เลขแดง"%",ขั้นตอน"%s", id"%s"' , '' , '' ,'"dbLegal".trcasetranStep_cannot_del_ircase() ', 'Error','Wutikrai','2019-04-30',123 ) -- 123
255 -- update "dbSys".tbErrMsg set msg = 'ไม่สามารถลบได้ มีคดีแทรกเลขดำ"%s",เลขแดง"%s",ขั้นตอน"%s",id"%s"' where id = 123;
256-- insert into "dbSys".tbErrMsg (msg, description,tablename,proc,kind, uid, upd,id) values ( 'ไม่สามารถลบได้เป็นคดีแทรกของคดี เลขดำ"%s",เลขแดง"%s",ขั้นตอน"%s",id"%s"' , '' , '' ,'"dbLegal".trcasetran_cannot_del_ircase() ', 'Error','Wutikrai','2019-04-30', 124 ) -- 124
257
258drop function if exists "dbSys".sysGetErrMsg(in i Int, out ms text, out errmsg text );
259create or replace function "dbSys".sysGetErrMsg (in i Int, out ms text, out errmsg text ) as $$
260BEGIN
261 select msg into ms from "dbSys".tbErrMsg where id = i;
262 errmsg := ms;
263 if ms is not null then
264 ms := concat_ws(' ',ms,'-', i );
265
266 end if;
267-- raise exception 'i=%, msg=%', i, m;
268
269end $$ LANGUAGE plpgsql;
270
271/***************************************
272
273 Loggin error information and return error message to user. Progrem decide whether stop or not , depending on Kind of Error
274 Authur : Wutikrai Pornchi
275 Since : 28-09-2013
276
277 Sample Call :-
278
279 err := 'ไม่ได้เลือกดำเนินการ';
280 select msg from "dbSys".sysCallErrMsg(
281 97
282 ,null -- talbename = description , format('%I.%s',tg_table_schema, tg_table_name)
283 ,null -- new.id
284 ,null -- NEW.uID
285 ,errmsg := err
286 )
287 into err;
288 raise exception '%', format(err ) ;
289
290*************************************/
291
292
293drop function if exists "dbSys".sysCallErrMsg(
294 in i Int , -- Error id
295 in Tablename text , -- Descriptin from caller ,no more table name since 28-10-2013
296 in RecordID int ,
297 in UID int ,
298 out m text
299);
300
301drop function if exists "dbSys".sysCallErrMsg(
302 in i Int , -- Error id
303 in Tablename text , -- Descriptin from caller ,no more table name since 28-10-2013
304 in RecordID int ,
305 in UID int ,
306 in errmsg text , -- default from caller
307 out msg text
308);
309
310create or replace function "dbSys".sysCallErrMsg(
311 inout i Int , -- Error id
312 in Tablename text , -- Descriptin from caller ,no more table name since 28-10-2013
313 in RecordID int ,
314 in UID int ,
315 in errmsg text = null , -- default from caller
316 out msg text
317) as $$
318declare Kind text;
319BEGIN
320 select ms into msg from "dbSys".sysGetErrMsg( i );
321
322 -- raise exception 'i=%, msg=%',i,msg;
323
324
325 if msg is not null then
326 insert into "dbSys".tbErrLog( pid, tablename,recordid, uid ) values ( i, tablename,recordid, uid );
327 select a.kind into kind from "dbSys".tbErrMsg a where a.id = i;
328 if kind = 'Error' then
329 -- perform sysRaiseWarning( msg );
330 -- raise exception '%','Error';
331
332 -- raise EXCEPTION '%',msg; -- Exception would abort last operation , still want to log DATA.
333
334 end if;
335 else
336
337 if errmsg is not null then
338 msg := concat_ws(' ',errmsg,'-', i );
339 else
340 msg := format('No error id# %s',i);
341 end if;
342 end if;
343end $$ LANGUAGE plpgsql;
344
345/***********************************************
346 Function : Execute sql and return error message, and its id
347
348 Sample :
349 select ms from "dbSys".errExecute( vartext('sql'));
350
351 Trap thi below:
352 update "dbSysWKF".tbworkorder_wkfrecvw11 set approvebyid= 24, approvewhen = now(), approvekind='6436' where id = Approve
353
354************************************************/
355
356drop function if exists "dbSys".errExecute( in sql text
357 , out ms text
358 , out errmsg text
359 , out errid int
360 , out start_time timestamp without time zone
361 , out stop_time timestamp without time zone
362 );
363
364create or replace function "dbSys".errExecute( in sql text,
365 out ms text
366 ,out errmsg text
367 ,out errid int
368 ,out start_time timestamp without time zone
369 ,out stop_time timestamp without time zone
370 ,out elapse_time interval
371)
372returns record as $$
373declare idpart text ;
374
375begin
376 ms := null; errid := null;
377
378 start_time := clock_timestamp();
379 begin
380 execute sql;
381 exception when others then
382 ms := SQLERRM;
383 end;
384 --*
385 stop_time := clock_timestamp();
386 elapse_time := stop_time - start_time;
387
388 --*
389 /**********************************
390 errmsg := split_part (ms, '-', 1 );
391 errmsg := trim(errmsg);
392 idpart := split_part (ms, '-', 2 );
393
394 select cutstr_right( '11-12-13-14','-');
395
396 "2016-01-07" is greater than one in next event,"2016-01-06" - 73
397
398 select cutstr_right( '"2016-01-07" is greater than one in next event,"2016-01-06" - 73','-'); --- - 73
399
400 select cutstr_right( '"2016-01-06" - 73','-'); -- - 73
401
402
403 select strpos_right( '"2016-01-07" is greater than one in next event,"2016-01-06" - 73', '-' ); -- 61
404
405
406 ************************************/
407 -- raise notice '355 %', ms ;
408 --if position ( '-' in ms ) > 0 then
409 -- raise notice '357';
410 begin
411 idpart := CutStr_Right(ms,'-');
412 -- "-117"
413 -- or may have more trailing error msg, "- 117, 9999: xxxxxxxxx......'
414 idpart := replace(idpart,'- ','-' ); -- "- 117" --> "-117"
415 idpart := replace(idpart,',', ' ');
416 idpart := cutstr( idpart,' ' ) ; -- "-117 " , select cutstr('-117 ,9999:xxxxxx', ' ' );
417 idpart := trim(idpart);
418
419 -- raise '0411:idpart %',idpart;
420 if idpart is not null then
421 errmsg := replace( ms, idpart, '');
422 else
423 errmsg := ms;
424 end if;
425 -- raise '0417: idpart "%", errmsg %',idpart, errmsg;
426 exception
427 when others then raise exception '0393:%, ms %', sqlerrm, ms;
428 end;
429
430 errmsg := trim(errmsg);
431 idpart := trim(leading '-' from idpart );
432 idpart := trim(idpart);
433
434
435 if not emptystr(idpart) then
436 begin
437 errid := idpart::int;
438 exception
439 when others then
440 errid := -1;
441 errmsg := ms;
442 end ;
443 end if;
444 --else
445 -- errmsg := ms;
446 -- idpart := 0;
447 --end if;
448
449
450 -- raise notice '379, errmsg %', errmsg;
451
452end $$ language plpgsql;
453
454/***********************************
455
456drop function if exists "dbSys".sqlResult( in sql text );
457create or replace function "dbSys".sqlResult( in sql text )
458returns int as $$
459declare result int;
460begin
461 execute sql into result;
462 return result;
463end $$ language plpgsql;
464****************************************/
465
466create or replace function "dbSys".errmsg(
467 in id int
468 , in errinfo text = null
469 , in uid int = null
470 , in recid int = null
471 , out err text ) returns text as $$
472begin
473 select msg from "dbSys".sysCallErrMsg(
474 id -- in i Int , -- Error id
475 ,errinfo -- in Tablename text , -- Descriptin from caller ,no more table name since 28-10-2013
476 ,recid -- in RecordID int ,
477 ,uid -- in UID int ,
478 ) into err;
479
480end $$ language plpgsql;
481
482/***********************************
483 Function : error registration
484 07-12-2014,Wut
485*************************************/
486drop function if exists "dbSys".errRegistration(
487 in errmsg text
488 ,in descript text
489 ,in func text
490 ,in file text
491 ,in devname text
492 ,in devdate date
493);
494create or replace function "dbSys".errRegistration(
495 in errmsg text
496 ,in descript text
497 ,in func text
498 ,in file text
499 ,in devname text
500 ,in devdate date
501 ,out _id int
502) returns int as $$
503declare find record;
504begin
505 select id from "dbSys".tbErrMsg where msg = errmsg into find;
506 if find is null then
507 insert into "dbSys".tbErrMsg (msg, description,tablename,proc,kind, uid, upd) values (
508 errmsg ,descript, file, func,'Error',devname, devdate::timestamp
509
510 )
511 returning id into _id;
512
513 else
514 _id := find.id;
515 update "dbSys".tbErrMsg set msg = errmsg, description= descript ,tablename = file, proc = func
516 ,uid = devname, devdate= upd::timestamp;
517
518 end if;
519
520end $$ language plpgsql;
521
522
523/**********************************
524 Registration
525**********************************/
526/*
527select _id from "dbSys". errRegistration(
528 'Only %s service is allowed'
529 ,'AATC only'
530 ,'"acAATC".tbworkorder_Only1Service()' ,'"acAATC".tbworkordervw_test4.sql' ,'Wutikrai', '2014-12-07'
531); -- 28
532
533*/