5: -- PROCEDURE
6: -- insert_row
7: --
8: -- DESCRIPTION
9: -- This procedure inserts rows into the table po_location_associations
10: --
11: PROCEDURE insert_row ( p_location_id IN NUMBER,
12: p_vendor_id IN NUMBER,
13: p_vendor_site_id IN NUMBER,
23: BEGIN
24:
25: l_po_location_exist := 'N';
26:
27: --Check if the location_id already exists in po_location_associations table.
28:
29: BEGIN
30: select 'Y'
31: into l_po_location_exist
28:
29: BEGIN
30: select 'Y'
31: into l_po_location_exist
32: from po_location_associations pla
33: where pla.location_id = nvl(p_location_id,0);
34: EXCEPTION
35: when no_data_found then
36: l_po_location_exist := 'N';
36: l_po_location_exist := 'N';
37: END;
38:
39: --If the parameter p_location_id is not null and it exists in
40: --po_location_associations table then update the table with the vendor_id,
41: --vendor_site_id, last_update_date, last_updated_by, last_update_login
42: --details. Else we insert the record with all the details above alongwith
43: --creation_date, created_by.
44:
44:
45: if (p_location_id is not null) then
46: if (l_po_location_exist = 'Y') then
47:
48: UPDATE po_location_associations
49: SET vendor_id = p_vendor_id,
50: vendor_site_id = p_vendor_site_id,
51: last_update_date = p_last_update_date,
52: last_updated_by = p_last_updated_by,
55: WHERE location_id = p_location_id;
56:
57: else
58:
59: INSERT into po_location_associations(location_id,
60: vendor_id,
61: vendor_site_id,
62: last_update_date,
63: last_updated_by,
95:
96: BEGIN
97: select 'Y', nvl(location_id,0)
98: into l_site_associated, l_location_id
99: from po_location_associations pla
100: where pla.vendor_site_id = p_vendor_site_id;
101:
102: EXCEPTION
103: when no_data_found then
114:
115: -- if there is a vendor site, then null out the vendor_id and vendor_site_id
116:
117: if (l_site_associated = 'Y') then
118: UPDATE po_location_associations
119: SET vendor_id = NULL,
120: vendor_site_id = NULL,
121: last_update_date = p_last_update_date,
122: last_updated_by = p_last_updated_by,
128: if (p_location_id is not null) then
129: BEGIN
130: select 'Y'
131: into l_po_location_exist
132: from po_location_associations pla
133: where pla.location_id = p_location_id;
134:
135: EXCEPTION
136: when no_data_found then
136: when no_data_found then
137: l_po_location_exist := 'N';
138: END;
139:
140: -- if po_location exists in the po_location_associations table, then update vendor_id,
141: -- vendor_site_id and other details with the new values passed by the table handler.
142: -- Else insert a row with the new values.
143:
144: if (l_po_location_exist = 'Y') then
141: -- vendor_site_id and other details with the new values passed by the table handler.
142: -- Else insert a row with the new values.
143:
144: if (l_po_location_exist = 'Y') then
145: UPDATE po_location_associations
146: SET vendor_id = p_vendor_id,
147: vendor_site_id = p_vendor_site_id,
148: last_update_date = p_last_update_date,
149: last_updated_by = p_last_updated_by,
150: last_update_login = p_last_update_login,
151: org_id = p_org_id --MO Access Control
152: WHERE location_id = p_location_id;
153: else
154: INSERT into po_location_associations ( location_id,
155: vendor_id,
156: vendor_site_id,
157: last_update_date,
158: last_updated_by,