Thread: Completely transparent casts

Completely transparent casts

From
Joachim Zobel
Date:
Hi.

I have a
CREATE TYPE ccnumber AS (
  length    SMALLINT,
  tail      VARCHAR(4),
  encrypt   TEXT
);
for credit card number storage. I would like this to be completely
transparent. However I can not get it to be a drop in replacement for a
text type, no matter what casts I create. I always have to do something
like

CREATE TABLE cc_test (
  test  ccnumber
);

INSERT INTO cc_test(test) VALUES (to_ccnumber('1234567890128'));

SELECT ''||test, test FROM cc_test;

Is there a trick I did not find yet?

Sincerely,
Joachim

--
"... ein Geschlecht erfinderischer Zwerge, die fuer alles gemietet werden
koennen."                            - Bertolt Brecht - Leben des Galilei