PGQLをトランスレートして生成したSQLをレポートのソースとした、Oracle APEXのアプリケーションを作成したことがあります。
PGQLの2層モードで生成されるSQLをAPEXのレポートに組み込む4.1.5 Granting System and Object Privileges for SQL Property Graphs
GRANT CREATE PROPERTY GRAPH, CREATE ANY PROPERTY GRAPH,
ALTER ANY PROPERTY GRAPH, DROP ANY PROPERTY GRAPH,
READ ANY PROPERTY GRAPH TO APEXDEV;
[oracle@apex ~]$ sqlplus system/********@localhost/freepdb1
SQL*Plus: Release 23.0.0.0.0 - Developer-Release on Fri Apr 7 15:34:54 2023
Version 23.2.0.0.0
Copyright (c) 1982, 2023, Oracle. All rights reserved.
Last Successful login time: Fri Apr 07 2023 15:34:44 +09:00
Connected to:
Oracle Database 23c Free, Release 23.0.0.0.0 - Developer-Release
Version 23.2.0.0.0
SQL> GRANT CREATE PROPERTY GRAPH, CREATE ANY PROPERTY GRAPH,
ALTER ANY PROPERTY GRAPH, DROP ANY PROPERTY GRAPH,
READ ANY PROPERTY GRAPH TO APEXDEV; 2 3
Grant succeeded.
SQL> exit
Disconnected from Oracle Database 23c Free, Release 23.0.0.0.0 - Developer-Release
Version 23.2.0.0.0
[oracle@apex ~]$
create table sqlcl_bank_accts ( | |
acct_id number not null constraint sqlcl_bank_accts_acct_id_pk primary key, | |
name varchar2(64) not null | |
) | |
; | |
create table sqlcl_bank_txns ( | |
txn_id number not null constraint sqlcl_bank_txns_txn_id_pk primary key, | |
from_acct_id number not null | |
constraint sqlcl_bank_txns_from_acct_i_fk | |
references sqlcl_bank_accts on delete cascade, | |
to_acct_id number not null | |
constraint sqlcl_bank_txns_to_acct_id_fk | |
references sqlcl_bank_accts on delete cascade, | |
description varchar2(128) not null, | |
amount number(38,2) not null | |
) | |
; | |
create index sqlcl_bank_txns_i1 on sqlcl_bank_txns (from_acct_id); | |
create index sqlcl_bank_txns_i52 on sqlcl_bank_txns (to_acct_id); |
テスト・データより、送金元と送金先が同じ行を削除します。
delete from sqlcl_bank_txns where from_acct_id = to_acct_id;
create property graph sqlcl_bank_graph | |
vertex tables ( | |
sqlcl_bank_accts as accounts | |
key (acct_id) | |
label account | |
properties (acct_id,name) | |
) | |
edge tables ( | |
sqlcl_bank_txns as transfers | |
key (txn_id) | |
source key (from_acct_id) references accounts(acct_id) | |
destination key (to_acct_id) references accounts(acct_id) | |
label transfer | |
properties (from_acct_id, to_acct_id, amount, description) | |
); |
select acct_id, count(*) as NumDeposits
from graph_table(sqlcl_bank_graph
match
(m is account) -[e is transfer] ->(v is account)
columns (v.acct_id)
)
group by acct_id
order by NumDeposits desc
fetch first :P2_ROWS rows only;
5 SQL GRAPH_TABLE Queries
select from_acct_id, amount, to_acct_id, description
from graph_table(sqlcl_bank_graph
match
(s is account where s.acct_id member of apex_string.split_numbers(:P3_ACCT_IDS,',')) -[e is transfer]->(d is account)
columns (s.acct_id as from_acct_id, e.amount as amount, d.acct_id as to_acct_id, e.description as description)
);