Thread

  1. Re: [SQL] Typecasting within sql statement.

    Richard Lynch <lynch@lscorp.com> — 1998-07-03T19:11:05Z

    Try something like this:
    
    update myTable set field = 42::text::varchar;
    
    I think the int4 --> text converter is written, and text --> varchar is
    written, but int4 --> varchar is not.
    
    Basically, anytime you need to go from one type to another that doesn't
    seem to have a converter, look for a more general intermediate type.
    
    At least, that's my understanding after one fight with this. :-)
    
    --
    --
    -- "TANSTAAFL" Rich lynch@lscorp.com
    
    
    
    
  2. Re: [SQL] Typecasting within sql statement.

    Colin Dick <cdick@mail.ocis.net> — 1998-07-03T19:25:35Z

    > update myTable set field = 42::text::varchar;
    > 
    > I think the int4 --> text converter is written, and text --> varchar is
    > written, but int4 --> varchar is not.
    
    Well,
    	It seems you understand what I am looking for but this did not
    work.  I get an error of:
    
    WARN:parser: parse error at or near "::"
    
    Do you think my fastest solution would be to write a func (inttochar)
    which accepts and int and returns a char.  Should only take a minute.  I
    think that is what I will do.  Thanks for your help.
    
    If anyone else knows an easier solution, let me know and I will dump my
    function.  Have a good weekend.
    
    --
    Colin Dick
    On Call Internet Services
    cdick@mail.ocis.net