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

Posted by Devorah on Jan 09, 2023 at 01:14 PM

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

Suggested Answer: A, D

Get Premium PGCES-02 Questions as Interactive Web-Based Practice Test or PDF Real Exam Format Detailed Explanations Instant Access Get Your Practice Test
35 comments · newest first
KE
Keneth 11 months ago
I've heard about errors with duplicate function names, so E might be true.
RI
Rikki 11 months ago
Wait, are you sure it won't return NULL if NULL is passed?
LO
Louvenia 12 months ago
I think it could return different values on multiple calls.
TA
Tasia 12 months ago
Totally agree, it returns only one line due to LIMIT 1.
NO
Novella 12 months ago
This function is written in SQL, not PL/pgSQL.
FR
Freida 1 year 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.
MA
Martha 1 year 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.
ST
Stefan 1 year 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.
RO
Ronna 1 year ago
I remember that functions defined with SQL language don't use PL/pgSQL, so I think option A is definitely incorrect.
LA
Laurene 1 year 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.
SA
Salena 1 year 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.
HO
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.
CL
Clarence 1 year ago
↳ replying to Howard
User1
HA
Harris 1 year ago
↳ replying to Howard
User3
SH
Sharita 1 year ago
↳ replying to Howard
User2
DU
Dulce 1 year ago
↳ replying to Howard
User1
TA
Tamra 1 year ago
↳ replying to Howard
I agree with you, C and D seem like the most reasonable choices.
LO
Lottie 1 year ago
↳ replying to Howard
I believe A is incorrect, but C and D make sense to me.
CL
Clorinda 1 year ago
↳ replying to Howard
I'm not sure about B, but I agree with C and D.
MI
Mickie 1 year ago
↳ replying to Howard
Yeah, D makes sense too. Let's go with C and D for our answers.
MI
Mickie 1 year ago
↳ replying to Howard
I agree with you on C. I also think D is correct because the returned values may not be the same.
BL
Blythe 1 year ago
↳ replying to Howard
I think C and D are correct too.
MI
Mickie 1 year ago
↳ replying to Howard
I think C is correct because when NULL is passed, NULL is returned.
NO
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.
TR
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.
AD
Adolph 1 year ago
↳ replying to Truman
User 2
AN
Anika 1 year ago
↳ replying to Truman
User 1
LU
Lucille 1 year ago
I agree with statement D because the function might not always return the same value.
AS
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.
MO
Mollie 1 year ago
I think statement C is correct because if NULL is passed, NULL is returned.
GL
Glendora 2 years 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.
TE
Teri 1 year ago
↳ replying to Glendora
I agree, and D is also correct because the returned value might change between function calls.
TE
Teri 1 year ago
↳ replying to Glendora
I think B is correct because the function could return multiple lines.
VA
Vanesa 2 years 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.
NO
Nohemi 2 years ago
The function is not defined using PL/pgSQL, it's using SQL language. I'm going with C and D.
0/2000 characters

Save Cancel