Reputation: 11
Screenshot of the result
I first tried making the solution for this exercise without using to_number (lower half of picture) since manager_id is a number (I checked it beforehand). However this gives me the result twice. So I looked at the solution that my teacher provided and saw that the teacher uses to_number (upper half of the picture). So I tested that version and it only gives the result once.
Why does this happen?
Below is a screenshot that shows that manager_id is already a number so why convert it again to_number?
Manager_id is defined as a number
Thanks in advance
A confused student :)
Upvotes: 0
Views: 54
Reputation: 142788
Is there a slash /
character somewhere in the afiedt.buf file? If so, it "instructs" SQL*Plus to re-run the last statement and you got the result twice.
Because, TO_NUMBER
has nothing to do with two "results". These aren't two rows (returned by the same query), but the same query ran twice.
Something like this:
SQL> select count(*) from emp;
COUNT(*)
----------
14
SQL> / --> this
COUNT(*)
----------
14
SQL>
Or, even better: contents of my a.sql
file:
prompt Number of rows in EMP table
select count(*) from emp;
/
Note the last slash. When executed, it result in
SQL> @a
Number of rows in EMP table
COUNT(*)
----------
14
COUNT(*)
----------
14
SQL>
Upvotes: 2