Home > Back-end >  Why do I get a copied line numbers warning using DECODE in Oracle SQL server?
Why do I get a copied line numbers warning using DECODE in Oracle SQL server?

Time:08-30

I am receiving a copied line warning when I am using decode in Oracle SQL Server. I can't seem to find any information on this type of warning anywhere. Why am I receiving this warning?

Image of the warning

Image of the Warning

This is my query

SELECT 
DECODE(value, 
1, 'OA', 
2, 'EZ', 
3, 'THD',
4, 'EDIWBI',
5, 'EManual',
6, 'BS',
7, 'OETY'
) ORDER_SOURCE
from my_table;

When I move line four up to line three (shown below), the warning disappears but then I get a suggestion to expand my SQL statement. I structured my DECODE statement like that to make it easier to read.

SELECT 
DECODE(value, 
1, 'OA', 2, 'EZ', 
3, 'THD',
4, 'EDIWBI',
5, 'EManual',
6, 'BS',
7, 'OETY'
) ORDER_SOURCE
from my_table;

CodePudding user response:

Solution is simple: ignore the warning. It is pointless. I believe software (SQL Developer) misidentified a "problem" (as there's none).

You can, though, navigate (with the mouse) to "Fix it", click it and you'll see what happens - all numbers (except 1) will be removed and then you'll get invalid query, as opposed to a valid one you have now.


Though, perhaps you'd want to consider using a CASE expression instead of DECODE for easier/simpler readability and maintenance; in simple cases (as yours) it doesn't really matter, but - for complex problems, DECODE is a nightmare.

  • Related