471,050 Members | 1,433 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,050 software developers and data experts.

code in docs gives me an error

Hi
I tried creating the function (from sec 19.3.1). But it gives me the
following error: "ERROR: type tablename does not exist".
Any ideas of what i might be doing wrong?

CREATE FUNCTION use_many_fields(tablename) RETURNS TEXT AS '
DECLARE
in_t ALIAS FOR $1;
BEGIN
RETURN in_t.f1 || in_t.f3 || in_t.f5 || in_t.f7;
END;
' LANGUAGE 'plpgsql';


Thanks,
--Hicham

Nov 23 '05 #1
2 1468
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Hi,

On Tue, 19 Oct 2004, Hicham G. Elmongui wrote:
I tried creating the function (from sec 19.3.1). But it gives me the
following error: "ERROR: type tablename does not exist".
Any ideas of what i might be doing wrong?
You have to write the data type while defining the function parameters.
For example,

CREATE FUNCTION use_many_fields(varchar) RETURNS TEXT AS '

....and then declare it as you've done below:
DECLARE
in_t ALIAS FOR $1;


Regards,
- --
Devrim GUNDUZ
devrim~gunduz.org devrim.gunduz~linux.org.tr
http://www.tdmsoft.com
http://www.gunduz.org
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.1 (GNU/Linux)

iD8DBQFBdTIVtl86P3SPfQ4RAj5vAKC2ugU2wcXHDgMMybyMqm 14L4+9UwCfUd7m
7WQxt0yl0PHuezSucptNLtE=
=Z94K
-----END PGP SIGNATURE-----

---------------------------(end of broadcast)---------------------------
TIP 5: Have you checked our extensive FAQ?

http://www.postgresql.org/docs/faqs/FAQ.html

Nov 23 '05 #2
"Hicham G. Elmongui" <el******@cs.purdue.edu> writes:
I tried creating the function (from sec 19.3.1). But it gives me the
following error: "ERROR: type tablename does not exist".
Any ideas of what i might be doing wrong? CREATE FUNCTION use_many_fields(tablename) RETURNS TEXT AS '


The example assumes you already created a table or composite type named
tablename.

regards, tom lane

---------------------------(end of broadcast)---------------------------
TIP 6: Have you searched our list archives?

http://archives.postgresql.org

Nov 23 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

21 posts views Thread by Steven Bethard | last post: by
4 posts views Thread by Michele Simionato | last post: by
2 posts views Thread by New Guy | last post: by
1 post views Thread by Christopher.Becker | last post: by
232 posts views Thread by robert maas, see http://tinyurl.com/uh3t | last post: by
reply views Thread by leo001 | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.