0
原諒我,這是我第一次嘗試Oracle包,所以我希望能夠簡單地忽略一些東西。從Oracle對象讀取其他對象表中的行
編輯我整理吧... 需要參考實際的聲明子類型,例如:
FOR j in outvar(i).tbl_ORDER_TENDERS.first..outvar(i).tbl_ORDER_TENDERS.last LOOP
DBMS_OUTPUT.PUT_LINE('tender record : '
|| to_char(outvar(i).tbl_ORDER_TENDERS(j).TENDER_AMT) || ' '
我創建了幾個幾個新的Oracle類型,將從持有行數據我DB,因爲這樣的:
create or replace
TYPE ORDERS_TABLE
IS TABLE OF ORDER_HEADER;
這指的是我的其他類型:
create or replace
TYPE ORDER_HEADER FORCE
AS OBJECT (
TRANSACTION_NUMBER VARCHAR2(20),
LOCATION_NUMBER VARCHAR2(10),
TERMINAL_NAME VARCHAR2(25),
START_DATETIME TIMESTAMP(6),
GROSS_SALES_AMOUNT NUMBER(20,0),
NET_SALES_AMOUNT NUMBER(20,0),
SAVINGS_AMOUNT NUMBER(20,0),
SAVINGS_PRECISION NUMBER(6,0),
TOTAL_TAX NUMBER(20,0),
CUSTOMER_IDENTIFIER VARCHAR2(50),
tbl_ORDER_LINES ORDER_LINES,
tbl_ORDER_TENDERS ORDER_TENDERS,
TBL_ORDER_REBATES ORDER_REBATES
);
而且例如,採取ORDER_TENDERS類型:
create or replace
TYPE ORDER_TENDERS FORCE
AS TABLE OF ORDER_TENDER;
其中包含招標的數據行:
create or replace
TYPE ORDER_TENDER AS OBJECT
(
TENDER_LINE_ID NUMBER(20,0),
TENDER_CODE VARCHAR2(10),
TENDER_AMT NUMBER(20,0),
UNENCODED_ACCOUNT_NUMBER VARCHAR2(25)
);
所以我的包,我認爲是工作,在那裏我可以填補這些對象(驗證)但是我不確定如何在調用這個包來查看我是否獲取ORDER_TENDER/ORDER_TENDERS數據時如何測試/調試/查看結果...
例如,正常工作:
declare
invar varchar2(5);
outvar ORDERS_TABLE;
O_ORDER_TENDERS ORDER_TENDERS;
O_ORDER_TENDER ORDER_TENDER;
begin
sales_trickler.GetSales(invar, outvar);
FOR i in 1..outvar.COUNT LOOP
DBMS_OUTPUT.PUT_LINE(' record : '
|| to_char(outvar(i).TRANSACTION_NUMBER) || ' '
|| to_char(outvar(i).LOCATION_NUMBER) || ' '
|| to_char(outvar(i).TERMINAL_NAME) || ' '
|| to_char(outvar(i).CUSTOMER_IDENTIFIER));
END LOOP;
end;
但是,如何查看ORDER_TENDERS/ORDER_TENDER數據?
我試圖把這個額外的中循環,但它不喜歡我怎麼指ORDER_TENDER(S)...
declare
invar varchar2(5);
outvar ORDERS_TABLE;
O_ORDER_TENDERS ORDER_TENDERS;
O_ORDER_TENDER ORDER_TENDER;
begin
sales_trickler.GetSales(invar, outvar);
FOR i in 1..outvar.COUNT LOOP
DBMS_OUTPUT.PUT_LINE(' record : '
|| to_char(outvar(i).TRANSACTION_NUMBER) || ' '
|| to_char(outvar(i).LOCATION_NUMBER) || ' '
|| to_char(outvar(i).TERMINAL_NAME) || ' '
|| to_char(outvar(i).CUSTOMER_IDENTIFIER));
FOR j in 1..outvar(i).O_ORDER_TENDERS.COUNT LOOP
DBMS_OUTPUT.PUT_LINE('tender record : '
|| to_char(O_ORDER_TENDERS(j).TENDER_AMT) || ' '
);
END LOOP;
END LOOP;
end;
我試圖與outvar(I).ORDER_TENDERS但那也沒用......任何想法?