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 PGCES-02 Exam - Topic 11 Question 38 Discussion

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. CREATEFUNCTION get_head(BOOLEAN) RETURNS TEXT LANGUAGE sql CALLED ONNULL INPUT AS 'SELECT val FROM t WHERE $1 OR id > 0 ORDER BY id LIMIT 1;';
A) This function is defined using PL/pgSQL. and D) Even if this function is passed the same parameter value and executed multiple times, the returned values will not necessarily also be the same value.
B) There are cases where this function returns multiple lines.
C) When NULL is passed for the argument and the function is executed, NULL is returned.
E) If a function with the same name and with type BOOLEAN as the parameter is already defined, an error occurs.

PostgreSQL PGCES-02 Exam - 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:

0/2000 characters
Keneth
8 months ago
I've heard about errors with duplicate function names, so E might be true.
upvoted 0 times
...
Rikki
8 months ago
Wait, are you sure it won't return NULL if NULL is passed?
upvoted 0 times
...
Louvenia
9 months ago
I think it could return different values on multiple calls.
upvoted 0 times
...
Tasia
9 months ago
Totally agree, it returns only one line due to LIMIT 1.
upvoted 0 times
...
Novella
9 months ago
This function is written in SQL, not PL/pgSQL.
upvoted 0 times
...
Freida
9 months ago
I vaguely recall something about functions returning different values even with the same input, so option D could be possible, but I'm not completely confident.
upvoted 0 times
...
Martha
9 months ago
I practiced a similar question, and I think if NULL is passed, it should return NULL based on how the function is structured, so option C seems correct.
upvoted 0 times
...
Stefan
9 months ago
I'm not sure, but I feel like the function could return multiple lines if the condition is met, which makes me think option B might be true.
upvoted 0 times
...
Ronna
9 months ago
I remember that functions defined with SQL language don't use PL/pgSQL, so I think option A is definitely incorrect.
upvoted 0 times
...
Laurene
9 months ago
This seems like a good opportunity to demonstrate my understanding of APIs and how they can be used to integrate different systems. I'll make sure to explain the benefits clearly and provide a specific example of how the company could implement this.
upvoted 0 times
...
Salena
10 months ago
I remember we discussed the importance of requiring suppliers to implement a sales and operations planning process. That might help, but I feel like it's more about managing capacity than directly preventing interruptions.
upvoted 0 times
...
Howard
1 year ago
This question is making my head spin! I bet the exam writer is having a good laugh at our expense. Anyway, I'm sticking with C and D, they seem the most reasonable to me.
upvoted 0 times
Clarence
1 year ago
User1
upvoted 0 times
...
Harris
1 year ago
User3
upvoted 0 times
...
Sharita
1 year ago
User2
upvoted 0 times
...
Dulce
1 year ago
User1
upvoted 0 times
...
Tamra
1 year ago
I agree with you, C and D seem like the most reasonable choices.
upvoted 0 times
...
Lottie
1 year ago
I believe A is incorrect, but C and D make sense to me.
upvoted 0 times
...
Clorinda
1 year ago
I'm not sure about B, but I agree with C and D.
upvoted 0 times
...
Mickie
1 year ago
Yeah, D makes sense too. Let's go with C and D for our answers.
upvoted 0 times
...
Mickie
1 year ago
I agree with you on C. I also think D is correct because the returned values may not be the same.
upvoted 0 times
...
Blythe
1 year ago
I think C and D are correct too.
upvoted 0 times
...
Mickie
1 year ago
I think C is correct because when NULL is passed, NULL is returned.
upvoted 0 times
...
...
Noah
1 year ago
I believe statement E is true because having a function with the same name and parameter type can cause an error.
upvoted 0 times
...
Truman
1 year 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
Adolph
1 year ago
User 2
upvoted 0 times
...
Anika
1 year ago
User 1
upvoted 0 times
...
...
Lucille
1 year ago
I agree with statement D because the function might not always return the same value.
upvoted 0 times
...
Ashleigh
1 year 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
1 year ago
I think statement C is correct because if NULL is passed, NULL is returned.
upvoted 0 times
...
Glendora
1 year 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
Teri
1 year ago
I agree, and D is also correct because the returned value might change between function calls.
upvoted 0 times
...
Teri
1 year ago
I think B is correct because the function could return multiple lines.
upvoted 0 times
...
...
Vanesa
1 year 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
1 year 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