Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> Re: Store Procedure Help

Re: Store Procedure Help

From: Aaron Rouse <aaron_rouse_at_yahoo.com>
Date: 10 Jan 2003 14:27:40 -0800
Message-ID: <a57b6daf.0301101427.498cfc9e@posting.google.com>


Thanks for the help and that is correct on the MAX() function is not needed. That query was originally given to me in the spec and today I noticed it was unneeded. I had tried the fetch in one form or another yesterday, I honestly can not remember if it was a exact copy in syntax as was shown, regardless it would end up erroring out. The method that did end up working for me is this:

CREATE OR REPLACE procedure SP_SLB_LOCORGSAP AS

	   BEGIN
	   		SELECT CD_SYSKEY_NEXT INTO LOOPLOC_ID FROM TMS_SYSKEY WHERE
NM_TABLE = 'LOCATIONS_DTL';
	   		FOR i IN LOC LOOP
				-- Insert in LOCATIONS_DTL
				INSERT INTO LOCATIONS_DTL

(ID_LOC, CD_LOC, NM_LST_UPDT, DT_LST_UPDT, CD_SEG)
VALUES
(LOOPLOC_ID, i.CD_LOC, i.NM_LST_UPDT, i.DT_LST_UPDT, i.CD_SEG);
-- Increment loop count LOOPLOC_ID := LOOPLOC_ID + 1; COMMIT; END LOOP; -- UPDATE new Max(CD_SYSKEY_NEXT) UPDATE TMS_SYSKEY SET CD_SYSKEY_NEXT = LOOPLOC_ID WHERE NM_TABLE = 'LOCATIONS_DTL'; COMMIT; -- Organizations Code SELECT CD_SYSKEY_NEXT INTO LOOPORG_ID FROM TMS_SYSKEY WHERE NM_TABLE = 'ORGANIZATIONS_DTL'; FOR i IN ORG LOOP -- Insert in ORGANIZATIONS_DTL INSERT INTO ORGANIZATIONS_DTL
(ID_ORG, CD_ORG, CD_ORG_TYPE, NM_LST_UPDT, DT_LST_UPDT,
CD_ORG_STATUS, CD_SEG) VALUES
(LOOPORG_ID, i.CD_ORG, 8, i.NM_LST_UPDT, i.DT_LST_UPDT, 'A', 230);
-- Increment loop count LOOPORG_ID := LOOPORG_ID + 1; COMMIT; END LOOP; -- UPDATE new Max(CD_SYSKEY_NEXT) UPDATE TMS_SYSKEY SET CD_SYSKEY_NEXT = LOOPORG_ID WHERE NM_TABLE = 'ORGANIZATIONS_DTL'; COMMIT;

END SP_SLB_LOCORGSAP; Received on Fri Jan 10 2003 - 16:27:40 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US