ZIP集計関数
構文
%%{init: {
'theme': 'base',
'flowchart': { 'padding': '7', 'nodeSpacing': '20', 'rankSpacing': '20' },
'themeVariables': {
'fontSize': '11px',
'fontFamily': 'Arial'
}
}}%%
flowchart LR
zipAggregateFunction_start((START))
zipAggregateFunction_start --> zipAggregateFunction_0_0[ZIP]:::quoted
zipAggregateFunction_0_0 --> zipAggregateFunction_0_1["("]:::quoted
zipAggregateFunction_0_1 --> zipAggregateFunction_0_2[expressionList]
zipAggregateFunction_0_2 --> zipAggregateFunction_0_3[")"]:::quoted
zipAggregateFunction_0_3 --> zipAggregateFunction_end((END))
目的
複数の行のバイナリドキュメントを1つのZIPアーカイブにまとめるグループ関数です。 最初の式は各ドキュメントのバイナリ内容(blob)を指定し、2番目の式はアーカイブ内でのドキュメントのファイル名を指定します。 nullの内容は省略されます。nullの内容しかない場合、結果はnullになります。
戻り値:blobとしてのZIPアーカイブ。
例
次の例では、すべての顧客の請求書PDFドキュメントを1つのZIPアーカイブにまとめています。たとえば監査人に引き渡す場合に使用できます。結果は、請求書ごとにファイルを含む1つのblobです。
select zip(ivc.pdf_document, ivc.invoice_number || '.pdf') invoices_archive
from invoices ivc
次の例では、顧客ごとの請求書PDFドキュメントを顧客ごとに1つのZIPアーカイブにまとめ、各アーカイブに顧客名を付けています。たとえば、各顧客に未払い請求書のコピーを送る場合に使用できます。
select ivc.customer_name
, zip(ivc.pdf_document, ivc.invoice_number || '.pdf') invoices_archive
from invoices ivc
group
by ivc.customer_name