Skip site navigation (1) Skip section navigation (2)

Re: inserting values into types

From: Yasir Malik <ymalik(at)cs(dot)stevens-tech(dot)edu>
To: PostgreSQL <pgsql-sql(at)postgresql(dot)org>
Subject: Re: inserting values into types
Date: 2004-12-05 04:13:29
Message-ID: Pine.NEB.4.60.0412042310560.7853@dab.cs.stevens-tech.edu (view raw or flat)
Thread:
Lists: 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

In response to

Responses

pgsql-sql by date

Next:From: Ellert van KoperenDate: 2004-12-05 17:48:56
Subject: Making dirty reads possible?
Previous:From: Kretschmer AndreasDate: 2004-12-04 15:14:28
Subject: Re: sum query

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group