Im using plpgsql to write triggers n Im wondering when to use = and when to use := in postgreSQL, what is the difference???
for example:
CREATE OR REPLACE FUNCTION on_ai_myTable() RETURNS TRIGGER AS $$
DECLARE
t_ix real;
n int;
BEGIN
IF NEW.time_type = 'Start' THEN
SELECT t.time_index FROM table_ebscb_spa_log02 t WHERE t.fn_name = NEW.fn_name AND t.time_type = 'Start' ORDER BY t.timestamp02 DESC LIMIT 1 INTO t_ix;
GET DIAGNOSTICS n = ROW_COUNT;
IF (n = 0) THEN
t_ix = 1;
ELSE
t_ix = t_ix + 1;
END IF;
END IF;
NEW.time_index = t_ix;
return NEW;
END
$$
LANGUAGE plpgsql;
In version 9.4, the documentation was updated to make it clear that there is no difference.
Version 9.4:
40.5.1. Assignment
An assignment of a value to a PL/pgSQL variable is written as:
variable { := | = } expression;
[...]
Equal (=) can be used instead of PL/SQL-compliant :=
In previous versions, :=
alone was mentioned as the assignment operator, but =
has been working since the beginning.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With