dbTalk Databases Forums  

Possible: using ordinal number instead of column name

comp.databases.postgresql comp.databases.postgresql


Discuss Possible: using ordinal number instead of column name in the comp.databases.postgresql forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Anton Huber
 
Posts: n/a

Default Possible: using ordinal number instead of column name - 04-26-2008 , 04:12 PM






Hi there,

to have it easier using one trigger doing similar things on different
tables I was wondering if it would be possible to use the ordinal # of
a column instead of using the column name.

Means:

CREATE TABLE test (
id serial NOT NULL,
ref_id integer,
payload character varying(100),
PRIMARY KEY (id)
);

SELECT id, ref_id, payload FROM test;
in 'trigger words': NEW.id, NEW.ref_id, NEW.payload

instead doing something like:

SELECT 1, 2, 3 FROM test;
in 'trigger words': NEW.1, NEW.2, NEW.3

Concerning the SELECT statement I get results I am expecting ;-) but
not what I want ...


Thanks a lot!


Regards,
Anton

--
Aber wieso? Gestern ging's doch noch!

Reply With Quote
  #2  
Old   
HansH
 
Posts: n/a

Default Re: Possible: using ordinal number instead of column name - 04-27-2008 , 06:20 AM






"Anton Huber" <hoover (AT) gmx (DOT) at> schreef in bericht
news:7g5714pfbg7saac0gqqt2ghls5mjnukll4 (AT) 4ax (DOT) com...
Quote:
Hi there,

to have it easier using one trigger doing similar things on different
tables I was wondering if it would be possible to use the ordinal # of
a column instead of using the column name.

Reading the above I just wonder:
- how to preserve the ordinal number during backup-and-restore
- what are the effects of ALTER [ COLUMN ] column TYPE type [ USING
expression ]
- are these numbers reassigned after dropping a column

HansH




Reply With Quote
  #3  
Old   
HansH
 
Posts: n/a

Default Re: Possible: using ordinal number instead of column name - 04-27-2008 , 06:20 AM



"Anton Huber" <hoover (AT) gmx (DOT) at> schreef in bericht
news:7g5714pfbg7saac0gqqt2ghls5mjnukll4 (AT) 4ax (DOT) com...
Quote:
Hi there,

to have it easier using one trigger doing similar things on different
tables I was wondering if it would be possible to use the ordinal # of
a column instead of using the column name.

Reading the above I just wonder:
- how to preserve the ordinal number during backup-and-restore
- what are the effects of ALTER [ COLUMN ] column TYPE type [ USING
expression ]
- are these numbers reassigned after dropping a column

HansH




Reply With Quote
  #4  
Old   
HansH
 
Posts: n/a

Default Re: Possible: using ordinal number instead of column name - 04-27-2008 , 06:20 AM



"Anton Huber" <hoover (AT) gmx (DOT) at> schreef in bericht
news:7g5714pfbg7saac0gqqt2ghls5mjnukll4 (AT) 4ax (DOT) com...
Quote:
Hi there,

to have it easier using one trigger doing similar things on different
tables I was wondering if it would be possible to use the ordinal # of
a column instead of using the column name.

Reading the above I just wonder:
- how to preserve the ordinal number during backup-and-restore
- what are the effects of ALTER [ COLUMN ] column TYPE type [ USING
expression ]
- are these numbers reassigned after dropping a column

HansH




Reply With Quote
  #5  
Old   
HansH
 
Posts: n/a

Default Re: Possible: using ordinal number instead of column name - 04-27-2008 , 06:20 AM



"Anton Huber" <hoover (AT) gmx (DOT) at> schreef in bericht
news:7g5714pfbg7saac0gqqt2ghls5mjnukll4 (AT) 4ax (DOT) com...
Quote:
Hi there,

to have it easier using one trigger doing similar things on different
tables I was wondering if it would be possible to use the ordinal # of
a column instead of using the column name.

Reading the above I just wonder:
- how to preserve the ordinal number during backup-and-restore
- what are the effects of ALTER [ COLUMN ] column TYPE type [ USING
expression ]
- are these numbers reassigned after dropping a column

HansH




Reply With Quote
  #6  
Old   
HansH
 
Posts: n/a

Default Re: Possible: using ordinal number instead of column name - 04-27-2008 , 06:20 AM



"Anton Huber" <hoover (AT) gmx (DOT) at> schreef in bericht
news:7g5714pfbg7saac0gqqt2ghls5mjnukll4 (AT) 4ax (DOT) com...
Quote:
Hi there,

to have it easier using one trigger doing similar things on different
tables I was wondering if it would be possible to use the ordinal # of
a column instead of using the column name.

Reading the above I just wonder:
- how to preserve the ordinal number during backup-and-restore
- what are the effects of ALTER [ COLUMN ] column TYPE type [ USING
expression ]
- are these numbers reassigned after dropping a column

HansH




Reply With Quote
  #7  
Old   
HansH
 
Posts: n/a

Default Re: Possible: using ordinal number instead of column name - 04-27-2008 , 06:20 AM



"Anton Huber" <hoover (AT) gmx (DOT) at> schreef in bericht
news:7g5714pfbg7saac0gqqt2ghls5mjnukll4 (AT) 4ax (DOT) com...
Quote:
Hi there,

to have it easier using one trigger doing similar things on different
tables I was wondering if it would be possible to use the ordinal # of
a column instead of using the column name.

Reading the above I just wonder:
- how to preserve the ordinal number during backup-and-restore
- what are the effects of ALTER [ COLUMN ] column TYPE type [ USING
expression ]
- are these numbers reassigned after dropping a column

HansH




Reply With Quote
  #8  
Old   
HansH
 
Posts: n/a

Default Re: Possible: using ordinal number instead of column name - 04-27-2008 , 06:20 AM



"Anton Huber" <hoover (AT) gmx (DOT) at> schreef in bericht
news:7g5714pfbg7saac0gqqt2ghls5mjnukll4 (AT) 4ax (DOT) com...
Quote:
Hi there,

to have it easier using one trigger doing similar things on different
tables I was wondering if it would be possible to use the ordinal # of
a column instead of using the column name.

Reading the above I just wonder:
- how to preserve the ordinal number during backup-and-restore
- what are the effects of ALTER [ COLUMN ] column TYPE type [ USING
expression ]
- are these numbers reassigned after dropping a column

HansH




Reply With Quote
  #9  
Old   
HansH
 
Posts: n/a

Default Re: Possible: using ordinal number instead of column name - 04-27-2008 , 06:20 AM



"Anton Huber" <hoover (AT) gmx (DOT) at> schreef in bericht
news:7g5714pfbg7saac0gqqt2ghls5mjnukll4 (AT) 4ax (DOT) com...
Quote:
Hi there,

to have it easier using one trigger doing similar things on different
tables I was wondering if it would be possible to use the ordinal # of
a column instead of using the column name.

Reading the above I just wonder:
- how to preserve the ordinal number during backup-and-restore
- what are the effects of ALTER [ COLUMN ] column TYPE type [ USING
expression ]
- are these numbers reassigned after dropping a column

HansH




Reply With Quote
  #10  
Old   
Laurenz Albe
 
Posts: n/a

Default Re: Possible: using ordinal number instead of column name - 04-28-2008 , 02:40 AM



Anton Huber <hoover (AT) gmx (DOT) at> wrote:
Quote:
to have it easier using one trigger doing similar things on different
tables I was wondering if it would be possible to use the ordinal # of
a column instead of using the column name.
This kind of thing will not be possible with PL/pgSQL, as far as I know.

You could write your trigger in PL/Perl
http://www.postgresql.org/docs/curre...-triggers.html

You might be able to do more there.

Yours,
Laurenz Albe


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.