Re: [GENERAL] Automatic truncation of character values casting to the type of a column type

2009-12-17 Thread Justin Bailey
On Wed, Dec 16, 2009 at 7:20 PM, Tom Lane t...@sss.pgh.pa.us wrote: Really?  Works for me, in everything back to 7.3. I must be missing something, because this function fails: CREATE OR REPLACE FUNCTION insertShort() RETURNS VOID AS $BODY$ DECLARE s Short.shortCol%TYPE; BEGIN

Re: [GENERAL] Automatic truncation of character values casting to the type of a column type

2009-12-17 Thread Tom Lane
Justin Bailey jgbai...@gmail.com writes: On Wed, Dec 16, 2009 at 7:20 PM, Tom Lane t...@sss.pgh.pa.us wrote: Really?  Works for me, in everything back to 7.3. If s was automatically truncated, the insert would succeed, but it fails with a value too long error. Oh, I thought the failure was

Re: [GENERAL] Automatic truncation of character values casting to the type of a column type

2009-12-17 Thread Sam Mason
On Thu, Dec 17, 2009 at 10:24:28AM -0500, Tom Lane wrote: Justin Bailey jgbai...@gmail.com writes: If s was automatically truncated, the insert would succeed, but it fails with a value too long error. Oh, I thought the failure was the behavior you wanted. There's no automatic truncation

Re: [GENERAL] Automatic truncation of character values casting to the type of a column type

2009-12-17 Thread Adrian Klaver
On Wednesday 16 December 2009 5:05:19 pm Justin Bailey wrote: Greetings! I am trying to avoid the old problem of inserting a 40 character string into a 20 character field. However, I'd like to avoid hard-coding the acceptable length (20). Is there a way to say cast to the same type as a given

[GENERAL] Automatic truncation of character values casting to the type of a column type

2009-12-16 Thread Justin Bailey
Greetings! I am trying to avoid the old problem of inserting a 40 character string into a 20 character field. However, I'd like to avoid hard-coding the acceptable length (20). Is there a way to say cast to the same type as a given column? E.g., if I have tables Long and Short: CREATE TABLE

[GENERAL] Automatic truncation of character values casting to the type of a column type

2009-12-16 Thread Justin Bailey
Greetings! I am trying to avoid the old problem of inserting a 40 character string into a 20 character field. However, I'd like to avoid hard-coding the acceptable length (20). Is there a way to say cast to the same type as a given column? E.g., if I have tables Long and Short:  CREATE TABLE Long

Re: [GENERAL] Automatic truncation of character values casting to the type of a column type

2009-12-16 Thread Tom Lane
Justin Bailey jgbai...@gmail.com writes: I have tried using the PL/PGSQL feature where types can be copied in a declaration: DECLARE myVal Short.shortCol%TYPE; But I can still put values which are too long into that variable, so it doesn't help me. Really? Works for me, in