If statement in a cursor
Hi
I am trying to have a if statement inside a cursor clause. But it gives me error saying that "PLS-00103: Encountered the symbol "IF" when expecting one of the following: ( select <a SQL statement>". I know this is not the right syntax so is there any way that I can specify the table that the cursor should get its information from based on a if clause.
The typeID field tells me which table to go to to get the information from. So if typeId=1 then go to table1 if it is type=2 then go to table2 etc.....
CREATE OR REPLACE PROCEDURE FILLDATA(
typeID IN NUMBER
) IS
data varchar2(16);
dataresult varchar2(16);
cursor c1 is
IF typeID=1 then
select value from TableName#1
ELSE
select value from TableName#2
END IF;
where id='1';
begin
open c1;
dataresult:='';
loop
fetch c1 into dataresult;
EXIT WHEN c1%NOTFOUND;
data:=concat(to_char(data), to_char(dataresult));
end loop;
close c1;
end
Your help will be really appreciated. Thanks a lot.
Message was edited by:
user561977
Message was edited by:
user561977
Message was edited by:
user561977
Or I guess:
DECLARE
cur SYS_REFCURSOR;
BEGIN
CASE ROUND(DBMS_RANDOM.VALUE(1,2))
WHEN 1 THEN OPEN cur FOR SELECT id FROM t1;
WHEN 2 THEN OPEN cur FOR SELECT id FROM t2;
END CASE;
CLOSE cur;
END;Also I can't think of a practical use for this here, but you can assign one ref cursor to another:
DECLARE
c1 SYS_REFCURSOR;
c2 SYS_REFCURSOR;
c_generic SYS_REFCURSOR;
BEGIN
CASE ROUND(DBMS_RANDOM.VALUE(1,2))
WHEN 1 THEN
DBMS_OUTPUT.PUT_LINE('Picked value: 1');
OPEN c1 FOR SELECT id FROM t1;
c_generic := c1;
WHEN 2 THEN
DBMS_OUTPUT.PUT_LINE('Picked value: 2');
OPEN c2 FOR SELECT id FROM t2;
c_generic := c2;
END CASE;
CLOSE c_generic;
IF c1%ISOPEN THEN
DBMS_OUTPUT.PUT_LINE('c1 is open.');
CLOSE c1;
ELSIF c2%ISOPEN THEN
DBMS_OUTPUT.PUT_LINE('c2 is open.');
CLOSE c2;
ELSE
DBMS_OUTPUT.PUT_LINE('It appears that neither c1 nor c2 is open.');
END IF;
END;
Picked value: 2
It appears that neither c1 nor c2 is open.
PL/SQL procedure successfully completed.Message was edited by:
William Robertson
Similar Messages
-
Replace the following open/fetch/close statements with a cursor FOR loop
Hi anyone could you please help me,
I would like to replace the following open/fetch/close statements with a cursor FOR loop.
Codes are:
CREATE OR REPLACE PROCEDURE COMOES.orchid_shipment_interface IS
-- get the com shipment header records
CURSOR c_com_shphdr ( p_dwn_end_dt DATE ) IS
SELECT custno client_id
, plheadno plheadno
, DECODE(carr_no,'FEDX',lading_no,'UPS',lading_no,carrier_pro_no) tracking_no
, carr_no||'/'||carr_method carrier_id
, plantid plant_id
, carr_no
, lading_no
, del_custaddr ship_to_id
, ol_type cfm_order_type
, del_custno
, shipterm freight_terms
, del_custattn attn_line
, custaddr
FROM com_plhead@com_pricing.world
WHERE status = '9'
AND (mod_dat) > p_dwn_end_dt;
-- get the com shipment address records
CURSOR c_com_shpadr (p_custaddr VARCHAR2) IS
SELECT name1 addr_name
, street1 addr_line1
, street2 addr_line2
, city city
, state state_cd
, zip zip
, country country_cd
, phone work_phone
, email email1
FROM com_address@com_pricing.world
WHERE addr_id = p_custaddr;
-- get the com shipment detail records
CURSOR c_com_shpdtl ( p_plheadno NUMBER) IS
SELECT pll.plheadno pllheadno
, pll.pllineno ord_line_no
, pll.ol_no erp_line_no
, pll.ol_segno
, pll.fg_id sku
, pll.qty_shipped ship_qty
, pll.ordno erp_ord_no
FROM com_plline@com_pricing.world pll
WHERE pll.plheadno = p_plheadno
AND NOT EXISTS (SELECT '1'
FROM com_pkg_int_interface@com_pricing.world cpi
WHERE pll.ordno = cpi.ordno
AND pll.ol_no = cpi.ol_no);
-- type declaration
-- type declaration of com table.
TYPE t_com_shphdr IS TABLE OF c_com_shphdr%ROWTYPE INDEX BY BINARY_INTEGER;
TYPE t_orchid_shphdr IS TABLE OF orchid_shipment_hdr_intf%ROWTYPE INDEX BY BINARY_INTEGER;
TYPE t_com_shpadr IS TABLE OF c_com_shpadr%ROWTYPE INDEX BY BINARY_INTEGER;
TYPE t_orchid_shpadr IS TABLE OF orchid_shipment_address_intf%ROWTYPE INDEX BY BINARY_INTEGER;
TYPE t_com_shpdtl IS TABLE OF c_com_shpdtl%ROWTYPE INDEX BY BINARY_INTEGER;
TYPE t_orchid_shpdtl IS TABLE OF orchid_shipment_dtl_intf%ROWTYPE INDEX BY BINARY_INTEGER;
lv_company_code com_customer.business_unit%TYPE;
lv_erp_ord_no com_plline.ordno%TYPE;
lv_actual_ship_date com_plline.confirm_date%TYPE;
lv_po_no com_oline.po_no%TYPE;
lv_ord_date com_oline.entrydate%TYPE;
lv_hdr_batch_ctrl_no download_batch_info.batch_ctrl_no%TYPE;
lv_adr_batch_ctrl_no download_batch_info.batch_ctrl_no%TYPE;
lv_dtl_batch_ctrl_no download_batch_info.batch_ctrl_no%TYPE;
lv_sku_desc com_salesitem.title%TYPE;
lv_ord_qty com_oldelseg.qty%TYPE;
lr_com_shphdr t_com_shphdr;
lr_orchid_shphdr t_orchid_shphdr;
lr_com_shpadr t_com_shpadr;
lr_orchid_shpadr t_orchid_shpadr;
lr_com_shpdtl t_com_shpdtl;
lr_orchid_shpdtl t_orchid_shpdtl;
-- variable declaration
ln_shphdr_seq NUMBER(10):= 0;
ln_shpadr_seg NUMBER(10):= 0;
ln_shpdtl_seq NUMBER(10):= 0;
cnt NUMBER(10):= 0;
cnt1 NUMBER(10):= 0;
ld_hdr_dwn_end_dt download_batch_info.download_end_tstamp%TYPE;
lc_hdr_dwn_status download_batch_info.dwn_status%TYPE;
ld_hdr_download_end_tstamp DATE;
ln_hdr_running_seq NUMBER(10) := 0;
ld_adr_dwn_end_dt download_batch_info.download_end_tstamp%TYPE;
lc_adr_dwn_status download_batch_info.dwn_status%TYPE;
ld_adr_download_end_tstamp DATE;
ln_adr_running_seg NUMBER(10) := 0;
ld_dtl_dwn_end_dt download_batch_info.download_end_tstamp%TYPE;
lc_dtl_dwn_status download_batch_info.dwn_status%TYPE;
ld_dtl_download_end_tstamp DATE;
ln_dtl_running_seq NUMBER(10) := 0;
BEGIN
-- get the batch control number details from batch information table for shipment header
BEGIN
SELECT batch_ctrl_no
, NVL(download_end_tstamp,TO_DATE('01/01/1980','MM/DD/YYYY'))
, dwn_status
INTO lv_hdr_batch_ctrl_no
, ld_hdr_dwn_end_dt
, lc_hdr_dwn_status
FROM comoes.download_batch_info
WHERE download_id = 'ORCHID_SHIPMENT_HDR_INTF';
EXCEPTION
WHEN NO_DATA_FOUND THEN
DBMS_OUTPUT.PUT_LINE (' No Data Found for ORCHID_SHIPMENT_HDR_INTF in Download Batch Info table...!!!');
RAISE;
WHEN TOO_MANY_ROWS THEN
DBMS_OUTPUT.PUT_LINE (' Too Many Rows found for ORCHID_SHIPMENT_HDR_INTF in Download Batch Info table...!!!');
RAISE;
WHEN OTHERS THEN
DBMS_OUTPUT.PUT_LINE (' Following error occured while getting batch control number for ORCHID_SHIPMENT_HDR_INTF in Download Batch Info table...!!!'||SQLERRM);
RAISE;
END;
-- get the batch control number details from batch information table for shipment address
BEGIN
SELECT batch_ctrl_no
, NVL(download_end_tstamp,TO_DATE('01/01/1980','MM/DD/YYYY'))
, dwn_status
INTO lv_adr_batch_ctrl_no
, ld_adr_dwn_end_dt
, lc_adr_dwn_status
FROM comoes.download_batch_info
WHERE download_id = 'ORCHID_SHIPMENT_ADDRESS_INTF';
EXCEPTION
WHEN NO_DATA_FOUND THEN
DBMS_OUTPUT.PUT_LINE (' No Data Found for ORCHID_SHIPMENT_ADDRESS_INTF in Download Batch Info table...!!!');
RAISE;
WHEN TOO_MANY_ROWS THEN
DBMS_OUTPUT.PUT_LINE (' Too Many Rows found for ORCHID_SHIPMENT_ADDRESS_INTF in Download Batch Info table...!!!');
RAISE;
WHEN OTHERS THEN
DBMS_OUTPUT.PUT_LINE (' Following error occured while getting batch control number for ORCHID_SHIPMENT_ADDRESS_INTF in Download Batch Info table...!!!'||SQLERRM);
RAISE;
END;
-- get the batch control number details from batch information table for shipment details
BEGIN
SELECT batch_ctrl_no
, NVL(download_end_tstamp,TO_DATE('01/01/1980','MM/DD/YYYY'))
, dwn_status
INTO lv_dtl_batch_ctrl_no
, ld_dtl_dwn_end_dt
, lc_dtl_dwn_status
FROM download_batch_info
WHERE download_id = 'ORCHID_SHIPMENT_DTL_INTF';
EXCEPTION
WHEN NO_DATA_FOUND THEN
DBMS_OUTPUT.PUT_LINE (' No Data Found for ORCHID_SHIPMENT_DTL_INTF in Download Batch Info table...!!!');
RAISE;
WHEN TOO_MANY_ROWS THEN
DBMS_OUTPUT.PUT_LINE (' Too Many Rows found for ORCHID_SHIPMENT_DTL_INTF in Download Batch Info table...!!!');
RAISE;
WHEN OTHERS THEN
DBMS_OUTPUT.PUT_LINE (' Following error occured while getting batch control number for ORCHID_SHIPMENT_DTL_INTF in Download Batch Info table...!!!'||SQLERRM);
RAISE;
END;
-- if previous run is not sucess then do nothing and return.
OPEN c_com_shphdr ( ld_hdr_dwn_end_dt ) ;
LOOP
-- delete the collection for every cycle
lr_com_shphdr.DELETE;
lr_orchid_shphdr.DELETE;
lr_com_shpadr.DELETE;
lr_orchid_shpadr.DELETE;
lr_com_shpdtl.DELETE;
lr_orchid_shpdtl.DELETE;
-- fetch the order header records to collection
FETCH c_com_shphdr BULK COLLECT INTO lr_com_shphdr LIMIT 500;
-- where there is no record in the collection the exit from the loop
EXIT WHEN lr_com_shphdr.COUNT = 0;
-- build your logic there to populate the data into order header collection.
FOR i IN 1..lr_com_shphdr.COUNT
LOOP
-- accumulate header running sequence number
ln_hdr_running_seq := ln_hdr_running_seq + 1;
ln_shphdr_seq := ln_hdr_running_seq;
-- Get the business unit for the customer from com_customer
BEGIN
SELECT business_unit
INTO lv_company_code
FROM com_customer@com_pricing.world
WHERE custno = lr_com_shphdr(i).del_custno;
EXCEPTION
WHEN OTHERS THEN
lv_company_code := NULL;
END;
-- Get the ordno, confirm_date from COM_PLLINE
BEGIN
SELECT ordno
, confirm_date
INTO lv_erp_ord_no
, lv_actual_ship_date
FROM com_plline@com_pricing.world cpl
WHERE cpl.plheadno = lr_com_shphdr(i).plheadno
AND ROWNUM = 1;
EXCEPTION
WHEN OTHERS THEN
lv_erp_ord_no := NULL;
lv_actual_ship_date := NULL;
END;
-- Get the po_no, Entry_date from COM_OLINE
BEGIN
SELECT po_no
, entrydate
INTO lv_po_no
, lv_ord_date
FROM com_oline@com_pricing.world col
WHERE col.ordno = lv_erp_ord_no
AND ROWNUM = 1;
EXCEPTION
WHEN OTHERS THEN
lv_po_no := NULL;
lv_ord_date := NULL;
END;
-- To assign the Bol Number from Lading Number
IF lr_com_shphdr(i).carr_no NOT IN ('FEDX','UPS') THEN
lr_orchid_shphdr(i).bol_no := lr_com_shphdr(i).lading_no;
ELSE
lr_orchid_shphdr(i).bol_no := NULL;
END IF;
-- For each order header get the Shipment Delivery Adderss
OPEN c_com_shpadr ( lr_com_shphdr(i).custaddr);
FETCH c_com_shpadr BULK COLLECT INTO lr_com_shpadr;
-- where there is no record in the collection the exit from the loop
EXIT WHEN lr_com_shpadr.COUNT = 0;
-- biuld your logic here to populate the del address collection.
FOR j IN 1..lr_com_shpadr.COUNT
LOOP
-- accumulate the loop count into temp variable, so that will through tell each set of order header.
cnt := cnt + 1;
-- accumolate the header running sequence number.
ln_adr_running_seg := ln_adr_running_seg + 1;
ln_shpadr_seg := ln_adr_running_seg;
-- move the order address data into collection.
lr_orchid_shpadr(cnt).client_id := lr_com_shphdr(i).del_custno;
lr_orchid_shpadr(cnt).ord_no := lr_com_shphdr(i).plheadno;
lr_orchid_shpadr(cnt).tracking_no := lr_com_shphdr(i).tracking_no;
lr_orchid_shpadr(cnt).addr_name := lr_com_shpadr(j).addr_name;
lr_orchid_shpadr(cnt).attn_line := lr_com_shphdr(i).attn_line;
lr_orchid_shpadr(cnt).addr_line1 := lr_com_shpadr(j).addr_line1;
lr_orchid_shpadr(cnt).addr_line2 := lr_com_shpadr(j).addr_line2;
lr_orchid_shpadr(cnt).addr_line3 := NULL;
lr_orchid_shpadr(cnt).addr_line4 := NULL;
lr_orchid_shpadr(cnt).addr_line5 := NULL;
lr_orchid_shpadr(cnt).city := lr_com_shpadr(j).city;
lr_orchid_shpadr(cnt).state_cd := lr_com_shpadr(j).state_cd;
lr_orchid_shpadr(cnt).zip := lr_com_shpadr(j).zip;
lr_orchid_shpadr(cnt).zip_ext := NULL;
lr_orchid_shpadr(cnt).country_cd := lr_com_shpadr(j).country_cd;
lr_orchid_shpadr(cnt).tax_geo_cd := NULL;
lr_orchid_shpadr(cnt).work_phone := lr_com_shpadr(j).work_phone;
lr_orchid_shpadr(cnt).email1 := lr_com_shpadr(j).email1;
lr_orchid_shpadr(cnt).cre_dat := SYSDATE;
lr_orchid_shpadr(cnt).cre_usr := USER;
lr_orchid_shpadr(cnt).batch_ctrl_no := lv_adr_batch_ctrl_no;
END LOOP;
CLOSE c_com_shpadr;
-- For each order header get the order detail/delivery segment data
OPEN c_com_shpdtl ( lr_com_shphdr(i).plheadno );
FETCH c_com_shpdtl BULK COLLECT INTO lr_com_shpdtl;
-- where there is no record in the collection the exit from the loop
EXIT WHEN lr_com_shpdtl.COUNT = 0;
-- build your logic here to populate the order detail collection
FOR k IN 1..lr_com_shpdtl.COUNT
LOOP
-- accumulate the loop count into a temp variable, so that will through till each set of Order Header.
cnt1 := cnt1 + 1;
-- accumulate header running sequence number
ln_dtl_running_seq := ln_dtl_running_seq + 1;
ln_shpdtl_seq := ln_dtl_running_seq;
-- Get Quantity for the delvery from delevery segment table.
BEGIN
SELECT NVL(Qty,0)
INTO lv_ord_qty
FROM com_oldelseg@com_pricing.world cds
WHERE cds.ordno = lr_com_shpdtl(k).erp_ord_no
AND cds.ol_no = lr_com_shpdtl(k).erp_line_no
AND cds.ol_segno = lr_com_shpdtl(k).ol_segno;
EXCEPTION
WHEN OTHERS THEN
lv_ord_qty := NULL;
END;
-- Get Title for the salesitem from the salesitem table.
BEGIN
SELECT Title
INTO lv_sku_desc
FROM com_salesitem@com_pricing.world cs
WHERE cs.fg_id = lr_com_shpdtl(k).sku;
EXCEPTION
WHEN OTHERS THEN
lv_sku_desc := NULL;
END;
-- move the Order detail data into collection
lr_orchid_shpdtl(cnt1).client_id := lr_com_shphdr(i).client_id;
lr_orchid_shpdtl(cnt1).ord_no := lr_com_shphdr(i).plheadno;
lr_orchid_shpdtl(cnt1).ord_line_no := lr_com_shpdtl(k).ord_line_no;
lr_orchid_shpdtl(cnt1).erp_line_no := lr_com_shpdtl(k).erp_line_no;
lr_orchid_shpdtl(cnt1).sku := lr_com_shpdtl(k).sku;
lr_orchid_shpdtl(cnt1).tracking_no := lr_com_shphdr(i).tracking_no;
lr_orchid_shpdtl(cnt1).container_no := NULL;
lr_orchid_shpdtl(cnt1).ord_qty := lv_ord_qty;
lr_orchid_shpdtl(cnt1).ship_qty := lr_com_shpdtl(k).ship_qty;
lr_orchid_shpdtl(cnt1).price_point := NULL;
lr_orchid_shpdtl(cnt1).pick_invoice_no := NULL;
lr_orchid_shpdtl(cnt1).cancel_qty := NULL;
lr_orchid_shpdtl(cnt1).bldg_id := NULL; --lr_com_shpdtl(k).bldg_id;
lr_orchid_shpdtl(cnt1).sku_company := NULL; --lr_com_shpdtl(k).sku_company;
lr_orchid_shpdtl(cnt1).sku_desc := lv_sku_desc;
lr_orchid_shpdtl(cnt1).icc_cd1 := NULL; --lr_com_shpdtl(k).icc_cd1;
lr_orchid_shpdtl(cnt1).erp_ord_no := lr_com_shpdtl(k).erp_ord_no;
lr_orchid_shpdtl(cnt1).cre_dat := SYSDATE;
lr_orchid_shpdtl(cnt1).cre_usr := USER;
lr_orchid_shpdtl(cnt1).batch_ctrl_no := lv_dtl_batch_ctrl_no;
END LOOP;
CLOSE c_com_shpdtl;
-- build the logic to populate Order Header
lr_orchid_shphdr(i).client_id := lr_com_shphdr(i).client_id;
lr_orchid_shphdr(i).ord_no := lr_com_shphdr(i).plheadno;
lr_orchid_shphdr(i).tracking_no := lr_com_shphdr(i).tracking_no;
lr_orchid_shphdr(i).container_no := NULL; -- container number is not maintained in COM
lr_orchid_shphdr(i).carrier_id := lr_com_shphdr(i).carrier_id;
lr_orchid_shphdr(i).plant_id := lr_com_shphdr(i).plant_id;
lr_orchid_shphdr(i).erp_ord_no := lv_erp_ord_no;
lr_orchid_shphdr(i).erp_ord_no2 := NULL;
lr_orchid_shphdr(i).po_no := lv_po_no;
lr_orchid_shphdr(i).ship_to_id := lr_com_shphdr(i).ship_to_id;
lr_orchid_shphdr(i).ship_to_addr_id := lr_com_shphdr(i).custaddr;
lr_orchid_shphdr(i).scac := NULL; --lr_com_shphdr(i).scac;
lr_orchid_shphdr(i).actual_ship_date := lv_actual_ship_date;
lr_orchid_shphdr(i).cfm_order_type := lr_com_shphdr(i).cfm_order_type;
lr_orchid_shphdr(i).company_code := lv_company_code;
lr_orchid_shphdr(i).no_of_order_lines := NULL; --lr_com_shphdr(i).no_of_order_lines;
lr_orchid_shphdr(i).pick_invoice_no := NULL;
lr_orchid_shphdr(i).ord_date := lv_ord_date;
lr_orchid_shphdr(i).orig_tender_date := NULL;
lr_orchid_shphdr(i).orig_delv_date := NULL;
lr_orchid_shphdr(i).delivery_flag := NULL;
lr_orchid_shphdr(i).delv_date_from := NULL;
lr_orchid_shphdr(i).delv_date_to := NULL;
lr_orchid_shphdr(i).orig_carr_cd := NULL;
lr_orchid_shphdr(i).routing_comment := NULL;
lr_orchid_shphdr(i).segment_type := NULL;
lr_orchid_shphdr(i).back_order_flag := NULL;
lr_orchid_shphdr(i).addr_override_flag := NULL;
lr_orchid_shphdr(i).fmx_assigned_carr := NULL;
lr_orchid_shphdr(i).fmx_assigned_ship_date := NULL;
lr_orchid_shphdr(i).fmx_assigned_delv_date := NULL;
lr_orchid_shphdr(i).freight_terms := lr_com_shphdr(i).freight_terms;
lr_orchid_shphdr(i).fmx_load_id := NULL;
lr_orchid_shphdr(i).asn_type := NULL;
lr_orchid_shphdr(i).icc_cd1 := NULL; --lr_com_shphdr(i).icc_cd1;
lr_orchid_shphdr(i).trans_type := NULL;
lr_orchid_shphdr(i).ref_no1 := NULL;
lr_orchid_shphdr(i).ref_no2 := NULL;
lr_orchid_shphdr(i).ref_no3 := NULL;
lr_orchid_shphdr(i).ref_no4 := NULL;
lr_orchid_shphdr(i).cre_dat := SYSDATE;
lr_orchid_shphdr(i).cre_usr := USER;
lr_orchid_shphdr(i).batch_ctrl_no := lv_hdr_batch_ctrl_no;
-- logic to get total boxes and weight.
BEGIN
SELECT SUM(no_cartons), SUM(weight)
INTO lr_orchid_shphdr(i).total_boxes
, lr_orchid_shphdr(i).weight
FROM com_plline@com_pricing.world pll
WHERE pll.plheadno = lr_com_shphdr(i).plheadno;
EXCEPTION
WHEN OTHERS THEN
lr_orchid_shphdr(i).total_boxes := NULL;
lr_orchid_shphdr(i).weight := NULL;
END;
END LOOP;
-- initialize the variables for next loop cycle.
cnt := 0;
cnt1 := 0;
-- populate the shipment header interface table.
FOR x IN 1..lr_orchid_shphdr.COUNT
LOOP
ld_hdr_download_end_tstamp := lr_orchid_shphdr(x).cre_dat;
INSERT INTO orchid_shipment_hdr_intf
(record_qualifier
,client_id
,ord_no
,tracking_no
,container_no
,bol_no
,carrier_id
,plant_id
,erp_ord_no
,erp_ord_no2
,po_no
,ship_to_id
,ship_to_addr_id
,scac
,actual_ship_date
,cfm_order_type
,company_code
,no_of_order_lines
,pick_invoice_no
,total_boxes
,weight
,ord_date
,orig_tender_date
,orig_delv_date
,delivery_flag
,delv_date_from
,delv_date_to
,orig_carr_cd
,routing_comment
,segment_type
,back_order_flag
,addr_override_flag
,fmx_assigned_carr
,fmx_assigned_ship_date
,fmx_assigned_delv_date
,freight_terms
,fmx_load_id
,asn_type
,upl_status
,icc_cd1
,trans_type
,ref_no1
,ref_no2
,ref_no3
,ref_no4
,cre_dat
,cre_usr
,batch_ctrl_no)
VALUES
( 10
,lr_orchid_shphdr(x).client_id
,lr_orchid_shphdr(x).ord_no
,lr_orchid_shphdr(x).tracking_no
,lr_orchid_shphdr(x).container_no
,lr_orchid_shphdr(x).bol_no
,lr_orchid_shphdr(x).carrier_id
,lr_orchid_shphdr(x).plant_id
,lr_orchid_shphdr(x).erp_ord_no
,lr_orchid_shphdr(x).erp_ord_no2
,lr_orchid_shphdr(x).po_no
,lr_orchid_shphdr(x).ship_to_id
,lr_orchid_shphdr(x).ship_to_addr_id
,lr_orchid_shphdr(x).scac
,lr_orchid_shphdr(x).actual_ship_date
,lr_orchid_shphdr(x).cfm_order_type
,lr_orchid_shphdr(x).company_code
,lr_orchid_shphdr(x).no_of_order_lines
,lr_orchid_shphdr(x).pick_invoice_no
,lr_orchid_shphdr(x).total_boxes
,lr_orchid_shphdr(x).weight
,lr_orchid_shphdr(x).ord_date
,lr_orchid_shphdr(x).orig_tender_date
,lr_orchid_shphdr(x).orig_delv_date
,lr_orchid_shphdr(x).delivery_flag
,lr_orchid_shphdr(x).delv_date_from
,lr_orchid_shphdr(x).delv_date_to
,lr_orchid_shphdr(x).orig_carr_cd
,lr_orchid_shphdr(x).routing_comment
,lr_orchid_shphdr(x).segment_type
,lr_orchid_shphdr(x).back_order_flag
,lr_orchid_shphdr(x).addr_override_flag
,lr_orchid_shphdr(x).fmx_assigned_carr
,lr_orchid_shphdr(x).fmx_assigned_ship_date
,lr_orchid_shphdr(x).fmx_assigned_delv_date
,lr_orchid_shphdr(x).freight_terms
,lr_orchid_shphdr(x).fmx_load_id
,lr_orchid_shphdr(x).asn_type
,00
,lr_orchid_shphdr(x).icc_cd1
,lr_orchid_shphdr(x).trans_type
,lr_orchid_shphdr(x).ref_no1
,lr_orchid_shphdr(x).ref_no2
,lr_orchid_shphdr(x).ref_no3
,lr_orchid_shphdr(x).ref_no4
,lr_orchid_shphdr(x).cre_dat
,lr_orchid_shphdr(x).cre_usr
,lr_orchid_shphdr(x).batch_ctrl_no);
END LOOP;
-- populate the shipment address interface table.
FOR y IN 1..lr_orchid_shpadr.COUNT
LOOP
ld_adr_download_end_tstamp := lr_orchid_shpadr(y).cre_dat;
INSERT INTO orchid_shipment_address_intf
( record_qualifier
, client_id
, ord_no
, tracking_no
, addr_name
, attn_line
, addr_line1
, addr_line2
, addr_line3
, addr_line4
, addr_line5
, city
, state_cd
, zip
, zip_ext
, country_cd
, tax_geo_cd
, work_phone
, email1
, cre_dat
, cre_usr
, batch_ctrl_no)
VALUES ( 14
, lr_orchid_shpadr(y).client_id
, lr_orchid_shpadr(y).ord_no
, lr_orchid_shpadr(y).tracking_no
, lr_orchid_shpadr(y).addr_name
, lr_orchid_shpadr(y).attn_line
, lr_orchid_shpadr(y).addr_line1
, lr_orchid_shpadr(y).addr_line2
, lr_orchid_shpadr(y).addr_line3
, lr_orchid_shpadr(y).addr_line4
, lr_orchid_shpadr(y).addr_line5
, lr_orchid_shpadr(y).city
, lr_orchid_shpadr(y).state_cd
, lr_orchid_shpadr(y).zip
, lr_orchid_shpadr(y).zip_ext
, lr_orchid_shpadr(y).country_cd
, lr_orchid_shpadr(y).tax_geo_cd
, lr_orchid_shpadr(y).work_phone
, lr_orchid_shpadr(y).email1
, lr_orchid_shpadr(y).cre_dat
, lr_orchid_shpadr(y).cre_usr
, lr_orchid_shpadr(y).batch_ctrl_no);
END LOOP;
-- populate the shipment detail interface table.
FOR z IN 1..lr_orchid_shpdtl.COUNT
LOOP
ld_dtl_download_end_tstamp := lr_orchid_shpdtl(z).cre_dat;
INSERT INTO orchid_shipment_dtl_intf
( record_qualifier
, client_id
, ord_no
, ord_line_no
, erp_line_no
, sku
, tracking_no
, container_no
, ord_qty
, ship_qty
, price_point
, pick_invoice_no
, cancel_qty
, bldg_id
, sku_company
, sku_desc
, icc_cd1
, erp_ord_no
, cre_dat
, cre_usr
, batch_ctrl_no)
VALUES ( 20
, lr_orchid_shpdtl(z).client_id
, lr_orchid_shpdtl(z).ord_no
, lr_orchid_shpdtl(z).ord_line_no
, lr_orchid_shpdtl(z).erp_line_no
, lr_orchid_shpdtl(z).sku
, lr_orchid_shpdtl(z).tracking_no
, lr_orchid_shpdtl(z).container_no
, lr_orchid_shpdtl(z).ord_qty
, lr_orchid_shpdtl(z).ship_qty
, lr_orchid_shpdtl(z).price_point
, lr_orchid_shpdtl(z).pick_invoice_no
, lr_orchid_shpdtl(z).cancel_qty
, lr_orchid_shpdtl(z).bldg_id
, lr_orchid_shpdtl(z).sku_company
, lr_orchid_shpdtl(z).sku_desc
, lr_orchid_shpdtl(z).icc_cd1
, lr_orchid_shpdtl(z).erp_ord_no
, lr_orchid_shpdtl(z).cre_dat
, lr_orchid_shpdtl(z).cre_usr
, lr_orchid_shpdtl(z).batch_ctrl_no);
END LOOP;
COMMIT;
END LOOP;
CLOSE c_com_shphdr;
-- set the status to success
UPDATE comoes.download_batch_info
SET batch_ctrl_no = orchid_plhead_btch_ctrl_seq.NEXTVAL
, dwn_status = '90'
, download_end_tstamp = NVL(ld_hdr_download_end_tstamp,SYSDATE)
WHERE download_id = 'ORCHID_SHIPMENT_HDR_INTF'
AND batch_ctrl_no = lv_hdr_batch_ctrl_no;
UPDATE comoes.download_batch_info
SET batch_ctrl_no = orchid_address_btch_ctrl_seq.NEXTVAL
, dwn_status = '90'
, download_end_tstamp = NVL(ld_hdr_download_end_tstamp,SYSDATE)
WHERE download_id = 'ORCHID_SHIPMENT_ADDRESS_INTF'
AND batch_ctrl_no = lv_adr_batch_ctrl_no;
UPDATE comoes.download_batch_info
SET batch_ctrl_no = orchid_plline_btch_ctrl_seq.NEXTVAL
, dwn_status = '90'
, download_end_tstamp = NVL(ld_dtl_download_end_tstamp,SYSDATE)
WHERE download_id = 'ORCHID_SHIPMENT_DTL_INTF'
AND batch_ctrl_no = lv_dtl_batch_ctrl_no;
-- Update the download status to success in the interface table.
-- Shipment Header
COMMIT;
EXCEPTION
WHEN OTHERS THEN
-- load is not sucess then set the status to fail
UPDATE comoes.download_batch_info
SET dwn_status = '99'
WHERE download_id = 'ORCHID_SHIPMENT_HDR_INTF'
AND batch_ctrl_no = lv_hdr_batch_ctrl_no;
UPDATE comoes.download_batch_info
SET dwn_status = '99'
WHERE download_id = 'ORCHID_SHIPMENT_ADDRESS_INTF'
AND batch_ctrl_no = lv_adr_batch_ctrl_no;
UPDATE comoes.download_batch_info
SET dwn_status = '99'
WHERE download_id = 'ORCHID_SHIPMENT_DTL_INTF'
AND batch_ctrl_no = lv_dtl_batch_ctrl_no;
COMMIT;
DBMS_OUTPUT.PUT_LINE('Following error occured while executing ORCHID_SHIPMENT_INTF procedure...!!!'||SQLERRM);
RAISE;
END orchid_shipment_interface;Edited by: BluShadow on 03-Aug-2011 13:28
added {noformat}{noformat} tags. Please read {message:id=9360002} to learn to do this yourself. &nbPlease read the Forum FAQ on how to ask a question, particularly how to format code
SQL and PL/SQL FAQ
SQL and PL/SQL FAQ
WHEN OTHERS THEN
DBMS_OUTPUT.PUT_LINE (' Following error occured while getting batch control number for ORCHID_SHIPMENT_HDR_INTF in Download Batch Info table...!!!'||SQLERRM);
RAISE;http://tkyte.blogspot.com/2008/01/why-do-people-do-this.html -
Delete statement that uses a sub-select with the statement in the cursor
Hi all,
How to write write a delete statement that uses a sub-select with the statement in the cursor?
CURSOR excluded_dates IS
SELECT TO_TIMESTAMP(report_parameter_value, in_date_format_mask)
INTO my_current_date_time
FROM report_parameters
WHERE report_parameters.report_parameter_id = in_report_parameter_id
AND report_parameters.report_parameter_group = 'DATE_TIME'
AND report_parameters.report_parameter_name = 'EXCLUDED_DATE';
OPEN excluded_dates;
LOOP
FETCH excluded_dates INTO my_excluded_date;
EXIT WHEN excluded_dates%NOTFOUND;
DELETE FROM edr_rpt_tmp_inclusion_table
WHERE TO_CHAR(date_time, 'mm/dd/yyyy') = TO_CHAR(my_excluded_date, 'mm/dd/yyyy');
END LOOP;
CLOSE excluded_dates;ThanksHi,
In such case I think is better to create a view an perform the delete using it. Example (using HR schema):
Connected to Oracle Database 10g Express Edition Release 10.2.0.1.0
Connected as hr
SQL> create or replace view v_employees as select * from employees where first_name like 'J%';
View created
SQL> select * from v_employees;
EMPLOYEE_ID FIRST_NAME LAST_NAME EMAIL PHONE_NUMBER HIRE_DATE JOB_ID SALARY COMMISSION_PCT MANAGER_ID DEPARTMENT_ID
110 John Chen JCHEN 515.124.4269 28/09/1997 FI_ACCOUNT 8200,00 108 100
112 Jose Manuel Urman JMURMAN 515.124.4469 07/03/1998 FI_ACCOUNT 7800,00 108 100
125 Julia Nayer JNAYER 650.124.1214 16/07/1997 ST_CLERK 3200,00 120 50
127 James Landry JLANDRY 650.124.1334 14/01/1999 ST_CLERK 2400,00 120 50
131 James Marlow JAMRLOW 650.124.7234 16/02/1997 ST_CLERK 2500,00 121 50
133 Jason Mallin JMALLIN 650.127.1934 14/06/1996 ST_CLERK 3300,00 122 50
139 John Seo JSEO 650.121.2019 12/02/1998 ST_CLERK 2700,00 123 50
140 Joshua Patel JPATEL 650.121.1834 06/04/1998 ST_CLERK 2500,00 123 50
145 John Russell JRUSSEL 011.44.1344.429268 01/10/1996 SA_MAN 14000,00 0,40 100 80
156 Janette King JKING 011.44.1345.429268 30/01/1996 SA_REP 10000,00 0,35 146 80
176 Jonathon Taylor JTAYLOR 011.44.1644.429265 24/03/1998 SA_REP 8600,00 0,20 149 80
177 Jack Livingston JLIVINGS 011.44.1644.429264 23/04/1998 SA_REP 8400,00 0,20 149 80
181 Jean Fleaur JFLEAUR 650.507.9877 23/02/1998 SH_CLERK 3100,00 120 50
186 Julia Dellinger JDELLING 650.509.3876 24/06/1998 SH_CLERK 3400,00 121 50
189 Jennifer Dilly JDILLY 650.505.2876 13/08/1997 SH_CLERK 3600,00 122 50
200 Jennifer Whalen JWHALEN 515.123.4444 17/09/1987 AD_ASST 4400,00 101 10
16 rows selected
SQL> delete from v_employees where hire_date >= to_date('01/06/1998', 'dd/mm/yyyy');
2 rows deleted
SQL> regards, -
PLS-00382 Type error in the select statement in the Cursor.
Hi,
I am trying to combine several different sql statements to form one large cursor for my java layer. I have attached the PL/SQL procedure that I am using and when I am trying to compile it is giving PLS-00382 error. Please help me.
PL/SQL Code.
CREATE OR REPLACE PROCEDURE test IS
tmpVar NUMBER;
TYPE checkRecord is RECORD (
name1 APPS.EMCSV_R25_DIST_PROF_TBL.distmgrfname%TYPE,
name2 APPS.EMCSV_R25_DIST_PROF_TBL.distmgrfname%TYPE,
name3 APPS.EMCSV_R25_DIST_PROF_TBL.distmgrfname%TYPE,
name4 APPS.EMCSV_R25_DIST_PROF_TBL.distmgrfname%TYPE,
oppstatus1 APPS.EMCSV_R25_DIST_PROF_TBL.oppstatus%TYPE,
oppcount1 APPS.EMCSV_R25_DIST_PROF_TBL.oppcount%TYPE,
oppamount1 APPS.EMCSV_R25_DIST_PROF_TBL.oppamount%TYPE,
oppstatus2 APPS.EMCSV_R25_DIST_PROF_TBL.oppstatus%TYPE,
oppcount2 APPS.EMCSV_R25_DIST_PROF_TBL.oppcount%TYPE,
oppamount2 APPS.EMCSV_R25_DIST_PROF_TBL.oppamount%TYPE,
oppstatus3 APPS.EMCSV_R25_DIST_PROF_TBL.oppstatus%TYPE,
oppcount3 APPS.EMCSV_R25_DIST_PROF_TBL.oppcount%TYPE,
oppamount3 APPS.EMCSV_R25_DIST_PROF_TBL.oppamount%TYPE,
oppstatus4 APPS.EMCSV_R25_DIST_PROF_TBL.oppstatus%TYPE,
oppcount4 APPS.EMCSV_R25_DIST_PROF_TBL.oppcount%TYPE,
oppamount4 APPS.EMCSV_R25_DIST_PROF_TBL.oppamount%TYPE);
TYPE checkCur IS REF CURSOR RETURN checkRecord;
checkCurVal checkCur;
checkCurRec checkRecord;
chechcurVal checkCur;
NAME: test
PURPOSE:
REVISIONS:
Ver Date Author Description
1.0 3/8/2006 1. Created this procedure.
NOTES:
Automatically available Auto Replace Keywords:
Object Name: test
Sysdate: 3/8/2006
Date and Time: 3/8/2006, 10:01:59 AM, and 3/8/2006 10:01:59 AM
Username: (set in TOAD Options, Procedure Editor)
Table Name: (set in the "New PL/SQL Object" dialog)
BEGIN
tmpVar := 0;
OPEN checkCurVal FOR
SELECT
a.distmgrfname,
a.distmgrlname,
a.salesrepfname,
a.salesreplname,
cursor (
SELECT b.oppstatus,
b.oppcount,
b.oppamount
from APPS.EMCSV_R25_DIST_PROF_TBL b
where b.userid = '100000001' AND
b.reportid = 'ISARPTR25' AND
b.oppstatus = 'Open' AND
b.isoppstatusselected = 'Y'),
cursor (
SELECT c.oppstatus,
c.oppcount,
c.oppamount
from APPS.EMCSV_R25_DIST_PROF_TBL c
where c.userid = '100000001' AND
c.reportid = 'ISARPTR25' AND
c.oppstatus = 'Commit' AND
c.isoppstatusselected = 'Y'),
cursor (
SELECT
d.oppstatus,
d.oppcount,
d.oppamount
from APPS.EMCSV_R25_DIST_PROF_TBL d
where d.userid = '100000001' AND
d.reportid = 'ISARPTR25' AND
d.oppstatus = 'Closed-Won' AND
d.isoppstatusselected = 'Y'),
cursor (
SELECT
e.oppstatus,
e.oppcount,
e.oppamount
from APPS.EMCSV_R25_DIST_PROF_TBL e
where e.userid = '100000001' AND
e.reportid = 'ISARPTR25' AND
e.oppstatus = 'Closed-Lost' AND
e.isoppstatusselected = 'Y')
from APPS.EMCSV_R25_DIST_PROF_TBL a
where a.userid = '100000001' AND
a.reportid = 'ISARPTR25' AND
a.isoppstatusselected = 'Y' ;
LOOP
FETCH checkCurVal INTO checkCurRec;
EXIT WHEN checkCurVal%NOTFOUND;
DBMS_OUTPUT.PUT_LINE (checkCurRec.name1 ||
checkCurRec.name2 ||
checkCurRec.name3 ||
checkCurRec.name4 ||
checkCurRec.oppstatus1 ||
checkCurRec.oppcount1 ||
checkCurRec.oppamount1 ||
checkCurRec.oppstatus2 ||
checkCurRec.oppcount2 ||
checkCurRec.oppamount2 ||
checkCurRec.oppstatus3 ||
checkCurRec.oppcount3 ||
checkCurRec.oppamount3 ||
checkCurRec.oppstatus4 ||
checkCurRec.oppcount4 ||
checkCurRec.oppamount4);
END LOOP;
END test;
/Thanks for Replying.
I am trying to build a cursor to fetch the records from the table. Table structure is something like this.
reportid VARCHAR2(10) NOT NULL,
distmgrid NUMBER DEFAULT 0,
salesrepid NUMBER DEFAULT 0,
distmgrfname VARCHAR2(40 CHAR) DEFAULT 'rfname',
distmgrlname VARCHAR2(40 CHAR) DEFAULT 'rlname',
salesrepfname VARCHAR2(40 CHAR) DEFAULT 'afname',
salesreplname VARCHAR2(40 CHAR) DEFAULT 'aname',
issalesrepselected CHAR(1 CHAR) DEFAULT 'Y',
oppstatus VARCHAR2(40 CHAR) DEFAULT 'oppstatus',
isoppstatusselected CHAR(1 CHAR) DEFAULT 'Y',
oppcount NUMBER DEFAULT 0,
oppamount NUMBER DEFAULT 0,
oppquote NUMBER DEFAULT 0,
Attribute1 VARCHAR2(10 CHAR),
Attribute2 VARCHAR2(15 CHAR),
Attribute3 NUMBER,
Attribute4 NUMBER
But from the above table, I am trying to build a report for which I need a cursor which I listed in the proc. Is it not possible to build a cursor within a cursor?
Yes each individual cursor return only one row. -
Case statement 'when IN cursor'
Hi folks.
I am wondering if it is possible to use the IN command within a CASE statement?
I am trying to see if a parameter falls under certain dates in another table. I have a cursor declared which points at that column of dates, and my case statement is like so
case parameter_date when IN certain_dates then if_holiday := 1 else if_holiday := 2 end;
It doesn't like it when I try to compile. And my procedure is listed as being Invalid.
Thanks for any help :)I am wondering if it is possible to use the IN command within a CASE statement?Yes.
SQL> select dname
2 , case when deptno in ( select deptno from emp )
3 then 'Has staff' else 'empty' end
4 from dept
5 /
DNAME CASEWHEND
ACCOUNTING Has staff
RESEARCH Has staff
SALES Has staff
OPERATIONS empty
SQL>What we can't do is use PL/SQL cursors like this
case parameter_date when IN certain_dates then if_holiday := 1 else if_holiday := 2 end;
^^^^^^^^^^^^^They're not variables. At least, not that sort of variable.
Cheers, APC
blog: http://radiofreetooting.blogspot.com -
Is there any alternative statement for OPEN CURSOR?
OPEN CURSOR WITH HOLD l_cursor FOR
SELECT paledger vrgar versi perio paobjnr pasubnr belnr posnr
hzdat usnam gjahr perde wadat fadat budat altperio papaobjnr
papasubnr kndnr artnr fkart frwae kursf kursbk kurskz rec_waers
kaufn kdpos rkaufnr skost prznr bukrs kokrs werks gsber vkorg
vtweg spart hrkft plikz kstar pspnr kstrg rbeln rposn sto_belnr
sto_posnr prctr pprctr rkestatu timestmp copa_awtyp copa_aworg
copa_bwzpt copa_awsys ktgrd kmhi01 kmhi02 kmhi03 hie04 hie05
hie06 hie07 prdha ww003 kunwe pstyv ww150 vsart ww152 ww153
ww154 ww155 crmelem ww156 ww157 vbund vv002_me vv001_me vv003_me
vv002 vv070 vv071 vv072 vv073 vv074 vv075 vv076 vv077 vv078
vv079 vv080 vv081 vv095 vv096 vv040 vv104 vv001 vv003 vv004
vv028 vv105 vv150 vv151 vv152 vv153 vv154 vv155 vv038 vv068
vv030 vv156 vv157 vv158 vv159 vv160 vv161 vv162 vv035 vv166
vv167 vv168 vv169 vv170 vv171 vv172 vv163 vv164 vv165 vv045
vv046 vv047 vv059 vv031 vv032 vv039 vv173 vv195 vv194 vv193
vv192 vv191 vv184 vv185 vv186 vv187 vv188 vv189 vv190 vv174
vv175 vv176 vv177 vv178 vv179 vv180 vv181 vv182 vv183
FROM (l_table) "ce1na01
WHERE paledger IN r_curr_ty
AND vrgar IN r_record
AND perio EQ lv_period.
* Fetch in Packets of 10000
DO .
FETCH NEXT CURSOR l_cursor
INTO TABLE lt_data
PACKAGE SIZE 10000.
* No More Data
IF NOT sy-subrc IS INITIAL.
CLOSE CURSOR l_cursor.
EXIT.
ENDIF.
ENDDO.
This is my current code. while executing it is taking more time so we need optimize this statement. Could you please suggest me.No.
-
How to identify the state of system cursor
Hi All,
My requirement is to identify the state of the system cursor and when it changes to normal mode from hour glass mode i have to do an action. Of all the things i had gone through it only dealt with the cursor that appears over a java component(setCursor() method etc).
Can anyone please provide me the solution to identify the state of the system cursor.
Since i am dealing with the mouse pointer that is not subclassed from JAVA's component class even sample coding to identify the system cursors state will help.
In simple wordings,
1)A non JAVA related process is running in the foreground which will change the mouse pointers state from hour glass to regular and vice versa.
2)My JAVA program which is running in the background has to identify the systems cursor state change and trigger some events.
Note: I had tried all of the possible methods in Component class and Cursor class which never worked out.
Your solution will be of great use to me. Please help.Kaleeswaran15 wrote:
..I dont want the cursor in screenshot. What i wanted is to find the time when the mouse pointer changes its status to regular from Hourglass. .. Oh, I thought you meant to grab an image including the current cursor, and analyze the image for the presence of an arrow or hourglass. My bad.
In any case, if the user is that keen to know via your Java application whether the mouse pointer of another program has changed to the wait state, there is always..
int askTheUser = JOptionPane,showConfirmDialog(
this,
"Is XYZ app. busy?",
"XYZ app. busy?",
JOptionPane.YES_NO_OPTION);
if ( askTheUser==JOptionPane.YES_OPTION ) {
// XYZ app. is busy!
// ...... untested.
..Thank you.You are welcome. -
Simple stored procedure - select with an if statement, returning a cursor
Hi,
I'm trying to create a very simple stored procedure, but having never worked with them before I'm not quite sure what I'm doing wrong.
Here's my code:
create or replace
procedure contact_return(
v_contact_id IN varchar2,
p_cursor OUT SYS_REFCURSOR)
AS
begin
set sql_statement varchar2(4000) := '
SELECT URN,
FIRSTNAME,
LASTNAME,
TITLE,
CREATED_DT,
AREA_URN,
MOBILE,
WORK,
EMAIL,
ORG_NAME,
ADDRESS,
POSTCODE,
IN_USE
FROM CONTACT';
if v_contact_id is not null then
sql_statement := sql_statement || ' where urn = ' || v_contact_id;
end if;
open p_cursor for sql_statement;
end;
It's actually returning 2 errors:
Error(7,3): PL/SQL: SQL Statement ignored
Error(7,7): PL/SQL: ORA-00922: missing or invalid option
Which seem to be a problem with my set sql_statement line, but it looks correct to me?
Thanksrajendra wrote:
Dear User,
It is not allowed to declare a variable inside the PL/SQL block means after begin ( in your case line no 7 ).
Lot of errors in your code.
Tell me your exact requirement and what you want to do , after that I will be able to solve your problem.
Thanks,
Rajendra
Well, you can declare after the begin, though it'll be as part of an embedded code block e.g.
SQL> ed
Wrote file afiedt.buf
1 create or replace procedure contact_return(empno IN number
2 ,c OUT SYS_REFCURSOR
3 ) AS
4 begin
5 declare
6 sql_statement varchar2(4000) := '
7 select *
8 from emp
9 where empno = nvl(:1,empno)';
10 begin
11 open c for sql_statement using contact_return.empno;
12 end;
13* end;
SQL> /
Procedure created.
SQL> var x refcursor
SQL> exec contact_return(7788,:x);
PL/SQL procedure successfully completed.
SQL> print x;
EMPNO ENAME JOB MGR HIREDATE SAL COMM DEPTNO
7788 SCOTT ANALYST 7566 19-APR-1987 00:00:00 3000 20
so, it is allowed, as long as it's coded correctly. -
I cannot select Unitied States or move cursor to continue during initial set up
I am unable to get past the "Welcome" screen ... what can I do?
Yes, please read this Knowledge Base article on that issue:
Article ID: KB26582 The error "Unable to display the BlackBerry ID agreement" during setup of the BlackBerry PlayBook
1. If any post helps you please click the below the post(s) that helped you.
2. Please resolve your thread by marking the post "Solution?" which solved it for you!
3. Install free BlackBerry Protect today for backups of contacts and data.
4. Guide to Unlocking your BlackBerry & Unlock Codes
Join our BBM Channels (Beta)
BlackBerry Support Forums Channel
PIN: C0001B7B4 Display/Scan Bar Code
Knowledge Base Updates
PIN: C0005A9AA Display/Scan Bar Code -
Select statement from "v_filename_txt" inside cursor
Hi,
I've got a store procedure procedure that create parametric tables to upload from csv files. I have collect into v_filename_txt variable the parametric table name where I would like to make some select.
I have write the following code but I can't use a variable into a select statement :
select field
FROM TABLE '''||v_filename_txt||''' ;
Does anybody know how to include the precedent statement into a cursor to retrive recods ?
Paolo.You could rcreate an external table. Then select the values from this external table.
You can switch the source of the external table to a new file with the
alter table myExtTable location ('mySecondCsvFIle.csv');
command.
Of cause this works only when all the files have the same structure. But the Idea is: mimic the structure of the csv file sin the database with a external table command. Then you can read the values and move them to some other table.
Insert into myParameterTable select * from myExtTable; -
Using cursor function in sql statement
hi all
can anyone plss explain why and when we will use cursor function in a sql statement like this and what is the difference while executing this sql statement with cursor function in comparison of a simple sql statement----
select
department_name,
cursor (
select last_name
from employees e
where e.department_id = d.department_id
order by last_name
) the_employees
from departments d
thnx in advanceRTFM
http://download.oracle.com/docs/cd/B19306_01/appdev.102/b14261/sqloperations.htm#sthref1452
Cheers
Sarma. -
Number of records in cursor select statement
hi all,
with the cursor i am selecting set of select statement and writing into the .txt file.
its working file, but it should not open the file if the cursor returns nothing.
how to check for the number of records return by the select statement in the cursor.
pls help me.
Thanks..Hi,
You can use a Cursor for loop (you'll not enter in the loop if the SELECT is retrieving no rows):
begin
for recs in(select * from whatever) loop
null; -- Produce your file
end loop;
end;You can also use a bulk collect and check "yourcollection.count" attribute ... (but don't use it if you are processing a lot of records!) -
Hello All:
Is it possible to have the CASE Statement in the cursor? If so, could you please show me how to use it? I tried to use it as following but it did not work on Form Builder. I tried it on Oracle SQL *Plus and it worked there.
CURSOR tbl_chck_cur IS
SELECT chck_id,
NVL(sup_chck_id,'') sup_chck_id,
(CASE WHEN sup_chck_id = null THEN
(SELECT order_no from tbl_chck_lk where tbl_chck.chck_id = tbl_chck_lk.chck_id ) ELSE
(SELECT order_no from tbl_chck_lk
where tbl_chck.chck_id = tbl_chck_lk.chck_id ) END) order_no,
FROM tbl_chck;
Thanks in advance for any help.
KTFirst, get rid of that NVL on sup_chck_id. It does nothing. What do you want it to do, anyway???
And what is the second table "Tbl_chk_sub" in the from clause?
Ignoring tbl_chk_sub, this might work:SELECT T1.chck_id,
T1.sup_chck_id,
Decode(T1.sup_chck_id, null,LK1.order_no,Lk2.order_no) order_no
FROM tbl_chck T1,
tbl_chck_lk LK1,
tbl_chck_lk LK2
where LK1.chck_id(+) = T1.chck_id
and LK2.sup_chck_id(+) = T1.sup_chck_idIf the above does not work, you will have to find a work-around -- either do the lookup select in the post-query trigger, or create a stored function you can call from the select that returns the correct order_no based on the two columns, sup_chck_id and chck_id.
Do you know if we can use the SELECT statement inside the CASE statement?Sometimes Forms are several steps behind in adapting new sql features. So it looks like you cannot at this time. -
Cursor 'mouseover' state change not working in Chrome
Flash novice here.
I'd appreciate any tips on where to start looking for answers to this problem.
Here's the basic details:
1. 40kb banners with no audio and nothing tricky
2. Created in Flash Pro CC 2014
3. Opened and re-saved in Flash CS6 for delivery to client website
4. Client IT reports that everything is fine and banners are up and running
5. For me personally, the mouseover state for the cursor works in Safari, but not in Chrome.
6. While the mouseover cursor state for my banner is not working in Chrome, it is working for all the other banners/ads on that page.
7. A friend tested the banner on all major browsers and the mouseover cursor state works for him.
Any ideas where to look would be appreciated.
Should I be talking to the host website, examining the Flash file, or checking my version of Chrome?
Thanks in advance.This forum software is very tricky; updates to forum posts sometimes need to be done three or four times until it "takes". I have been able to update your original post.
Now that it is actually readable, I will go and have a look at it. -
How to create a cursor on a union select statement?
Hi,
Using Oracle 10g RAC +ASM ( RELEASE 1002000300)
What are is the proper way to create a cursor on a union select statement?
Is it possible?
code lines, Results in PLS-00201 error: sT := crsR.STATUS; sS := crsR.TIME;
Procedure listed below:
CREATE OR REPLACE PROCEDURE BUILD_SUMMARY IS
CURSOR csrO IS
SELECT
STATUS,
TIME
FROM (
SELECT
SUBSTR(DESCRIPTION,1,50) STATUS,
TO_CHAR(TIMESTAMP,'MM/DD/YY hh12:mi:ss') TIME
FROM GLOBALSALES.CUBE_STATUS
UNION ALL
SELECT
' TOTAL BUILD TIME',
TO_CHAR(TO_DATE('00:00:00','HH24:MI:SS') +(MAX(TIMESTAMP) - MIN(TIMESTAMP)), 'HH24:MI:SS')
FROM GLOBALSALES.CUBE_STATUS);
csrR csrO%ROWTYPE;
sT LONG :='';
sS LONG :='';
BEGIN
FOR csrR IN csrO
LOOP
sT := crsR.STATUS;
sS := crsR.TIME;
DBMS_OUTPUT.PUT_LINE(sT || ' ' || sS);
END LOOP;
END;
/csrR csrO%ROWTYPE;
Declares the csrR correct? Cursor Record of Cursor Object Type?That line declares one variable CSRR with your column structure described by the cursor (CSRO) type you declared above it. It means the CSRR variable has the columns you had in the SELECT statement in that cursor.
When you run a cursor as you did you don't need to declare the record variable. Try this:
CREATE OR REPLACE PROCEDURE build_summary IS
CURSOR csro IS
SELECT status, TIME
FROM (SELECT substr(description, 1, 50) status, to_char(TIMESTAMP, 'MM/DD/YY hh12:mi:ss') TIME
FROM globalsales.cube_status
UNION ALL
SELECT ' TOTAL BUILD TIME',
to_char(to_date('00:00:00', 'HH24:MI:SS') + (MAX(TIMESTAMP) - MIN(TIMESTAMP)),
'HH24:MI:SS')
FROM globalsales.cube_status);
--csrr csro%ROWTYPE;
st LONG := '';
ss LONG := '';
BEGIN
FOR csrr IN csro
LOOP
st := csrr.status;
ss := csrr.time;
dbms_output.put_line(st || ' ' || ss);
END LOOP;
END;Also why are you using LONG? It's a deprecated data type and Oracle recommends against using it. Either pick varchar2(4000) or CLOB.
DBMS_OUTPUT.PUT_LINE will implicitly convert that LONG data type anyway.
Maybe you are looking for
-
BIP Report does not generate in Siebel 7.8
Hi Experts, We are having a problem not generating BIP report in Siebel 7.8. It says 'failed to generate report'. The xdo.log displays [100710_043210802][oracle.apps.xdo.template.rtf.RTFParagraph][STATEMENT] stylename=Normal [100710_043210802][][STAT
-
How to remove an ipad from my account
I am given my first ipad away, how i remove this ipad from my account? I already reset all contents.
-
Version 03.03.00.XO - MLS QOS not supported
Hi All, Anyone face the same problem with the following IOS Version? MLS QOS is not supported in global command. Switch#sh ver Cisco IOS Software, IOS-XE Software, Catalyst 4500 L3 Switch Software (cat4500es8-UNIVERSALK9-M), Version 03.03.00.XO RELEA
-
My lov results into the return value instead of the display value in APEX
Hi, For 1 of the columns I'm representing in APEX, I choose 'Display as text, based on a lov'. I'm using: select aan.id||', '||r.naam||', '||a.woonplaats d, aan.id r from wmo_aanvragen aan , wmo_dossiers d , wmo_relaties r , wmo_adressen a where d.av
-
Hi All, While down loading .csv file, i can get my file name length dynamicallly upto 157 bytes but not getting more than that. I have a requirement to download very long file name. Can any one please suggest me a good solution?. My code is response.