0

I'm trying to use a global variable in package body with db link but SQLDeveloper throws me PL:00352

 CREATE OR REPLACE PACKAGE BODY my_package
    AS
      global_variable ANOTHER_TABLE@MY_DB_LINK.ANOTHER_FIELD%TYPE;
    
      PROCEDURE my_procedure IS
       variable1 my_table.my_field%TYPE;
      BEGIN
       do things;
      END;
    END my_package;

The global_variable line is throwing me PLS-00352: Unable to access another database 'MY_DB_LINK';

Maybe I am wrong with syntax?

Thanks in advance.

1 Answers1

1

Wrong syntax.

Example: my database link works:

SQL> select * from dual@dbl_scott;

D
-
X

Declaring a variable that inherits datatype from emp table, empno column, over the database link:

SQL> declare
  2    gl_var emp.empno@dbl_scott%type;
  3  begin
  4    null;
  5  end;
  6  /

PL/SQL procedure successfully completed.

SQL>

So, it is: table.column@database_link%type

In your case:

global_variable another_table.another_field@my_db_link%type;
Littlefoot
  • 131,892
  • 15
  • 35
  • 57