I was just going through
https://blogs.oracle.com/sql/entry/12_things_developers_will_love and checking the new Oracle 12.2 features, and noticed something about the "Loooooooooooooooong Names".
So say if I define a variable as
v_table_name user_tables.table_name%TYPE;
Would this automatically take care of the long names which would be (are) available in 12c (extended names)?
Or is this a bad convention to follow?
Regards!!
If you keep reading down the article to:
https://blogs.oracle.com/sql/entry/12_things_developers_will_love#expressions You'll find the answer is:
Yes!
SQL> create table "12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678" (
2 x int
3 );
Table created.
SQL>
SQL> declare
2 l user_tables.table_name%type;
3 begin
4 select table_name into l from user_tables
5 where table_name like '1234%';
6
7 dbms_output.put_line(length(l));
8 end;
9 /
128
PL/SQL procedure successfully completed.
Of course, if you want fully qualified names with the schema and quotes around the name, you'll find it doesn't work:
SQL> declare
2 l user_tables.table_name%type;
3 begin
4 select '"' || owner || '"."' || table_name || '"'
5 into l from all_tables
6 where table_name like '1234%';
7
8 dbms_output.put_line(length(l));
9 end;
10 /
declare
*
ERROR at line 1:
ORA-06502: PL/SQL: numeric or value error: character string buffer too small