Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Data Bases > Pgsql Novice > Inserting a rec...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 1 of 2 Topic 3076 of 3323
Post > Topic >>

Inserting a record returned from a function

by p9e883002@[EMAIL PROTECTED] Apr 16, 2008 at 08:46 AM

I have a function defined as:

CREATE OR REPLACE FUNCTION word_doc_from_raw(character varying, character 
varying, bytea)
RETURNS record AS
$BODY$

SELECT ROW(
id_from_word( $1 ),
id_from_doc_name( $2 ),
$3
)

$BODY$
LANGUAGE 'sql' STABLE;

And I'm trying to INSERT the returned record into a table defined as:

CREATE TABLE word_doc
(
word_id integer NOT NULL,
doc_id integer NOT NULL,
posns bytea,
CONSTRAINT word_doc_pkey PRIMARY KEY (word_id, doc_id),
CONSTRAINT word_doc_word_id_fkey FOREIGN KEY (word_id)
REFERENCES words (word_id) MATCH SIMPLE
ON UPDATE RESTRICT ON DELETE RESTRICT
)
WITHOUT OIDS;

with the statement:

insert into word_doc ( word_id, doc_id, posns )
values( (word_doc_from_raw( 'word', 'do***ent.name', 'some raw data' )).*
)

and getting the error:

ERROR: record type has not been registered
SQL state: 42809

Does this mean I must always define a type in order to do anything useful
with a 
record returned from a function?
I've seen references in the docs to "casting" and a syntax like:

ROW( ...)::tag

Is this useful in this situation?

Cheers, buk.





-- 
Sent via pgsql-novice mailing list (pgsql-novice@[EMAIL PROTECTED]
)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-novice
 




 2 Posts in Topic:
Inserting a record returned from a function
p9e883002@[EMAIL PROTECTE  2008-04-16 08:46:54 
Re: Inserting a record returned from a function
gbarosio@[EMAIL PROTECTED  2008-04-16 10:55:36 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Fri Dec 5 4:56:40 CST 2008.