01.06.2013 Views

OpenEdge Getting Started: Multi-tenancy Overview - Product ...

OpenEdge Getting Started: Multi-tenancy Overview - Product ...

OpenEdge Getting Started: Multi-tenancy Overview - Product ...

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Chapter 4: <strong>Multi</strong>-<strong>tenancy</strong> and <strong>OpenEdge</strong> SQL<br />

Join multi-tenant tables<br />

To join three multi-tenant tables, pub.mtcustomer, pub.mtorder, and<br />

pub.mtorderline:<br />

SELECT<br />

tenantName_tbl (c) as ten_name,<br />

c.name as c_name,<br />

COUNT (*)<br />

FROM<br />

Pub.mtcustomer AS c<br />

INNER JOIN pub.mtorder AS o<br />

ON tenantId_tbl (c) = tenantId_tbl (o)<br />

AND c.custnum = o.custnum<br />

INNER JOIN pub.mtorderline AS ol<br />

ON tenantId_tbl (o) = tenantId_tbl (ol)<br />

AND o.ordernum = ol.ordernum<br />

GROUP BY<br />

ten_name, c_name;<br />

Insert rows into a multi-tenant table<br />

To insert a new row in a tenant partition of the tenant, SNCSoftware, in the multi-tenant<br />

table, mtcustomer:<br />

INSERT INTO pub.mtcustomer TENANT SNCSoftware<br />

(custnum, name)<br />

VALUES<br />

(9999, 'West Side Sports');<br />

Move rows between partitions in a multi-tenant table<br />

To move the rows from the DEFAULT partition of a multi-tenant table, mtcustomer, and<br />

distribute it to the tenants, SNCSoftware and OED<strong>Product</strong>s:<br />

INSERT INTO pub.mtcustomer TENANT SNCSoftware<br />

SELECT *<br />

FROM pub.mtcustomer AS mtc<br />

WHERE tenantName_tbl (mtc) = 'default'<br />

AND MOD (custnum, 2) = 0;<br />

INSERT INTO pub.mtcustomer TENANT OED<strong>Product</strong>s<br />

SELECT *<br />

FROM pub.mtcustomer AS mtc<br />

WHERE tenantName_tbl (mtc) = 'default'<br />

AND MOD (custnum, 2) 0;<br />

DELETE<br />

FROM pub.mtcustomer AS mtc<br />

WHERE tenantName_tbl (mtc) = 'default';<br />

70 <strong>OpenEdge</strong> <strong>Getting</strong> <strong>Started</strong>: <strong>Multi</strong>-<strong>tenancy</strong> <strong>Overview</strong>

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!