X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 864283A5D6A for ; Sun, 5 Dec 2004 04:14:18 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 67773-05 for ; Sun, 5 Dec 2004 04:14:09 +0000 (GMT) Received: from guinness.cs.stevens.edu (guinness.cs.stevens-tech.edu [155.246.89.8]) by svr1.postgresql.org (Postfix) with ESMTP id 62F5D3A5D55 for ; Sun, 5 Dec 2004 04:13:53 +0000 (GMT) Received: from dab.cs.stevens.edu (dab.cs.stevens-tech.edu [155.246.89.71]) by guinness.cs.stevens.edu (Postfix) with ESMTP id 5E8A0141649 for ; Sat, 4 Dec 2004 23:16:24 -0500 (EST) Received: by dab.cs.stevens.edu (Postfix, from userid 4405) id E69FC1CD814; Sat, 4 Dec 2004 23:13:29 -0500 (EST) Received: from localhost (localhost [127.0.0.1]) by dab.cs.stevens.edu (Postfix) with ESMTP id BA44E1BBC90 for ; Sat, 4 Dec 2004 23:13:29 -0500 (EST) Date: Sat, 4 Dec 2004 23:13:29 -0500 (EST) From: Yasir Malik To: PostgreSQL Subject: Re: inserting values into types In-Reply-To: <20041201234311.L622@hermes.hilbert.loc> Message-ID: References: <20041201215811.476CF23CE8@ws5-3.us4.outblaze.com> <20041201234311.L622@hermes.hilbert.loc> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.05 tagged_above=0 required=5 tests=FORGED_RCVD_HELO X-Spam-Level: X-Archive-Number: 200412/36 X-Sequence-Number: 19656 >> 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