By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,710 Members | 1,970 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,710 IT Pros & Developers. It's quick & easy.

CHAR vs TEXT args

P: n/a
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
Share this Question
Share on Google+
2 Replies


P: n/a
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

P: n/a
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.