[SQL] record type
Or maybe anyone knows how to work with record types ? How to insert something like ('1','2','3') into a table, or split it ? Anything ? regards mk
Re: [SQL] record type
2008/7/10 Marcin Krawczyk [EMAIL PROTECTED]: Hi. I need to know whether it's possible for a plpgsql function to accept record type parameters ? Is there a way to accomplish that ? I need to use something like ('1','2','3') as a parameter. regards mk All about record type http://www.postgresql.org/docs/8.3/interactive/plpgsql-declarations.html#PLPGSQL-DECLARATION-RECORDS section 38.3.4 but, try this ;-) merlin=# create table your_table(col1 int, col2 varchar(12), col3 int); CREATE TABLE merlin=# create or replace function test_1(val_of your_table) returns void as $$ declare begin insert into your_table values(val_of.col1, val_of.col2, val_of.col3); end; $$ LANGUAGE plpgsql; CREATE FUNCTION CREATE FUNCTION merlin=# select test_1((1,'test',2)); test_1 (1 row) merlin=# select * from your_table ; col1 | col2 | col3 --+--+-- 1 | test |2 (1 row) Time: 0.380 ms -- -- Serdecznie pozdrawiam Pawel Socha [EMAIL PROTECTED] programista/administrator perl -le 's**02).4^-%2,).^9%4^!./4(%2^3,!#+7!2%^53%2**y% -;^[%`-{ a%%s%%$_%ee'
Re: [SQL] record type
Nice thanks a lot. Niezłe, dzieki. regards pozdrowienia mk 2008/7/11 Pawel Socha [EMAIL PROTECTED]: 2008/7/10 Marcin Krawczyk [EMAIL PROTECTED]: Hi. I need to know whether it's possible for a plpgsql function to accept record type parameters ? Is there a way to accomplish that ? I need to use something like ('1','2','3') as a parameter. regards mk All about record type http://www.postgresql.org/docs/8.3/interactive/plpgsql-declarations.html#PLPGSQL-DECLARATION-RECORDS section 38.3.4 but, try this ;-) merlin=# create table your_table(col1 int, col2 varchar(12), col3 int); CREATE TABLE merlin=# create or replace function test_1(val_of your_table) returns void as $$ declare begin insert into your_table values(val_of.col1, val_of.col2, val_of.col3); end; $$ LANGUAGE plpgsql; CREATE FUNCTION CREATE FUNCTION merlin=# select test_1((1,'test',2)); test_1 (1 row) merlin=# select * from your_table ; col1 | col2 | col3 --+--+-- 1 | test |2 (1 row) Time: 0.380 ms -- -- Serdecznie pozdrawiam Pawel Socha [EMAIL PROTECTED] programista/administrator perl -le 's**02).4^-%2,).^9%4^!./4(%2^3,!#+7!2%^53%2**y% -;^[%`-{ a%%s%%$_%ee'
[SQL] record type
Hi. I need to know whether it's possible for a plpgsql function to accept record type parameters ? Is there a way to accomplish that ? I need to use something like ('1','2','3') as a parameter. regards mk
[SQL] Record type in sql
Hello, I have a little problem I want to declare a type record for later use like that create type record_structure1 as (id int2, nume text); that is ok! next in a function I want to use something like that: select * from table as record_structure1 ? instead of writing select * from table as t1(id int2, nume text); is this possible? Thank You, Adrian Din -- Using Opera's revolutionary e-mail client: http://www.opera.com/m2/ ---(end of broadcast)--- TIP 9: the planner will ignore your desire to choose an index scan if your joining column's datatypes do not match
Re: [SQL] Record type in sql
Yo can do s.t. similar, if the order in which you select the columns corresponds to the order your type is defined. So you'd gonna use: select intcol, textcol from table; -Original Message- From: Din Adrian [mailto:[EMAIL PROTECTED] Sent: Montag, 17. Jänner 2005 13:31 To: pgsql-sql@postgresql.org Subject: [SQL] Record type in sql Hello, I have a little problem I want to declare a type record for later use like that create type record_structure1 as (id int2, nume text); that is ok! next in a function I want to use something like that: select * from table as record_structure1 ? instead of writing select * from table as t1(id int2, nume text); is this possible? Thank You, Adrian Din -- Using Opera's revolutionary e-mail client: http://www.opera.com/m2/ ---(end of broadcast)--- TIP 9: the planner will ignore your desire to choose an index scan if your joining column's datatypes do not match ---(end of broadcast)--- TIP 6: Have you searched our list archives? http://archives.postgresql.org