userdefined types

Started by Assad Jarrahianabout 20 years ago6 messagesgeneral
Jump to latest
#1Assad Jarrahian
jarraa@gmail.com

Hello,
So I have been reading over the web and it seems that one must
define two methods before declaring a type. But I seem to have done it
(CREATE TYPE) without creating any functions and it did not give me
an error. I tried to use

INSERT TABLENAME SET user-defined-column = ROW('val1' ,'va2' ...);

and it works. The only problem is when I have ROW( , ,
'values','morevalues', ,'evenmorevalues');

it does not like the commas one after the other (empty value) .... how
do I solve that .... or does this have something to do with those two
methods (in and out) that I overlooked.

any insight would be much appreciated.

-assad

#2Tom Lane
tgl@sss.pgh.pa.us
In reply to: Assad Jarrahian (#1)
Re: userdefined types

Assad Jarrahian <jarraa@gmail.com> writes:

it does not like the commas one after the other (empty value) .... how
do I solve that .... or does this have something to do with those two
methods (in and out) that I overlooked.

any insight would be much appreciated.

You have not given us nearly enough information. "It does not like"
is not adequate: show the *exact* error message. (Even if the details
mean nothing to you, they might mean something to other people.)

Given the context, I suspect there's something wrong with your C code
and you'll have to show us the code to get any useful help. But I am
just speculating on the basis of no evidence whatsoever ...

regards, tom lane

#3Assad Jarrahian
jarraa@gmail.com
In reply to: Tom Lane (#2)
Re: userdefined types

C code (I am confused, are you talking about c-functions and types,
cause I don't have any!)

all I have is listed below (with the last query not working)
So getting back to user-defined types, is it REALLY necessary to have
the in-out functions (just to note, I am using jdbc with the db)

Thanks!
-assad

CREATE TYPE address AS
(bldgname varchar,
bldgzone varchar,
bldgfloor varchar,
bldgroom varchar,
street varchar,
crossing1 varchar,
crossing2 varchar,
city varchar,
state varchar,
zip varchar,
district varchar,
county varchar,
country varchar,
countrycode varchar,
phonenumber varchar,
ext varchar,
url varchar);

CREATE TABLE userprofiles
(
username varchar(32) NOT NULL,
address address,
CONSTRAINT table_profiles PRIMARY KEY (username)
)

UPDATE userprofiles SET address = ROW(''
,'','','','','','','','','','','','','','','','') where
username='mooreg3';

Query returned successfully: 1 rows affected, 156 ms execution time.

UPDATE userprofiles SET address = ROW(
,'','','',,'',,'','','','','','','','','','') where
username='mooreg3';

ERROR: syntax error at or near "," at character 41

Show quoted text

On 1/9/06, Tom Lane <tgl@sss.pgh.pa.us> wrote:

Assad Jarrahian <jarraa@gmail.com> writes:

it does not like the commas one after the other (empty value) .... how
do I solve that .... or does this have something to do with those two
methods (in and out) that I overlooked.

any insight would be much appreciated.

You have not given us nearly enough information. "It does not like"
is not adequate: show the *exact* error message. (Even if the details
mean nothing to you, they might mean something to other people.)

Given the context, I suspect there's something wrong with your C code
and you'll have to show us the code to get any useful help. But I am
just speculating on the basis of no evidence whatsoever ...

regards, tom lane

#4Tom Lane
tgl@sss.pgh.pa.us
In reply to: Assad Jarrahian (#3)
Re: userdefined types

Assad Jarrahian <jarraa@gmail.com> writes:

UPDATE userprofiles SET address = ROW(
,'','','',,'',,'','','','','','','','','','') where
username='mooreg3';

ERROR: syntax error at or near "," at character 41

That first comma is wrong, or else you forgot to put in a value
before it ...

regards, tom lane

#5Assad Jarrahian
jarraa@gmail.com
In reply to: Tom Lane (#4)
Re: userdefined types

Why is the first commaa wrong?
I guess thats my question

how do I set a value of a type to null?
I mean if type is made up of type a,b,c
how do I set them all at once, but having b to be null?

I thought using the ,, with nothing in between would do that I guess I
was wrong.
Any help would be much appreciated.
-assad

Show quoted text

On 1/9/06, Tom Lane <tgl@sss.pgh.pa.us> wrote:

Assad Jarrahian <jarraa@gmail.com> writes:

UPDATE userprofiles SET address = ROW(
,'','','',,'',,'','','','','','','','','','') where
username='mooreg3';

ERROR: syntax error at or near "," at character 41

That first comma is wrong, or else you forgot to put in a value
before it ...

regards, tom lane

#6Tino Wildenhain
tino@wildenhain.de
In reply to: Assad Jarrahian (#5)
Re: userdefined types

Assad Jarrahian schrieb:

Why is the first commaa wrong?
I guess thats my question

how do I set a value of a type to null?
I mean if type is made up of type a,b,c
how do I set them all at once, but having b to be null?

I thought using the ,, with nothing in between would do that I guess I
was wrong.
Any help would be much appreciated.
-assad

You write: null
e.g. (null,null,1,2,3,4) in your case.