pg.ddx.io pgsql-sql@postgresql.org mailing list archive
help / color / mirror / Atom feedinserting values into types
8+ messages / 5 participants
[nested] [flat]
* inserting values into types
@ 2004-11-30 23:51 Andrew Thorley <andrew.thorley@linuxmail.org>
0 siblings, 1 reply; 8+ messages in thread
From: Andrew Thorley @ 2004-11-30 23:51 UTC (permalink / raw)
To: pgsql-sql
Hi,
ive generated a user defined type: CREATE TYPE qwerty_UDT AS (abc INT);
& table as: CREATE TABLE t (col1 qwerty_UDT);
my prob is that when i try to insert into the type i.e: INSERT INTO t (col1) Values (qwerty_UDT(123));
i get the error:
ERROR: function test_x(integer) does not exist
HINT: No function matches the given name and argument types. You may need to add explicit type casts.
which is quite confusing, does anyone have any ideas or exp with this scenario, or offer help in any way?
ty in advance :)
--
______________________________________________
Check out the latest SMS services @ http://www.linuxmail.org
This allows you to send and receive SMS through your mailbox.
Powered by Outblaze
^ permalink raw reply [nested|flat] 8+ messages in thread
* Re: inserting values into types
@ 2004-12-01 00:17 Michael Fuhr <mike@fuhr.org>
parent: Andrew Thorley <andrew.thorley@linuxmail.org>
0 siblings, 0 replies; 8+ messages in thread
From: Michael Fuhr @ 2004-12-01 00:17 UTC (permalink / raw)
To: Andrew Thorley <andrew.thorley@linuxmail.org>; +Cc: pgsql-sql
On Wed, Dec 01, 2004 at 07:51:17AM +0800, Andrew Thorley wrote:
> ive generated a user defined type: CREATE TYPE qwerty_UDT AS (abc INT);
>
> & table as: CREATE TABLE t (col1 qwerty_UDT);
Are you using 8.0? I don't think earlier versions allowed this.
> my prob is that when i try to insert into the type i.e: INSERT INTO t (col1) Values (qwerty_UDT(123));
>
> i get the error:
>
> ERROR: function test_x(integer) does not exist
This error doesn't agree with the INSERT statement you gave -- it
should say "function qwerty_udt(integer) does not exist". Where
does test_x() come from? Did you type the SQL statements and/or
error messages instead of cutting and pasting? We can see what's
happening, but it's better to paste the exact statements and output
to avoid mistakes.
> HINT: No function matches the given name and argument types. You may need to add explicit type casts.
See the "Composite Types" documentation -- it has a section entitled
"Composite Value Input":
http://developer.postgresql.org/docs/postgres/rowtypes.html
--
Michael Fuhr
http://www.fuhr.org/~mfuhr/
^ permalink raw reply [nested|flat] 8+ messages in thread
* Re: inserting values into types
@ 2004-12-01 17:53 Michael Fuhr <mike@fuhr.org>
0 siblings, 0 replies; 8+ messages in thread
From: Michael Fuhr @ 2004-12-01 17:53 UTC (permalink / raw)
To: Andrew Thorley <andrew.thorley@linuxmail.org>; +Cc: pgsql-sql
On Wed, Dec 01, 2004 at 06:07:34PM +0800, Andrew Thorley wrote:
> > Did you type the SQL statements and/or error messages instead
> > of cutting and pasting?
>
> yes i C&P'ed the SQL code & error code.
But did you copy the error message associated with the SQL code you
copied, or did you copy some other error message? I ask because
the function name in the error doesn't match the function name in
the INSERT statement. Here's what I get when I execute the statements
in your message:
test=> CREATE TYPE qwerty_UDT AS (abc INT);
CREATE TYPE
test=> CREATE TABLE t (col1 qwerty_UDT);
CREATE TABLE
test=> INSERT INTO t (col1) Values (qwerty_UDT(123));
ERROR: function qwerty_udt(integer) does not exist
You said the error you got was:
ERROR: function test_x(integer) does not exist
The error is the same but the detail differs: your error refers
to test_x(integer) instead of qwerty_udt(integer). So where is
test_x coming from?
--
Michael Fuhr
http://www.fuhr.org/~mfuhr/
^ permalink raw reply [nested|flat] 8+ messages in thread
* Re: inserting values into types
@ 2004-12-01 21:58 Andrew Thorley <andrew.thorley@linuxmail.org>
0 siblings, 2 replies; 8+ messages in thread
From: Andrew Thorley @ 2004-12-01 21:58 UTC (permalink / raw)
To: Michael Fuhr <mike@fuhr.org>; +Cc: pgsql-sql
hi mike,
sorry for confusion, the test_x is my mistake, its from another type i created which is executing the same code.
my error i get from:
CREATE TYPE qwerty_UDT AS (abc INT);
CREATE TABLE t (col1 qwerty_UDT);
INSERT INTO t (col1) VALUES (qwerty_UDT(123));
is:
ERROR: function qwerty_udt(integer) does not exist
HINT: No function matches the given name and argument types. You may need to add explicit type casts.
----- Original Message -----
From: "Michael Fuhr" <mike@fuhr.org>
To: "Andrew Thorley" <andrew.thorley@linuxmail.org>
Subject: Re: [SQL] inserting values into types
Date: Wed, 1 Dec 2004 10:53:01 -0700
>
> On Wed, Dec 01, 2004 at 06:07:34PM +0800, Andrew Thorley wrote:
>
> > > Did you type the SQL statements and/or error messages instead
> > > of cutting and pasting?
> >
> > yes i C&P'ed the SQL code & error code.
>
> But did you copy the error message associated with the SQL code you
> copied, or did you copy some other error message? I ask because
> the function name in the error doesn't match the function name in
> the INSERT statement. Here's what I get when I execute the statements
> in your message:
>
> test=> CREATE TYPE qwerty_UDT AS (abc INT);
> CREATE TYPE
> test=> CREATE TABLE t (col1 qwerty_UDT);
> CREATE TABLE
> test=> INSERT INTO t (col1) Values (qwerty_UDT(123));
> ERROR: function qwerty_udt(integer) does not exist
>
> You said the error you got was:
>
> ERROR: function test_x(integer) does not exist
>
> The error is the same but the detail differs: your error refers
> to test_x(integer) instead of qwerty_udt(integer). So where is
> test_x coming from?
>
> --
> Michael Fuhr
> http://www.fuhr.org/~mfuhr/
--
______________________________________________
Check out the latest SMS services @ http://www.linuxmail.org
This allows you to send and receive SMS through your mailbox.
Powered by Outblaze
^ permalink raw reply [nested|flat] 8+ messages in thread
* Re: inserting values into types
@ 2004-12-01 22:11 Tom Lane <tgl@sss.pgh.pa.us>
parent: Andrew Thorley <andrew.thorley@linuxmail.org>
1 sibling, 0 replies; 8+ messages in thread
From: Tom Lane @ 2004-12-01 22:11 UTC (permalink / raw)
To: Andrew Thorley <andrew.thorley@linuxmail.org>; +Cc: Michael Fuhr <mike@fuhr.org>; pgsql-sql
"Andrew Thorley" <andrew.thorley@linuxmail.org> writes:
> CREATE TYPE qwerty_UDT AS (abc INT);
> CREATE TABLE t (col1 qwerty_UDT);
> INSERT INTO t (col1) VALUES (qwerty_UDT(123));
> ERROR: function qwerty_udt(integer) does not exist
Just say
INSERT INTO t (col1) VALUES (ROW(123));
Note this will not work at all on pre-8.0 Postgres.
regards, tom lane
^ permalink raw reply [nested|flat] 8+ messages in thread
* Re: inserting values into types
@ 2004-12-01 22:43 Karsten Hilbert <Karsten.Hilbert@gmx.net>
parent: Andrew Thorley <andrew.thorley@linuxmail.org>
1 sibling, 1 reply; 8+ messages in thread
From: Karsten Hilbert @ 2004-12-01 22:43 UTC (permalink / raw)
To: pgsql-sql
> CREATE TYPE qwerty_UDT AS (abc INT);
>
> CREATE TABLE t (col1 qwerty_UDT);
>
> INSERT INTO t (col1) VALUES (qwerty_UDT(123));
>
> ERROR: function qwerty_udt(integer) does not exist
> HINT: No function matches the given name and argument types. You may need to add explicit type casts.
Well, doesn't the error message say it ? "function ... does
not exist". The question would be why are you doing
"qwerty_UDT(123)" in the first place ? It seems you'd
want to be casting ? PostgreSQL, in any case, thinks you want
to call a function qwerty_UDT(integer) which it can't find.
Karsten
--
GPG key ID E4071346 @ wwwkeys.pgp.net
E167 67FD A291 2BEA 73BD 4537 78B9 A9F9 E407 1346
^ permalink raw reply [nested|flat] 8+ messages in thread
* Re: inserting values into types
@ 2004-12-05 04:13 Yasir Malik <ymalik@cs.stevens-tech.edu>
parent: Karsten Hilbert <Karsten.Hilbert@gmx.net>
0 siblings, 1 reply; 8+ messages in thread
From: Yasir Malik @ 2004-12-05 04:13 UTC (permalink / raw)
To: pgsql-sql
>> CREATE TYPE qwerty_UDT AS (abc INT);
>>
>> CREATE TABLE t (col1 qwerty_UDT);
>>
>> INSERT INTO t (col1) VALUES (qwerty_UDT(123));
>>
>> ERROR: function qwerty_udt(integer) does not exist
>> HINT: No function matches the given name and argument types. You may need to add explicit type casts.
It seems as though you want to create your own user-defined types. That
isn't easy in PostgreSQL. You have to create an external C struct and
write a function to convert a PostgreSQL string to a C struct and return
it to the database (called an input function), and create another function
that takes an object from the database and returns a string to the
database in order to print out the object (called an output function).
The only thing PostgreSQL knows about the object is size of the object and
the input and output functions. You also need to be the database
administrator. Go here for more information:
http://www.postgresql.org/docs/current/static/xtypes.html
I had to create an object-oriented database for one of my classes, and
although I wanted to use PostgreSQL, I didn't want to deal with so low
level stuff. Oracle is much better for object-oriented features.
Regards,
Yasir
^ permalink raw reply [nested|flat] 8+ messages in thread
* Re: inserting values into types
@ 2004-12-06 04:03 Michael Fuhr <mike@fuhr.org>
parent: Yasir Malik <ymalik@cs.stevens-tech.edu>
0 siblings, 0 replies; 8+ messages in thread
From: Michael Fuhr @ 2004-12-06 04:03 UTC (permalink / raw)
To: Yasir Malik <ymalik@cs.stevens-tech.edu>; +Cc: pgsql-sql
On Sat, Dec 04, 2004 at 11:13:29PM -0500, Yasir Malik wrote:
> >>CREATE TYPE qwerty_UDT AS (abc INT);
> >>
> >>CREATE TABLE t (col1 qwerty_UDT);
> >>
> >>INSERT INTO t (col1) VALUES (qwerty_UDT(123));
> >>
> >>ERROR: function qwerty_udt(integer) does not exist
> >>HINT: No function matches the given name and argument types. You may
> >>need to add explicit type casts.
>
> It seems as though you want to create your own user-defined types. That
> isn't easy in PostgreSQL.
That the CREATE TABLE statement succeeded implies that he's using
PostgreSQL 8.0, which has better support for composite types than
previous versions. What he's trying to do will work -- he just has
the syntax wrong.
http://developer.postgresql.org/docs/postgres/rowtypes.html
--
Michael Fuhr
http://www.fuhr.org/~mfuhr/
^ permalink raw reply [nested|flat] 8+ messages in thread
end of thread, other threads:[~2004-12-06 04:03 UTC | newest]
Thread overview: 8+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2004-11-30 23:51 inserting values into types Andrew Thorley <andrew.thorley@linuxmail.org>
2004-12-01 00:17 ` Michael Fuhr <mike@fuhr.org>
2004-12-01 17:53 Re: inserting values into types Michael Fuhr <mike@fuhr.org>
2004-12-01 21:58 Re: inserting values into types Andrew Thorley <andrew.thorley@linuxmail.org>
2004-12-01 22:11 ` Tom Lane <tgl@sss.pgh.pa.us>
2004-12-01 22:43 ` Karsten Hilbert <Karsten.Hilbert@gmx.net>
2004-12-05 04:13 ` Yasir Malik <ymalik@cs.stevens-tech.edu>
2004-12-06 04:03 ` Michael Fuhr <mike@fuhr.org>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox