pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Luiz K. Matsumura <luiz@planit.com.br>
To: pgsql-sql@postgresql.org
Subject: Re: Cast on character columns in views
Date: Tue, 04 Sep 2007 04:33:50 -0300
Message-ID: <46DD0A5E.9010400@planit.com.br> (raw)
In-Reply-To: <46DCFD6D.20803@planit.com.br>
References: <144384.86744.qm@web31802.mail.mud.yahoo.com>
	<46DCFD6D.20803@planit.com.br>



Luiz K. Matsumura wrote:
>
> Richard Broersma Jr wrote:
>> --- "Luiz K. Matsumura" <luiz@planit.com.br> wrote:
>>  
>>> CREATE VIEW view1( id, col1, type1, type2) AS
>>> SELECT table1.id,
>>>        table1.col1,
>>>        CAST( table2.type1 AS CHARACTER( 3 )),
>>>        NULL
>>> FROM   table1
>>> JOIN   table2 ON table2.fk_table1 = table1.id
>>> UNION ALL
>>> SELECT table1.id,
>>>        table1.col1,
>>>        CAST( NULL AS CHARACTER( 3 )),
>>>        table3.type2
>>> FROM   table1
>>> JOIN   table3 ON table3.fk_table1 = table1.id;
>>>     
>>
>> Would the above changes work?
>>
>> Regards,
>> Richard Broersma Jr.
>>
>>
>>   
> Hi Richard,
> Your changes works ! But now I know what mistake I did:
>
> The error is occurring because I'm doing a CREATE OR REPLACE VIEW 
> command.
> The command with null:character(3) works too.
> The error is because I create a view then try to change the definition 
> with the CREATE OR REPLACE VIEW command
> When I drop the view first , and then create again the view (in a 
> separated transaction), now the command works! (this is a bug?)
> I'm using a postgres 8.2.4 on Linux.
>
> Thanks a lot!
>
Ugh, I'm totally crazy with this views
I'm using pgadmin with postgres, when I  clink on "view the data of 
selected object" button all works fine.
But when I open a query tool window and do:

SELECT * FROM view1;

Now, again type1 column returns as bpchar.
But if I do:

SELECT type1 FROM view1;

Now, type1 column returns as character(3)

If I do

select id, col1, type1,type2  from view1;

Again type1 returns as bpchar. But if I do

select id, col1,type2, type1 from view1;

Now type1 return as character(3).



-- 
Luiz K. Matsumura
Plan IT Tecnologia Informática Ltda.




view thread (7+ messages)  latest in thread

Message-ID: <46DD0A5E.9010400@planit.com.br>
Permalink:  ../46DD0A5E.9010400@planit.com.br/
Also on:    postgresql.org/message-id/46DD0A5E.9010400@planit.com.br

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: luiz@planit.com.br
  Subject: Re: Cast on character columns in views
  In-Reply-To: <46DD0A5E.9010400@planit.com.br>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox