nerdexam
Oracle

1Z0-909 · Question #41

Examine these statement which execute successfully: Now, examine the statements executed in the mysqi command-line client: What is true? A. B. C. D.

The correct answer is C. Statement 1 displays: +-----+-----+-----+ | p1 | p2 | p3 | +-----+-----+-----+ | 10 | NULL| 30 | +-----+-----+-----+ Statement 2 displays: +-----+-----+-----+ | @p1 | @p2 | @p3 | +-----+-----+-----+ | 10 | 2 | 3 | +-----+-----+-----+. Option C is correct because MySQL OUT parameters are always initialized to NULL inside a stored procedure, regardless of the value held by the user-defined variable passed as the argument - so p2 is NULL even though the caller may have passed a non-null @p2. Meanwhile, IN…

SQL Fundamentals

Question

Examine these statement which execute successfully:

Now, examine the statements executed in the mysqi command-line client:

What is true? A. B. C. D.

Exhibit

1Z0-909 question #41 exhibit

Options

  • AStatement 1 displays: +-----+-----+-----+ | p1 | p2 | p3 | +-----+-----+-----+ | 10 | 20 | 30 | +-----+-----+-----+ Statement 2 displays: +-----+-----+-----+ | @p1 | @p2 | @p3 | +-----+-----+-----+ | 1 | 2 | 3 | +-----+-----+-----+
  • BStatement 1 displays: +-----+-----+-----+ | p1 | p2 | p3 | +-----+-----+-----+ | NULL| NULL| NULL| +-----+-----+-----+ Statement 2 displays: +-----+-----+-----+ | @p1 | @p2 | @p3 | +-----+-----+-----+ | 1 | 2 | 3 | +-----+-----+-----+
  • CStatement 1 displays: +-----+-----+-----+ | p1 | p2 | p3 | +-----+-----+-----+ | 10 | NULL| 30 | +-----+-----+-----+ Statement 2 displays: +-----+-----+-----+ | @p1 | @p2 | @p3 | +-----+-----+-----+ | 10 | 2 | 3 | +-----+-----+-----+
  • DStatement 1 displays: +-----+-----+-----+ | p1 | p2 | p3 | +-----+-----+-----+ | 10 | NULL| NULL| +-----+-----+-----+ Statement 2 displays: +-----+-----+-----+ | @p1 | @p2 | @p3 | +-----+-----+-----+ | 10 | 20 | 30 | +-----+-----+-----+

How the community answered

(44 responses)
  • A
    18% (8)
  • B
    5% (2)
  • C
    70% (31)
  • D
    7% (3)

Explanation

Option C is correct because MySQL OUT parameters are always initialized to NULL inside a stored procedure, regardless of the value held by the user-defined variable passed as the argument - so p2 is NULL even though the caller may have passed a non-null @p2. Meanwhile, IN parameters (p1 and p3) correctly receive the values supplied at call time (10 and 30), and session variables (@p1, @p2, @p3) retain their pre-call values unless explicitly overwritten by an OUT/INOUT assignment within the procedure body.

Why the distractors fail:

  • A is wrong because it shows p2 = 20 inside the procedure - OUT parameters never inherit the caller's value; they always begin NULL.
  • B is wrong because it shows all three local params as NULL, ignoring that IN parameters (p1, p3) do receive their passed values of 10 and 30.
  • D is wrong because it shows p3 = NULL inside the procedure (an IN param would hold its passed value, 30) and incorrectly shows @p1/@p2/@p3 = 10/20/30 outside.

Memory tip: Think of OUT as "output only" - the procedure produces the value, it never receives one, so it always enters the procedure as NULL. Contrast with IN (read-only copy of the caller's value) and INOUT (gets the caller's value AND can write back).

Topics

#mysql client#session variables#statement execution#command-line

Community Discussion

No community discussion yet for this question.

Full 1Z0-909 Practice