Re: now i'm really confused. insert/update does autocast, where sometimes. - Mailing list pgsql-general

From Daniel Schuchardt
Subject Re: now i'm really confused. insert/update does autocast, where sometimes.
Date
Msg-id fvpa00$31fb$1@news.hub.org
Whole thread Raw
In response to operator varchar = integer  (Daniel Schuchardt <daniel_schuchardt@web.de>)
List pgsql-general
demo=# ALTER TABLE a ADD COLUMN d VARCHAR;
ALTER TABLE
demo=# UPDATE a SET d=current_date;
UPDATE 3
demo=# SELECT * FROM a WHERE d=current_date;
ERROR:  operator does not exist: character varying = date at character 24
HINT:  No operator matches the given name and argument type(s). You
might need t
o add explicit type casts.
LINE 1: SELECT * FROM a WHERE d=current_date;


so and now think what takes happen in plpgsql functions if you work with
variables.

DECLARE z INTEGER;

calculations

UPDATE a SET b=z WHERE xyz;

 GET DIAGNOSTICS rows = ROW_COUNT;
 IF rows=0 THEN
 ELSE
    FOR r IN SELECT * FROM a WHERE b=z....
 END IF;



i know that are hypotethical issues but i will show the risk.

pgsql-general by date:

Previous
From: Daniel Schuchardt
Date:
Subject: Re: operator is not unique: integer || integer
Next
From: Daniel Schuchardt
Date:
Subject: now i'm really confused. insert/update does autocast, where sometimes.