Skip to Main Content
  • Questions
  • Access variables and types declared inside the package on remote schema for assignment and execution in my schema

Breadcrumb

Question and Answer

Chris Saxon

Thanks for the question, Thirumoorthi.

Asked: November 28, 2018 - 7:43 am UTC

Last updated: November 28, 2018 - 2:18 pm UTC

Version: 12c

Viewed 1000+ times

You Asked

Hi All,
I want to access and assign value to variable and type declared inside procedure of remote schema via db from my schema.

Eg. below code is in the main schema[REMOTETEST1] for processing
create package mytest 
g_value myType;
rec_op myType;
function execprocess(rec_op out myType )
return boolean;


I want to assign value for g_value from my schema which is in different database using DB Link.

In my schema[TEST1],

REMOTETEST1.mytest@DBLINK.g_value:=VALUE;

and Chris said...

Create get/set methods inside the package to manipulate it:

create database link loopback using '//localhost:1521/orcl';

create or replace package mytest is
  g_value int;
  
  function get_val return int;
  procedure set_val ( val int );
  
end mytest;
/

create or replace package body mytest is
 
  function get_val return int as
  begin
    return g_value;
  end;
  
  procedure set_val ( val int ) as
  begin
    g_value := val;
  end;
  
end mytest;
/

exec mytest.set_val@loopback ( 1 );

select mytest.get_val@loopback from dual;

GET_VAL   
        1 


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

More to Explore

Administration

Need more information on Administration? Check out the Administrators guide for the Oracle Database