Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- CREATE TYPE simnaobool AS ENUM ('Sim', 'Não'); -- (TRUE=Sim, FALSE=Não)
- CREATE TYPE simnaoint AS ENUM ('Sim', 'Não'); -- (1=Sim, 0=Não)
- CREATE OR REPLACE FUNCTION bool2simnao(boolean)
- RETURNS simnaobool AS $$
- BEGIN
- RETURN CASE WHEN $1 THEN 'Sim'::simnaobool ELSE 'Não'::simnaobool END;
- END;
- $$ LANGUAGE plpgsql IMMUTABLE;
- CREATE OR REPLACE FUNCTION int2simnao(integer)
- RETURNS simnaoint AS $$
- BEGIN
- RETURN CASE WHEN $1 = 1 THEN 'Sim'::simnaoint ELSE 'Inativo'::simnaoint END;
- END;
- $$ LANGUAGE plpgsql IMMUTABLE;
- CREATE CAST (boolean AS simnaobool) WITH FUNCTION bool2simnao(boolean) AS IMPLICIT;
- CREATE CAST (integer AS simnaoint) WITH FUNCTION int2simnao(integer) AS IMPLICIT;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement