Deal of The Day! Hurry Up, Grab the Special Discount - Save 25% - Ends In 00:00:00 Coupon code: SAVE25
Welcome to Pass4Success

- Free Preparation Discussions

PostgreSQL Exam PGCES-02 Topic 11 Question 38 Discussion

Actual exam question for PostgreSQL's PGCES-02 exam
Question #: 38
Topic #: 11
[All PGCES-02 Questions]

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;';

Show Suggested Answer Hide Answer
Suggested Answer: A, D

Contribute your Thoughts:

Truman
1 days ago
Wait, is this a trick question? What if the table is empty? In that case, the function would return NULL, so C is definitely correct. As for the other statement, I'll go with D - it sounds like it could return different values even with the same parameter.
upvoted 0 times
...
Lucille
1 days ago
I agree with statement D because the function might not always return the same value.
upvoted 0 times
...
Ashleigh
4 days ago
I'm a bit stumped on this one. Is the function going to return the first row based on the id, or the first row where the condition is true? I guess I'll go with C and D, just to be safe.
upvoted 0 times
...
Mollie
4 days ago
I think statement C is correct because if NULL is passed, NULL is returned.
upvoted 0 times
...
Glendora
7 days ago
This is a tricky one! I'm going to say B and D are the correct statements. The function could return multiple lines if there are multiple rows with id > 0, and the returned value might change if the table is updated between function calls.
upvoted 0 times
...
Vanesa
8 days ago
Hmm, if the function is called with NULL input, it should return NULL, so C is correct. But I'm not sure about the other statement, let me think about it.
upvoted 0 times
...
Nohemi
9 days ago
The function is not defined using PL/pgSQL, it's using SQL language. I'm going with C and D.
upvoted 0 times
...

Save Cancel