The following lines contain the word 'select', 'insert', 'update' or 'delete':
* This will be called only when multiple lines are inserted/Deleted
*/
PROCEDURE HANDLE_AUCTION_EXHIBIT_DETAILS(p_auction_header_id NUMBER)
IS
p_EXHIBIT_NUMBER VARCHAR2(2);
p_LAST_UPDATED_BY NUMBER;
DELETE FROM pon_auction_exhibit_details WHERE auction_header_id=p_auction_header_id
AND IS_CDRL = 'N'
AND exhibit_number in
(SELECT exhibits.exhibit_number FROM pon_auction_exhibit_details exhibits WHERE exhibits.auction_header_id=p_auction_header_id
AND IS_CDRL='N'
AND exhibit_number NOT IN (SELECT exhibit_number FROM pon_auction_item_prices_ALL items
WHERE items.auction_header_id=p_auction_header_id AND items.exhibit_number=exhibits.exhibit_number));
SELECT created_by,last_updated_by
INTO
p_CREATED_BY,p_LAST_UPDATED_BY
FROM pon_auction_headers_all
WHERE auction_header_id=p_auction_header_id;
/* SELECT exhibit_number
INTO p_EXHIBIT_NUMBER
FROM pon_auction_item_prices_ALL items
WHERE items.auction_header_id=p_auction_header_id
AND items.exhibit_number IS NOT NULL
AND NOT EXISTS
(SELECT exhibit_number FROM pon_auction_exhibit_details exhibits
WHERE auction_header_id=p_auction_header_id AND IS_CDRL='N' AND items.exhibit_number=exhibits.exhibit_number)
AND ROWNUM=1;*/
INSERT INTO pon_auction_exhibit_details
(AUCTION_HEADER_ID,
EXHIBIT_NUMBER,
IS_CDRL,
ASSOCIATED_TO_LINE,
EXHIBIT_DESCRIPTION,
CREATION_DATE,
CREATED_BY,
LAST_UPDATE_DATE,
LAST_UPDATED_BY) (
SELECT
p_auction_header_id,
exhibit_number,
'N',
NULL,
NULL,
SYSDATE,
p_CREATED_BY,
SYSDATE,
p_LAST_UPDATED_BY
FROM pon_auction_item_prices_ALL items
WHERE items.auction_header_id=p_auction_header_id
AND items.exhibit_number IS NOT NULL
AND NOT EXISTS
(SELECT exhibit_number FROM pon_auction_exhibit_details exhibits
WHERE auction_header_id=p_auction_header_id AND IS_CDRL='N' AND items.exhibit_number=exhibits.exhibit_number)
GROUP BY exhibit_number);
/* This api will Insert data into Exhibit Details table
* This will be called when single exhibit line is created/Modified
*/
PROCEDURE CREATE_EXHIBIT_DETAILS(p_auction_header_id NUMBER,p_old_exhibit_number varchar2,p_exhibit_number varchar2)
IS
number_of_exhibits NUMBER;
p_LAST_UPDATED_BY NUMBER;
SELECT Count(*)
INTO number_of_exhibits
FROM pon_auction_exhibit_details
WHERE auction_header_id=p_auction_header_id
AND exhibit_number=p_exhibit_number
AND IS_CDRL='N';
SELECT Count(*)
INTO number_of_lines
FROM pon_auction_item_prices_all
WHERE auction_header_id=p_auction_header_id
AND exhibit_number=p_exhibit_number
AND ROWNUM=1;
INSERT INTO pon_auction_exhibit_details
(AUCTION_HEADER_ID,
EXHIBIT_NUMBER,
IS_CDRL,
CREATION_DATE,
LAST_UPDATE_DATE
)
values (p_auction_header_id,p_exhibit_number,'N',SYSDATE,SYSDATE);
DELETE_EXHIBIT_DETAILS(p_auction_header_id ,p_old_exhibit_number);
/* This api will Delete data from Exhibit Details table
* This will be called when single exhibit line is deleted/Modified
*/
PROCEDURE DELETE_EXHIBIT_DETAILS(p_auction_header_id NUMBER,p_exhibit_number varchar2)
IS
number_of_lines NUMBER;
SELECT Count(*)
INTO number_of_lines
FROM pon_auction_item_prices_all
WHERE auction_header_id=p_auction_header_id
AND exhibit_number=p_exhibit_number
AND ROWNUM=1;
DELETE from pon_auction_exhibit_details
WHERE auction_header_id=p_auction_header_id
AND exhibit_number=p_exhibit_number
AND IS_CDRL='N';
/* This api is used when CLINs are deleted in a Solicitation
* If there are exhibits linked to the deleted CLIN, those links will be removed by this procedure
* p_line_number is used based on single clin delete or multiple clin delete
*/
PROCEDURE UPDATE_EXHIBIT_DETAILS(p_auction_header_id NUMBER,p_line_number NUMBER)
IS
BEGIN
IF(IS_EXHIBITS_ENABLED_FOR_AUC(p_auction_header_id) = 'N') THEN
RETURN;
UPDATE pon_auction_exhibit_details
SET ASSOCIATED_TO_LINE=NULL
WHERE AUCTION_HEADER_ID=p_auction_header_id
AND ASSOCIATED_TO_LINE = p_line_number;
UPDATE pon_auction_exhibit_details
SET ASSOCIATED_TO_LINE=NULL
WHERE AUCTION_HEADER_ID=p_auction_header_id
AND ASSOCIATED_TO_LINE
NOT IN (SELECT line_number FROM pon_auction_item_prices_all WHERE AUCTION_HEADER_ID=p_auction_header_id);
select count(1) INTO l_cdrl_count
FROM okc_deliverables
where business_document_id = p_auction_header_id
and business_document_version = -99
and del_category_code = 'CDRL'
and exhibit_code = p_exhibit_number;
INSERT_CDRL_EXHIBIT_DETAILS(p_auction_header_id,p_new_exhibit_number,p_return_status,p_msg_data);
/* This api is to Delete Exhibits
*/
PROCEDURE DELETE_EXHIBITS(
p_auction_header_id NUMBER,
p_doctype_id NUMBER,
p_user_id NUMBER,
p_exhibit_number VARCHAR2,
p_is_cdrl VARCHAR2)
IS
p_msg_data VARCHAR2(1000);
DELETE_ELINS(p_auction_header_id,p_doctype_id,p_user_id,p_exhibit_number);
OKC_CDRL_PVT.delete_cdrl_for_exhibits
(p_api_version => 1.0,
p_init_msg_list => FND_API.G_TRUE,
p_commit => FND_API.G_FALSE,
--p_doc_class => 'SOURCING',
p_doc_type => 'SOLICITATION',
p_doc_id => p_auction_header_id,
p_doc_version => NULL,
p_mode => NULL,
p_exhibit_tbl => l_exhibit_tbl,
x_msg_data => p_msg_data,
x_msg_count => p_msg_count,
x_return_status => p_return_status);
DELETE_CDRL_EXHIBIT_DETAILS(p_auction_header_id,p_exhibit_number,p_return_status);
SELECT lookup_code
INTO p_new_exhibit_number
FROM (select lookup_code
from fnd_lookup_values
where lookup_type = 'PO_CLM_EXHIBIT_NUMBER'
AND Length(lookup_code) = 1
AND lookup_code NOT IN
(SELECT exhibit_number FROM pon_auction_exhibit_details WHERE auction_header_id=p_source_auction_header_id)
ORDER BY lookup_code)
WHERE ROWNUM=1;
SELECT lookup_code
INTO p_new_exhibit_number
FROM (select lookup_code
from fnd_lookup_values
where lookup_type = 'PO_CLM_EXHIBIT_NUMBER'
AND lookup_code NOT IN
(SELECT exhibit_number FROM pon_auction_exhibit_details WHERE auction_header_id=p_source_auction_header_id)
ORDER BY length(lookup_code), lookup_code)
WHERE ROWNUM=1;
SELECT line_number
BULK COLLECT INTO p_lines
FROM pon_auction_item_prices_all
WHERE auction_header_id = p_auction_header_id
AND exhibit_number = p_exhibit_number;
SELECT Max(line_number)
INTO p_initial_line_number
FROM pon_auction_item_prices_all WHERE
auction_header_id = p_auction_header_id;
SELECT Max(line_number)
INTO p_final_line_number
FROM pon_auction_item_prices_all WHERE
auction_header_id = p_auction_header_id;
SELECT X,p_new_exhibit_number||Decode(Length(p_new_exhibit_number)
+Length(pon_clo_renumber_pkg.DECIMAL_TO_ELIN(X)),4,'',3,'0',2,'00')
||pon_clo_renumber_pkg.DECIMAL_TO_ELIN(X) AS NEXT_ELIN_SET
BULK COLLECT INTO p_line_numbers,p_line_num_displays
FROM
(SELECT LEVEL AS X
FROM dual
CONNECT BY LEVEL <=p_final_line_number-p_initial_line_number+1);
UPDATE pon_auction_item_prices_all
SET exhibit_number = p_new_exhibit_number,
line_num_display=p_line_num_displays(i)
WHERE auction_header_id = p_auction_header_id
AND line_number=p_line_numbers(i)+p_initial_line_number;
SELECT NVL(MAX(line_number),0)
INTO P_LINE_NUMBER
FROM pon_auction_item_prices_all
WHERE auction_header_id = p_source_auction_header_id;
SELECT Count(*)
INTO P_NO_OF_LINES
FROM pon_auction_item_prices_all
WHERE auction_header_id = p_source_auction_header_id;
UPDATE PON_AUCTION_HEADERS_ALL
SET NUMBER_OF_LINES = P_NO_OF_LINES,
LAST_LINE_NUMBER = P_LINE_NUMBER
WHERE AUCTION_HEADER_ID = p_source_auction_header_id;
PROCEDURE DELETE_ELINS(
p_auction_header_id NUMBER,
p_doctype_id NUMBER,
p_user_id NUMBER,
p_exhibit_number VARCHAR2)
IS
p_source_auction_header_id NUMBER := p_auction_header_id;
p_number_of_lines_deleted NUMBER;
LOG_MESSAGE('delete_lines','IS_EXHIBITS_ENABLED_FOR_AUC:'||'Y' );
SELECT line_number
BULK COLLECT INTO p_lines
FROM pon_auction_item_prices_all
WHERE auction_header_id = p_auction_header_id
AND exhibit_number = p_exhibit_number;
LOG_MESSAGE('delete_lines','After Collecting the line number of the exhibit Lines' );
pon_clm_clo_util_pkg.delete_single_line
(p_auction_header_id=> p_auction_header_id,
p_line_number => p_lines(i),
x_result => p_result,
x_error_code => p_error_code,
x_error_message => p_error_message,
x_number_of_lines_deleted => p_number_of_lines_deleted);
LOG_MESSAGE('delete_lines','Number of Lines Deleted'||p_number_of_lines_deleted);
LOG_MESSAGE('delete_lines','Remove Exhibit Details record' );
DELETE_EXHIBIT_DETAILS(p_source_auction_header_id,p_exhibit_number);
LOG_MESSAGE('delete_lines','Delete Lines Completed' );
SELECT NVL(MAX(line_number),0)
INTO P_LINE_NUMBER
FROM pon_auction_item_prices_all
WHERE auction_header_id = p_source_auction_header_id;
SELECT Count(*)
INTO P_NO_OF_LINES
FROM pon_auction_item_prices_all
WHERE auction_header_id = p_source_auction_header_id;
UPDATE PON_AUCTION_HEADERS_ALL
SET NUMBER_OF_LINES = P_NO_OF_LINES,
LAST_LINE_NUMBER = P_LINE_NUMBER
WHERE AUCTION_HEADER_ID = p_source_auction_header_id;
LOG_MESSAGE('delete_lines','Exception in Delete Lines' );
SELECT Count(*)
INTO l_elin_count
FROM pon_auction_exhibit_details
WHERE auction_header_id = p_auction_header_id
AND associated_to_line = p_line_number
AND Nvl(is_cdrl, 'N') = 'N';
SELECT Decode(Nvl(exhibit_number, '-1'), '-1' , 'N', 'Y')
INTO l_is_elin
FROM pon_auction_item_prices_all
WHERE auction_header_id = p_auction_header_id
AND line_number = p_line_number;
SELECT org_id, doctype_id
INTO l_org_id,l_doctype_id
FROM pon_auction_headers_all
WHERE auction_header_id = p_auction_header_id;
/* This api will Insert data into Exhibit Details table for cdrls.
* This will be called from okc code.
* If cdrl record already exists : x_return_status = 'S', x_return_msg := 'CDRL_RECORD_EXISTS'
* If p_exhibit_number is used by elins : x_return_status = 'U', x_return_msg := 'EXHIBIT_NUM_USED_BY_ELIN'
*/
PROCEDURE INSERT_CDRL_EXHIBIT_DETAILS(p_auction_header_id IN NUMBER,
p_exhibit_number IN VARCHAR2,
x_return_status OUT NOCOPY VARCHAR2,
x_return_msg OUT NOCOPY VARCHAR2)
IS
l_cdrl_exists VARCHAR2(1);
SELECT Nvl(is_cdrl, 'E')
INTO l_cdrl_exists
FROM pon_auction_exhibit_details
WHERE auction_header_id=p_auction_header_id
AND exhibit_number=p_exhibit_number;
INSERT INTO pon_auction_exhibit_details
(AUCTION_HEADER_ID,
EXHIBIT_NUMBER,
IS_CDRL,
ASSOCIATED_TO_LINE,
EXHIBIT_DESCRIPTION,
CREATION_DATE,
CREATED_BY,
LAST_UPDATE_DATE,
LAST_UPDATED_BY)
VALUES
(p_auction_header_id,p_exhibit_number,'Y', NULL, NULL, SYSDATE,l_user_id,SYSDATE,l_user_id);
END INSERT_CDRL_EXHIBIT_DETAILS;
/* This api will delete cdrl exhibit record from pon_auction_exhibit_details table.
* This api should be called by okc code.
*/
PROCEDURE DELETE_CDRL_EXHIBIT_DETAILS(p_auction_header_id IN NUMBER,
p_exhibit_number IN VARCHAR2,
x_return_status OUT NOCOPY VARCHAR2)
IS
BEGIN
DELETE FROM pon_auction_exhibit_details
WHERE auction_header_id = p_auction_header_id
AND exhibit_number = p_exhibit_number
AND is_cdrl = 'Y';
END DELETE_CDRL_EXHIBIT_DETAILS;