T
T
TheLostRoot2018-03-05 17:47:19
PostgreSQL
TheLostRoot, 2018-03-05 17:47:19

How to write an iterator function?

Postgresql
There is a table with the structure:
terms:
id SERIAL
term VARCHAR(40)
freq BIGINT
It is necessary to write a function that takes a value as a parameter with the same type as the term column. And if there is an entry with such a value, increase its freq value by 1. If there is no such entry, create it and set the freq value to 1.
You need to return the freq value.
It is assumed that a unique index and records are hung on the table and there are no identical term values.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Melkij, 2018-03-05
@melkij

This is called not an iterator.
Wrap in a function at will. 9.5+

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question