[Greater-commits] r393 - trunk/packaging/defaultdata
scm-commit@wald.intevation.org
scm-commit at wald.intevation.org
Mon Jul 11 10:54:43 CEST 2011
Author: bricks
Date: 2011-07-11 10:54:43 +0200 (Mon, 11 Jul 2011)
New Revision: 393
Modified:
trunk/packaging/defaultdata/11_create_tables.sql
Log:
Update bin_obj_procf to postgres syntax and fix the function
All trigger function should return TRIGGER type
Modified: trunk/packaging/defaultdata/11_create_tables.sql
===================================================================
--- trunk/packaging/defaultdata/11_create_tables.sql 2011-07-08 15:37:42 UTC (rev 392)
+++ trunk/packaging/defaultdata/11_create_tables.sql 2011-07-11 08:54:43 UTC (rev 393)
@@ -213,27 +213,25 @@
-- Name: "bin_obj_procf" () Type: FUNCTION Owner: greater
--
-CREATE FUNCTION "bin_obj_procf" () RETURNS opaque AS '
+CREATE FUNCTION "bin_obj_procf" () RETURNS TRIGGER AS '
DECLARE
updateAction VARCHAR (10);
remarkString VARCHAR (2001);
- separatorPos NUMERIC (3);
+ separatorPos INT;
BEGIN
updateAction := ''nothing'';
IF TG_OP=''UPDATE'' THEN
IF (OLD.REMARK IS NOT NULL OR NEW.REMARK IS NOT NULL) THEN
- IF NEW.REMARK IS NULL THEN
+ IF NEW.REMARK IS NULL OR LENGTH(NEW.REMARK) = 0 THEN
updateAction := ''delete'';
- END IF;
- IF OLD.REMARK IS NULL THEN
+ ELSIF OLD.REMARK IS NULL OR LENGTH(OLD.REMARK) = 0 THEN
updateAction := ''insert'';
- END IF;
- IF OLD.REMARK != NEW.REMARK THEN
+ ELSIF OLD.REMARK != NEW.REMARK THEN
updateAction := ''rebuild'';
END IF;
END IF;
- END IF;
+ END IF;
IF (TG_OP=''DELETE'' OR updateAction = ''delete'' OR updateAction = ''rebuild'') THEN
DELETE FROM BIN_OBJ_SEARCH_TAB WHERE BIN_OBJ_ID = OLD.BIN_OBJ_ID;
RETURN OLD;
@@ -254,11 +252,11 @@
remarkString := RTRIM(remarkString, '';'');
remarkString := remarkString || '';'';
WHILE (LENGTH(remarkString) > 0) LOOP
- separatorPos := INSTR (remarkString, '';'');
+ separatorPos := strpos(remarkString, '';'');
INSERT INTO BIN_OBJ_SEARCH_TAB
(BIN_OBJ_ID, KEY_WORD)
- VALUES (NEW.BIN_OBJ_ID, SUBSTR(remarkString, 1, separatorPos-1));
- remarkString := SUBSTR (remarkString, separatorPos,
+ VALUES (NEW.BIN_OBJ_ID, substr(remarkString, 1, separatorPos - 1));
+ remarkString := substr(remarkString, separatorPos,
LENGTH (remarkString) - separatorPos + 1);
remarkString := LTRIM (remarkString, '';'');
END LOOP;
@@ -380,7 +378,7 @@
-- Name: "catch_procf" () Type: FUNCTION Owner: greater
--
-CREATE FUNCTION "catch_procf" () RETURNS opaque AS '
+CREATE FUNCTION "catch_procf" () RETURNS TRIGGER AS '
BEGIN
IF TG_OP=''UPDATE'' THEN
IF OLD.CATCH_ID != NEW.CATCH_ID THEN
@@ -684,7 +682,7 @@
-- Name: "res_procf" () Type: FUNCTION Owner: greater
--
-CREATE FUNCTION "res_procf" () RETURNS opaque AS '
+CREATE FUNCTION "res_procf" () RETURNS TRIGGER AS '
BEGIN
IF TG_OP=''UPDATE'' THEN
IF OLD.RES_ID != NEW.RES_ID THEN
More information about the Greater-commits
mailing list