470,614 Members | 1,458 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,614 developers. It's quick & easy.

CHAR vs TEXT args

I've created two PL/pgSQL functions with the same name and different
signatures:

CREATE FUNCTION ABC(CHAR) ...
CREATE FUNCTION ABC(TEXT) ....

I intended to call the CHAR-signature function like this:
SELECT ABC('R');

And the TEXT-signature function like this:
SELECT ABC('Right');

But I found that both calls invoke the TEXT-signature function. So is
there any distinction between CHAR and TEXT? Can I somehow specify
that the argument 'R' is to be treated as a CHAR, so the
CHAR-signature version of ABC is executed?

Thanks.
-David
Nov 11 '05 #1
2 1787
David Shadovitz wrote:
I intended to call the CHAR-signature function like this:
SELECT ABC('R');

And the TEXT-signature function like this:
SELECT ABC('Right');

But I found that both calls invoke the TEXT-signature function. So is
there any distinction between CHAR and TEXT? Can I somehow specify
that the argument 'R' is to be treated as a CHAR, so the
CHAR-signature version of ABC is executed?


If you want to force the CHAR version, do something like:
SELECT ABC('R'::char);

See:
http://www.postgresql.org/docs/view....TAX-TYPE-CASTS

HTH,

Joe
---------------------------(end of broadcast)---------------------------
TIP 7: don't forget to increase your free space map settings

Nov 11 '05 #2
Thanks, Joe and Dennis.

That double-colon type cast did the trick.

As an experienced software engineer, but a newcomer to PostgreSQL, I
appreciate the help.

-David
Nov 11 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

5 posts views Thread by jab3 | last post: by
2 posts views Thread by tmr_net | last post: by
3 posts views Thread by DG is a god.... | last post: by
9 posts views Thread by happyvalley | last post: by
Xx r3negade
3 posts views Thread by Xx r3negade | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.