4.12 Performing Cross-Schema Operations

All GeoRaster operations can work on GeoRaster objects defined in schemas other than the current connection schema. In other words, GeoRaster fully supports cross-schema access, update, and processing.

For more information, see Cross-Schema Support with GeoRaster.

Example 4-2 Cross-Schema Copy Operation

In the following example, USER2 makes a copy of an image from USER1 and stores it in the USER2 schema. Assume that USER1 owns the GEORASTER_TABLE table and that USER2 owns the G_TABLE table.

--connect to user1 and grant permissons to user2
--assume user1 stores the image in georaster_table and the image’s RDT table is rdt_1 
conn user1/pswd1
 grant select on georaster_table to user2;
grant select on rdt_1 to user2;

--connect to user2 and make a copy of a georaster from user1
conn user2/pswd2
SQL> DECLARE
   gr1 sdo_georaster;
   gr2 sdo_georaster;
BEGIN
   --select the image from georaster_table in user1
   select georaster into gr1 from user1.georaster_table where georid = 100;
   -- the copy is to be stored in g_table in user2, assuming the georaster object is already initiated
   select geor into gr2 from g_table where id = 1 for update;
   sdo_geor.changeFormatCopy(gr1, 'blocking=OPTIMALPADDING blocksize=(512,512,3) interleaving=BIP', gr2);
   update g_table set geor=gr2 where id=1;
   commit;
END;
/ 

Example 4-3 Cross-Schema Raster Algebra and Copy Operation

In the following example, USER2 runs a raster algebra operation on an image in the USER1 schema and stores the result in USER1. Assume that USER1 owns both the GEORASTER_TABLE and G_TABLE tables. The existing image is in GEORASTER_TABLE and the image’s raster data table is RDT_1. The resulting image is stored in G_TABLE and its raster data table is RDT_2.

--connect to user1 and grant permissons to user2
conn user1/pswd1
grant select on georaster_table to user2;
grant select on rdt_1 to user2;
grant select, update, insert, delete on g_table to user2;
grant select, update, insert, delete on rdt_2 to user2;

--connect to user2 and run a raster algebra operation on an image in user1 
conn user2/pswd2
DECLARE
   gr1 sdo_georaster;
   gr2 sdo_georaster;
BEGIN
   --select the image from georaster_table in user1
   select georaster into gr1 from user1.georaster_table where georid = 100;
   -- the result is to be stored in g_table in user1, assuming the georaster object is already initiated
   select geor into gr2 from user1.g_table where id = 1 for update;
   sdo_geor_ra.rasterMathOp(gr1,sdo_string2_array('{0}','{1}','{2}'), 'blocking=OPTIMALPADDING blocksize=(512,512,3) interleaving=BIP',gr2);
   update user1.g_table set geor=gr2 where id=1;
   commit;
END;
/