Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
CursorAdapter and Oracle stored procedures
Message
 
 
To
28/10/2004 12:48:39
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Miscellaneous
Thread ID:
00955370
Message ID:
00955439
Views:
42
This message has been marked as the solution to the initial question of the thread.
I use SQLEXEC to do this, but should work in CAs. My Commands usually look like:
PRIVATE pnKeyID, pcStaff_ID, pnMap_ID
TEXT TO lcSQL NOSHOW PRETEXT 1
    BEGIN InsertManager.NewMainLogRecord(nKeyID=>?@pnKeyID,
    cStaff_ID=>?pcStaff_ID, nMap_ID=>?pnMap_ID); END;
ENDTEXT
lcSQL = strtran(lcSQL, CHR(13) + CHR(10), [ ])
For the primary key, I can pass the pnKeyID by reference using the @ sign. So when the proc executes in Oracle, the nKeyID value in the Oracle SP is returned to the VFP private variable pnKeyID. The companion Oracle package below has 2 procedures where you would need just the one for this example. I keep this code in an Oracle script file [*.SQL] so I can run them from SQL*Plus or other SQL utility when I need to create them.

CREATE OR REPLACE PACKAGE InsertManager AS
PROCEDURE NewMainLogRecord
(nKeyID OUT number,
cStaff_ID IN varchar2,
nMap_ID IN number);
PROCEDURE NewCallAlertRecord
(nLogID IN number,
nTechID IN number,
nStat IN number);
END;
/
show error
CREATE OR REPLACE PACKAGE BODY InsertManager AS
PROCEDURE NewMainLogRecord
(nKeyID OUT number,
cStaff_ID IN varchar2,
nMap_ID IN number) IS
nKount number := 0;
nOldID number := -1;
BEGIN
SELECT s_HLP_MAIN_LOG.NextVal INTO nKeyID FROM DUAL;
INSERT INTO Hlp_Main_Log (KeyID, Staff_ID, Map_ID)
VALUES (nKeyID, cStaff_ID, nMap_ID);
commit;
select count(*) into nKount from Staff_Archive where Staff_ID = cStaff_ID;
if nKount > 0 then
if nKount = 1 then
select keyid into nOldID from Staff_Archive where Staff_ID = cStaff_ID;
end if;
delete from Staff_Archive where Staff_ID = cStaff_ID;
end if;
insert into Staff_Archive
(keyid, Staff_ID, FirstName, LastName, MailCode, CubeLoc, Phone)
(select nOldID, keynum, firstname, lastname, mailstop, grid,
substr(replace(rtrim(telno), '.', ''), 1, 10)
from reg6.reglocator where keynum = cStaff_ID);
commit;
END;
PROCEDURE NewCallAlertRecord
(nLogID IN number,
nTechID IN number,
nStat IN number) IS
nKount number := 0;
BEGIN
select count(*) into nKount from Hlp_Call_Alerts where Log_ID = nLogID and Tech_ID = nTechID;
if nKount = 0 then
insert into Hlp_Call_Alerts (Log_ID, Tech_ID, Status_ID)
values (nLogID, nTechID, nStat);
else
update Hlp_Call_Alerts set Status_ID = nStat
where Log_ID = nLogID and Tech_ID = nTechID;
end if;
commit;
END;
END;
/
show error
Mark McCasland
Midlothian, TX USA
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform