0% found this document useful (0 votes)
29 views2 pages

Only Vendor Create

The document contains SQL statements to create a staging table called XXSD_STG_VENDOR_CREATE with columns for supplier ID, name, status, vendor ID, and error message. It then inserts records for 10 suppliers. A procedure is declared to loop through the records, create vendors, update the status and error message, and handle exceptions. Finally, queries are shown to select from the staging and vendor tables.

Uploaded by

gufran.momin25
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
29 views2 pages

Only Vendor Create

The document contains SQL statements to create a staging table called XXSD_STG_VENDOR_CREATE with columns for supplier ID, name, status, vendor ID, and error message. It then inserts records for 10 suppliers. A procedure is declared to loop through the records, create vendors, update the status and error message, and handle exceptions. Finally, queries are shown to select from the staging and vendor tables.

Uploaded by

gufran.momin25
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2

CREATE TABLE XXSD_STG_VENDOR_CREATE

(
SUPP_ID VARCHAR2 (200),
SUPP_NAME VARCHAR2 (200),
STATUS VARCHAR2 (10),
N_VENDOR_ID NUMBER (5),
ERROR_MSG VARCHAR2 (600)
);

INSERT INTO XXSD_STG_VENDOR_CREATE (SUPP_ID, SUPP_NAME)


VALUES ('1', 'GENERAL MOTORS');
INSERT INTO XXSD_STG_VENDOR_CREATE (SUPP_ID, SUPP_NAME)
VALUES ('2', 'FORD MOTORS');
INSERT INTO XXSD_STG_VENDOR_CREATE (SUPP_ID, SUPP_NAME)
VALUES ('3', 'BMW GROUP');
INSERT INTO XXSD_STG_VENDOR_CREATE (SUPP_ID, SUPP_NAME)
VALUES ('4', 'NISSAN GROUP');
INSERT INTO XXSD_STG_VENDOR_CREATE (SUPP_ID, SUPP_NAME)
VALUES ('5', 'HYUNDAI MOTOR GROUP');
INSERT INTO XXSD_STG_VENDOR_CREATE (SUPP_ID, SUPP_NAME)
VALUES ('6', 'NISSAN GROUP');
INSERT INTO XXSD_STG_VENDOR_CREATE (SUPP_ID, SUPP_NAME)
VALUES ('7', 'HYUNDAI MOTOR GROUP');
INSERT INTO XXSD_STG_VENDOR_CREATE (SUPP_ID, SUPP_NAME)
VALUES ('8', 'HONDA MOTORS');
INSERT INTO XXSD_STG_VENDOR_CREATE (SUPP_ID, SUPP_NAME)
VALUES ('9', 'MERCEDES-BENZ');
INSERT INTO XXSD_STG_VENDOR_CREATE (SUPP_ID, SUPP_NAME)
VALUES ('10', 'JAGUAR');

SELECT * FROM XXSD_STG_VENDOR_CREATE;

CURSOR vendor_int_cur IS
SELECT *
FROM Ap_Suppliers_Int
WHERE import_request_id = l_request_id
AND vendor_interface_id IS NOT NULL
ORDER BY segment1;
vendor_int_rec vendor_int_cur%ROWTYPE;
vendor_rec r_vendor_rec_type;

SELECT *
FROM ap_suppliers
WHERE vendor_id IN (SELECT n_vendor_id FROM supp_basic_data);

DECLARE
v_api_error VARCHAR2 (500);
v_error_msg VARCHAR2 (500) := NULL;
l_vendor_rec ap_vendor_pub_pkg.r_vendor_rec_type;
l_return_status VARCHAR2 (10);
l_msg_count NUMBER;
l_msg_data VARCHAR2 (1000);
l_vendor_id NUMBER;
l_party_id NUMBER;
CURSOR xx_supp
IS
SELECT * FROM supp_basic_data;
BEGIN
FOR supp_data IN xx_supp
LOOP
BEGIN
l_vendor_rec.vendor_name := supp_data.supp_name; -- Required
pos_vendor_pub_pkg.create_vendor (
-- -------------------------
-- Input Parameters
-- -------------------------
p_vendor_rec => l_vendor_rec
, -- ----------------------------
-- Output Parameters
-- ----------------------------
x_return_status => l_return_status
,x_msg_count => l_msg_count
,x_msg_data => l_msg_data
,x_vendor_id => l_vendor_id
,x_party_id => l_party_id);
COMMIT;
dbms_output.put_line (l_vendor_id);
--To ensure that the data inserted successfully
BEGIN
UPDATE supp_basic_data
SET status = 'Done', n_vendor_id = l_vendor_id, error_msg = NULL
WHERE supp_id = supp_data.supp_id;
EXCEPTION
WHEN OTHERS THEN
NULL;
END;
-- To handle unexpected errors and unsuccessful data insertion
EXCEPTION
WHEN OTHERS THEN
v_api_error := sqlerrm;
v_error_msg := v_error_msg || ' ' || v_api_error;
UPDATE supp_basic_data
SET error_msg = v_error_msg, status = 'Error'
WHERE supp_id = supp_data.supp_id;
COMMIT;
END;
END LOOP;
END;

CURSOR vendor_int_cur IS
SELECT *
FROM Ap_Suppliers_Int
WHERE import_request_id = l_request_id
AND vendor_interface_id IS NOT NULL
ORDER BY segment1;
vendor_int_rec vendor_int_cur%ROWTYPE;
vendor_rec r_vendor_rec_type;

SELECT *
FROM ap_suppliers
WHERE vendor_id IN (SELECT n_vendor_id FROM XXSD_STG_VENDOR_CREATE);

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy