Skip to Main Content
  • Questions
  • Oracle 12.2 new features: long names

Breadcrumb

Question and Answer

Chris Saxon

Thanks for the question.

Asked: November 25, 2016 - 10:55 am UTC

Last updated: November 25, 2016 - 2:00 pm UTC

Version: 12.2.0.1

Viewed 1000+ times

You Asked

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!!

and Chris said...

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


Is this answer out of date? If it is, please let us know via a Comment

More to Explore

PL/SQL demos

Check out more PL/SQL tutorials on our LiveSQL tool.

PL/SQL docs

PL/SQL reference manual from the Oracle documentation library