Skip to Main Content
  • Questions
  • Stored Procedure to work across database links

Breadcrumb

Question and Answer

Connor McDonald

Thanks for the question, Meyyappan.

Asked: March 18, 2021 - 6:49 am UTC

Last updated: June 01, 2021 - 1:51 am UTC

Version: 11G

Viewed 1000+ times

You Asked

Hi Tom,

I want to create a DB link to fetch the data from various views from schema 1 and get load into whichever table created in schema2. Also I want to update the table periodically to using daily jobs.

Please help to achieve this.

Example:

Schema A: view1, view2 (Fetch few colums from view 1 and view 2)

schema B: Created a table A based on view 1 & View2 from schema A.

Created DB link in schema B to fetch the view1 &view2

Now I want to store procedure to insert the record store in schemaB. TableA using view1 & view2 (Schema A)

Thanks
Meyyappan

and Connor said...

Well...minimal information here :-( so here's out best

create or replace
procedure MY_PROC is
begin
  insert into schemaB.tablesA
  select * 
  from view1@dblink, view2@dblink
   where view1.pk = view2.pk
end;
/


Really we can't offer more than that on such low details

Rating

  (1 rating)

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

Comments

two schema in same DB?

Rajeshwaran Jeyabal, June 01, 2021 - 2:20 pm UTC

By any chance schema 1 and schema 2 are part of same database? if so we dont even need db-links, just grant from schema1 to schema2 is what we needed, then do dml across the schema.

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