Re: Converting to identity columns with domains on PK columns

2019-07-05 Thread Adrian Klaver
On 7/5/19 3:32 PM, Tom Lane wrote: Adrian Klaver writes: On 7/5/19 1:49 PM, PegoraroF10 wrote: Sorry, the example I was thinking was this one, which works on Firebird, using its way of writing, obviously. create function myproc(id integer) returns I32 language sql as 'select $1'; On postgres

Re: Converting to identity columns with domains on PK columns

2019-07-05 Thread Tom Lane
Adrian Klaver writes: > On 7/5/19 1:49 PM, PegoraroF10 wrote: >> Sorry, the example I was thinking was this one, which works on Firebird, >> using its way of writing, obviously. >> create function myproc(id integer) returns I32 language sql as 'select $1'; >> >> On postgres ERROR: return type mis

Re: Converting to identity columns with domains on PK columns

2019-07-05 Thread Adrian Klaver
On 7/5/19 1:55 PM, PegoraroF10 wrote: - Because we don´t need to give rigths to user on sequences; - Nobody will change values of pk fields, because we would like to have GENERATE ALWAYS on those PK Fields. An IDENTITY column is still backed by a sequence: create table identity_test(id integer

Re: Converting to identity columns with domains on PK columns

2019-07-05 Thread Adrian Klaver
On 7/5/19 1:49 PM, PegoraroF10 wrote: Sorry, the example I was thinking was this one, which works on Firebird, using its way of writing, obviously. create function myproc(id integer) returns I32 language sql as 'select $1'; On postgres ERROR: return type mismatch in function declared to return

Re: Converting to identity columns with domains on PK columns

2019-07-05 Thread PegoraroF10
- Because we don´t need to give rigths to user on sequences; - Nobody will change values of pk fields, because we would like to have GENERATE ALWAYS on those PK Fields. -- Sent from: http://www.postgresql-archive.org/PostgreSQL-general-f1843780.html

Re: Converting to identity columns with domains on PK columns

2019-07-05 Thread PegoraroF10
Sorry, the example I was thinking was this one, which works on Firebird, using its way of writing, obviously. create function myproc(id integer) returns I32 language sql as 'select $1'; On postgres ERROR: return type mismatch in function declared to return i32 What I mean is that Firebird sees I

Re: Converting to identity columns with domains on PK columns

2019-07-05 Thread Adrian Klaver
On 7/5/19 1:01 PM, PegoraroF10 wrote: Adrian, on Firebird if you create a table or procedure with fields or params declared with domains, they can be used with those domains or with their base type. On Postgres I32 is not equal to integer. create procedure myproc(id i32) returns(x i32) as ... s

Re: Converting to identity columns with domains on PK columns

2019-07-05 Thread Tom Lane
PegoraroF10 writes: > Adrian, on Firebird if you create a table or procedure with fields or params > declared with domains, they can be used with those domains or with their > base type. On Postgres I32 is not equal to integer. > create procedure myproc(id i32) returns(x i32) as ... > select *

Re: Converting to identity columns with domains on PK columns

2019-07-05 Thread PegoraroF10
Adrian, on Firebird if you create a table or procedure with fields or params declared with domains, they can be used with those domains or with their base type. On Postgres I32 is not equal to integer. create procedure myproc(id i32) returns(x i32) as ... select * from myproc(cast(5 as integer))

Re: Converting to identity columns with domains on PK columns

2019-07-05 Thread Adrian Klaver
On 7/5/19 4:38 AM, PegoraroF10 wrote: Well, I think it´ll not as easy as you said. That tables has dependencies. So, if I try to alter type it gives me ERROR: cannot alter type of a column used in a trigger definition. I dropped all Triggers of that table and it gives me ERROR: cannot alter type

Re: Converting to identity columns with domains on PK columns

2019-07-05 Thread PegoraroF10
Well, I think it´ll not as easy as you said. That tables has dependencies. So, if I try to alter type it gives me ERROR: cannot alter type of a column used in a trigger definition. I dropped all Triggers of that table and it gives me ERROR: cannot alter type of a column used by a view or rule. The

Re: Converting to identity columns with domains on PK columns

2019-07-05 Thread Laurenz Albe
PegoraroF10 wrote: > Domains on Postgres are really strange to me. Am I creating a domain which is > exactly equal to integer, right ? > > create domain i32 as integer; > create domain T50 as varchar(50); > > Create table MyTable( > ID I32 not null primary key, > Description T50); > > Then, afte

Re: Converting to identity columns with domains on PK columns

2019-07-04 Thread Adrian Klaver
On 7/4/19 1:27 PM, Adrian Klaver wrote: On 7/4/19 1:03 PM, PegoraroF10 wrote: ok, thanks for the explanation but ... I cannot add a field and move data, constraints, triggers, identity to it because my pk field will be repositioned to the last field on that table and I have lots of other codes

Re: Converting to identity columns with domains on PK columns

2019-07-04 Thread Adrian Klaver
On 7/4/19 1:27 PM, Adrian Klaver wrote: On 7/4/19 1:03 PM, PegoraroF10 wrote: ok, thanks for the explanation but ... I cannot add a field and move data, constraints, triggers, identity to it because my pk field will be repositioned to the last field on that table and I have lots of other codes

Re: Converting to identity columns with domains on PK columns

2019-07-04 Thread Adrian Klaver
On 7/4/19 1:03 PM, PegoraroF10 wrote: ok, thanks for the explanation but ... I cannot add a field and move data, constraints, triggers, identity to it because my pk field will be repositioned to the last field on that table and I have lots of other codes which point to pk as the first field on ev

Re: Converting to identity columns with domains on PK columns

2019-07-04 Thread PegoraroF10
ok, thanks for the explanation but ... I cannot add a field and move data, constraints, triggers, identity to it because my pk field will be repositioned to the last field on that table and I have lots of other codes which point to pk as the first field on every table. So, there is a way to conver

Re: Converting to identity columns with domains on PK columns

2019-07-04 Thread Adrian Klaver
On 7/4/19 12:41 PM, PegoraroF10 wrote: Domains on Postgres are really strange to me. Am I creating a domain which is exactly equal to integer, right ? create domain i32 as integer; create domain T50 as varchar(50); Create table MyTable( ID I32 not null primary key, Description T50); Then, afte