プライマリ・コンテンツに移動
Oracle® R Enterpriseユーザーズ・ガイド
リリース1.5
E67082-02
目次へ移動
目次
索引へ移動
索引

前
前へ
次
次へ

2.2.1.2 ore.sync関数の使用方法

例2-10ore.sync関数の使用を示します。この例ではまず、ore.exec関数を呼び出して、rquserのデータベース・スキーマに存在する表を表すいくつかの表を作成します。次に、ore.syncを呼び出し、スキーマの3つの表を指定します。ore.syncの呼出しによりrquserにR環境を作成し、そのスキーマ内の指定された表に対するプロキシore.frameオブジェクトを作成します。この例では、現在の環境にあるore.frameプロキシ・オブジェクトをリストします。TABLE3表はスキーマ内に存在しますが、ore.frameプロキシ・オブジェクトは含まれません(このプロキシ・オブジェクトはore.sync呼出しに含められていないため)。

次に、query引数を使用してore.syncを呼び出して、指定されたSQL問合せに対するore.frameオブジェクトを作成します。再びore.frameオブジェクトをリストします。

次にore.syncを再び呼び出し、SHスキーマにR環境を作成し、そのスキーマ内の指定された表に対するプロキシ・オブジェクトをその環境内に作成します。この例では、ore.exists関数を呼び出して、指定された表が現在の環境に存在するかどうかを確認した後に、SH環境に存在するかどうかを確認します。SH環境内のRオブジェクトをリストします。

次に、ore.frameオブジェクトのQUERY1QUERY2およびTABLE4をrquser環境から削除します。最後に、環境内のプロキシ・オブジェクトを再びリストします。

注意:

ore.rm関数の呼出しにより、TABLE4表のプロキシであるore.frameが環境から削除されます。スキーマから表は削除されません。

例2-10 ore.frameプロキシ・オブジェクトをR環境に追加するためのore.syncの使用方法

# After connecting to a database as rquser, create some tables.
ore.exec("CREATE TABLE TABLE1 AS SELECT * FROM dual")
ore.exec("CREATE TABLE TABLE2 AS SELECT * FROM dual")
ore.exec("CREATE TABLE TABLE3 AS SELECT * FROM dual")
ore.exec("CREATE TABLE TABLE4 AS SELECT * FROM dual")
# Create ore.frame objects for the specified tables.
ore.sync(table = c("TABLE1", "TABLE3", "TABLE4"))
# List the ore.frame proxy objects in the current environment.
ore.ls()
# Create ore.frame objects for the specified queries.
ore.sync(query = c("QUERY1" = "SELECT 0 X, 1 Y FROM dual",
                   "QUERY2" = "SELECT 1 X, 0 Y FROM dual"))
ore.ls()
# The rquser user has been granted SELECT permission on the tables in the 
# SH schema.
ore.sync("SH", table = c("CUSTOMERS", "SALES"))
# Find out if the CUSTOMERS ore.frame exists in the rquser environment.
ore.exists("CUSTOMERS")
# Find out if it exists in the SH environment.
ore.exists("CUSTOMERS", schema = "SH")
# List the ore.frame proxy objects in the SH environment.
ore.ls("SH")
# Remove the ore.frame objects for the specified objects.
ore.rm(c("QUERY1", "QUERY2", "TABLE4"))
# List the ore.frame proxy objects in the current environment again.
ore.ls()
例2-10のリスト
R> # After connecting to a database as rquser, create some tables.
R> ore.exec("CREATE TABLE TABLE1 AS SELECT * FROM dual")
R> ore.exec("CREATE TABLE TABLE2 AS SELECT * FROM dual")
R> ore.exec("CREATE TABLE TABLE3 AS SELECT * FROM dual")
R> ore.exec("CREATE TABLE TABLE4 AS SELECT * FROM dual")
R> # Create ore.frame objects for the specified tables.
R> ore.sync(table = c("TABLE1", "TABLE3", "TABLE4"))
R> # List the ore.frame proxy objects in the current environment.
R> ore.ls()
 [1] "TABLE1"     "TABLE3"     "TABLE4"
R> # Create ore.frame objects for the specified queries.
R> ore.sync(query = c("QUERY1" = "SELECT 0 X, 1 Y FROM dual",
+                     "QUERY2" = "SELECT 1 X, 0 Y FROM dual"))
R> ore.ls()
 [1] "QUERY1"     "QUERY2"     "TABLE1"     "TABLE3"     "TABLE4"
R> # The rquser user has been granted SELECT permission on the tables in the 
R> # SH schema.
R> ore.sync("SH", table = c("CUSTOMERS", "SALES"))
R> # Find out if the CUSTOMERS ore.frame exists in the rquser environment.
R> ore.exists("CUSTOMERS")
[1] FALSE
R> # Find out if it exists in the SH environment.
R> ore.exists("CUSTOMERS", schema = "SH")
[1] TRUE
R> # List the ore.frame proxy objects in the SH environment.
R> ore.ls("SH")
[1] "CUSTOMERS" "SALES"
R> # Remove the ore.frame objects for the specified objects.
R> ore.rm(c("QUERY1", "QUERY2", "TABLE4"))
R> # List the ore.frame proxy objects in the current environment again.
R> ore.ls()
 [1] "TABLE1"     TABLE3"