Quantcast
Channel: PostgreSQL – MacLochlainns Weblog
Viewing all articles
Browse latest Browse all 50

PL/pgSQL Test Q?

$
0
0

Intriguing little PostgreSQL PL/pgSQL test question posed by an interviewer of one of my students. Basically, how many times will this loop and what will it return or will it generate an error. (BTW, they wrapped it into a named function.)

DO
$$
BEGIN
  FOR i IN 0.2..1.5 LOOP
    RAISE NOTICE '%', i;
  END LOOP;
END;
$$;

It’ll loop three times and return 0, 1, and 2 because the double numbers entered as boundaries to the for-loop are implicitly case as integers.


Viewing all articles
Browse latest Browse all 50

Trending Articles