nerdexam
PostgreSQL_CE

PGCES-02 · Question #47

A table is defined as follows: CREATE TABLE t (id INT, val TEXT); Select two correct statements from below about the function "get_head" defined below. CREATE FUNCTION get_head(BOOLEAN) RETURNS TEXT…

The correct answer is D. Even if this function is passed the same parameter value and executed multiple times, the E. If a function with the same name and with type BOOLEAN as the parameter is already defined. See the full explanation below for the reasoning.

Question

A table is defined as follows:

CREATE TABLE t (id INT, val TEXT); Select two correct statements from below about the function "get_head" defined below. CREATE FUNCTION get_head(BOOLEAN) RETURNS TEXT LANGUAGE sql CALLED ON NULL INPUT AS 'SELECT val FROM t WHERE $1 OR id > 0 ORDER BY id LIMIT 1;';

Options

  • AThis function is defined using PL/pgSQL.
  • BThere are cases where this function returns multiple lines.
  • CWhen NULL is passed for the argument and the function is executed, NULL is returned.
  • DEven if this function is passed the same parameter value and executed multiple times, the
  • EIf a function with the same name and with type BOOLEAN as the parameter is already defined,

How the community answered

(53 responses)
  • A
    9% (5)
  • B
    4% (2)
  • C
    15% (8)
  • D
    72% (38)

Community Discussion

No community discussion yet for this question.

Full PGCES-02 Practice