CREATE CAST question
От | Robert Wimmer |
---|---|
Тема | CREATE CAST question |
Дата | |
Msg-id | BAY12-F131753E9B50F8831E4ECF2D0C70@phx.gbl обсуждение исходный текст |
Ответы |
Re: CREATE CAST question
|
Список | pgsql-novice |
I have the following problem I want to define a schema qualified domain and create a cast to cast a string in the new domain. This is what i did. *** CREATE DOMAIN tree.ident AS TEXT; CREATE OR REPLACE FUNCTION tree.ident_cast(TEXT) RETURNS tree.ident AS ' DECLARE regex TEXT; ret TEXT; l1 INT; l2 INT; BEGIN regex := ''^[a-zA-Z0-9][^/%_]*''; ret := SUBSTRING($1 FROM regex); l1 := LENGTH($1); l2 := LENGTH(ret); IF l1 <> l2 THEN RAISE EXCEPTION ''syntax error in "%" at % (%) '',$1,l2,ret; END IF; RETURN $1; END; ' LANGUAGE plpgsql; CREATE CAST (TEXT AS tree.ident) WITH FUNCTION tree.ident_cast(TEXT) AS IMPLICIT; *** the cast function works as expected ... tree_cal=# SELECT tree.ident_cast('path/node'); ERROR: syntax error in "path/node" at 9 (path) but if i do the following no error will occur tree_cal=# SELECT CAST('path/node' AS tree.ident); path/node this looks like as if the cast function never whas used ... what do i have to do that the cast function is called during the cast ? regards i am using postgre 7.4 on debian _________________________________________________________________ Behalten Sie Ihre Hotmails, den Messenger und die Suchfunktionen stets im Auge! http://toolbar.msn.at?DI=43&XAPID=2170
В списке pgsql-novice по дате отправления: