How to make the second procedure to wait untill the first procedure gets completed Using DBMS_SCHEDULER? - stored-procedures

I need to run multiple procedures one by one. The second procedure is depends upon first one and third depends on 2nd...like that i have multiple procedures.
This is my Code. First one(A_BLOCK) is executing at the given time.
BEGIN
DBMS_SCHEDULER.CREATE_JOB (
job_name => 'mxpdm.my_job1',
job_type => 'PLSQL_BLOCK',
job_action => 'BEGIN A_BLOCK; END;',
start_date => '04-FEB-15 2.25.00PM ASIA/CALCUTTA',
enabled => TRUE,
comments => 'Check');
END;
/
I don't know how to schedule and execute the second procedure B_BLOCK,after the A_BLOCK gets completed. I have searched in docs and i'm not clear,since i just started using this DBMS_SCHEDULER. Can somebody please help me?

Related

ZEOSLib: Error Message from TZReadOnlyQuery

I have been using ZeosLib Components with Delphi and Lazarus for the past 10 years or so. I'm mostly using it to access MySQL Databases.
Now I have run into a strange Problem with TZReadOnlyQuery.
In my MariaDB database I have a pretty complex stored procedure that takes some input parameters, one inout param and one out param. Because of the error I get, when I try to call it with TZReadOnlyQuery, I have made a very simple procedure to test it.
This is my test procedure:
CREATE PROCEDURE MyProc(INOUT a VARCHAR(255), OUT r VARCHAR(255))
BEGIN
set a = 'inparam changed';
set r = 'outparam set';
END
I tried to call this procedure from different MySQL query/managment tools with this statement:
set #x = 'inputparam';
call MyProc(#x, #y);
select #x, #y;
I get the expected answer: a dataset with one record and two fields like this:
But when I add the same query statement to a TZReadOnlyQuery and try to open it I get an error message:
Any ideas why this happens and how to work around it?
Thanks!

Why this code do not work in second time click button

I write this code for button click event . the first time I click the button every thing work correctly but when click for the second time on button it raise an error. whats the problem?
procedure TfrmMain.Button1Click(Sender: TObject);
var
B : Boolean;
begin
DM.tblTemp.DisableControls;
B:= DM.tblTemp.Locate('FoodName', DM.tblAsli.FieldByName('FoodName').AsString,[]) ;
if B then
begin
DM.tblTemp.Edit;
DM.tblTemp.FieldByName('Number').AsInteger:= DM.tblTemp.FieldByName('Number').AsInteger + 1;
DM.tblTemp.Post;
end
else
begin
DM.tblTemp.insert;
DM.tblTemp.FieldByName('FoodName').AsString := DM.tblAsli.FieldByName('FoodName').AsString;
DM.tblTemp.FieldByName('UnitPrice').AsInteger := DM.tblAsli.FieldByName('FoodPrice').AsInteger;
DM.tblTemp.FieldByName('Number').AsInteger := 1;
DM.tblTemp.Post;
end;
TotalPrice:= TotalPrice + DM.tblTemp.FieldByName('TotalPrice').AsInteger;
DM.tblTemp.EnableControls;
end;
the Error is
Row cannot be located for updating. Some values may have been changed
since it was last read
DM is data madual
tmbTbl is ADOTable
It is a pity you haven't said which DBMS you are using (e.g. Sql Server or MS Access,
nor told us a full list of the table's column types and indexes, if any.
The most likely answer to your q is that the variable B is set to False the first time
because the call to tblTemp.Locate fails to locate the Food name in question, so the Insert branch executes and the food's data is
added to the table but the second time the Edit branch executes and the error occurs,
though you have not said where, exactly. My guess would be on the call to .Post, because
the error message is one the ADO layer, which sits between the DBMS provider and your app,
emits when it attempts to post a change to the table but cannot identify which table row to update.
As I mentioned in a comment, the fix to this is usually at add a primary key index to the table, and I gather from your latest comment that this has succeeded for you. For the record and benefit of future readers it would be helpful if you could confirm which DBMS you are using and which Ole Driver you are using in your connection string.
Fwiw, I've tested your code using a table on MS Sql Server and MS Access and do not get the
error with either database.
Btw there is an obvious q, "How is it that tblTemp.Locate succeeds, but ADO is unable to
identify the correct record to post the update?" The answer is that tblTemp.Locate works in
a different way than identifying the relevant row to post the update.

Parameter order for webSdk procedures

I need to create some reports using the websdk pertaining to orders and price quotes.
I tried following the documentation but even the example given in the developer portal is lacking a lot of crucial information.
Specifically, I need to work with these two procedures:
ESH_WWWSHOWORDER3
ESH_WWWSHOWCPROF2
I tried writing some logic arround the sample found on https://prioritysoftware.github.io/api/procedure/#Introduction
const procedure = priority.procStart(PROC_NAME,"R", () => {},customerName, function(procSuccess){
logger.info('Proc start OK, received documentOptions');
logger.info(JSON.stringify(procSuccess));
logger.info('Specifying format...');
resolve(new Promise((resolve, reject) => {
procSuccess.proc.documentOptions(1,1,2,procSuccess => {
logger.info('Received inputFields');
logger.info(JSON.stringify(procSuccess));
procSuccess.proc.inputFields(1,{ORDNUM: ordernum}, procSuccess => {
logger.info('Received url');
logger.info(JSON.stringify(procSuccess));
});
}, procError => {
reject(procError)
})
}));
}, function(procError){
logger.error('Proc start error');
logger.error(procError);
reject(procError);
});
}).catch(err => {
logger.error(err);
})
Where PROC_NAME is WWWSHOWORDER
I am trying to understand what the process is asking of me, but it's not really clear. I tried supplying some values in the order specified by the documentation but I get errors that are not very descriptive to someone who doesn't know the ins and outs of Priority.
The logs look somehting like this
Starting Procedure WWWSHOWORDER
2019-11-26T11:55:31.718Z info: Proc start OK, received documentOptions
2019-11-26T11:55:31.719Z info: {"proc":{"name":"WWWSHOWORDER"},"type":"message","message":"No such Tabula entity"}
2019-11-26T11:55:31.721Z info: Specifying format...
2019-11-26T11:55:32.124Z info: Received inputFields
2019-11-26T11:55:32.125Z info: {"proc":{"name":"WWWSHOWORDER"},"type":"message","message":"Failure to p...
Unfortunately my logs are truncated for some strange reason...
EDIT:
I switched trying to work with ESH_WWWSHOWORDER3, I am getting an inputFields parameter, and I hope what I need to do, is take the iinputFields.input.EditFields object, and populate the value field with the name of the order, I think, unfortunately this results in a 500 error from the server...
{"proc":{"title":"(אישור הזמנה עם מפרט ללקוח (פריו","name":"ESH_WWWSHOWORDER3"},"type":"inputFields","input":{"EditFields":[{"field":1,"helpstring":"","ispassword":0,"mandatory":0,"operator":0,"readonly":0,"title":"Order","type":"text","code":"Str","value":"*","value1":"","maxlength":56,"zoom":"Zoom","format":""}],"Operators":[{"name":"= ","op":0,"title":"equals"},{"name":"< ","op":1,"title":"less than"},{"name":"<=","op":2,"title":"less than or equal to"},{"name":"> ","op":3,"title":"greater than"},{"name":">=","op":4,"title":"greater than or equal to"},{"name":"<>","op":5,"title":"not equal to"},{"name":"- ","op":6,"title":"between"},{"name":"! ","op":7,"title":"ולא"},{"name":"| ","op":8,"title":"או"}],"text":"","title":"Parameter Input"}}
2019-12-02T09:07:10.129Z info: Specifying input...
2019-12-02T09:07:10.550Z error: ###Can't connect to server. HTTP Response: 500, Internal Server Error
details: <s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" xmlns:u="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd"><s:Header><o:Security s:mustUnderstand="1" xmlns:o="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"><u:Timestamp u:Id="_0"><u:Created>2019-12-02T09:07:07.700Z</u:Created><u:Expires>2019-12-02T09:12:07.700Z</u:Expires></u:Timestamp></o:Security></s:Header><s:Body><s:Fault><faultcode xmlns:a="http://schemas.microsoft.com/net/2005/12/windowscommunicationfoundation/dispatcher">a:InternalServiceFault</faultcode><faultstring xml:lang="he-IL">Object reference not set to an instance
of an object.</faultstring><detail><ExceptionDetail xmlns="http://schemas.datacontract.org/2004/07/System.ServiceModel" xmlns:i="http://www.w3.org/2001/XMLSchema-instance"><HelpLink i:nil="true"/><InnerException i:nil="true"/><Message>Object reference not set to an instance of an object.</Message><StackTrace> at WCFService.ProcEditFieldsOKMob(String session, Boolean save, Byte[] xml)
at SyncInvokeProcEditFieldsOKMob(Object , Object[] , Object[] )
at System.ServiceModel.Dispatcher.SyncMethodInvoker.Invoke(Object instance, Object[] inputs, Object[]& outputs)
at System.ServiceModel.Dispatcher.DispatchOperationRuntime.InvokeBegin(MessageRpc& rpc)
at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage5(MessageRpc& rpc)
at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage11(MessageRpc& rpc)
at System.ServiceModel.Dispatcher.MessageRpc.Process(Boolean isOperationContextSet)</StackTrace><Type>System.NullReferenceException</Type></ExceptionDetail></detail></s:Fault></s:Body></s:Envelope>
Again, documentation does not seem to be very detailed on this topic, the EditFields object itself is not very well described...
I am also not an experienced priority user, so I am not sure where I need to navigate to check out these procedures and what else.
It seems that you are passing "R" as the second parameter, which means that you are calling for a report. Try passing "P" instead.
Also, what is customerName? according to the Web SDK I believe this should be dname: "Internal name of the company in which the procedure is run."
You can tell that WWWSHOWORDER is a Procedure and not a Report by going to System Management -> Generators -> Procedures -> Procedure Generator and querying for it. If you find it in the procedure generator - its a procedure (in this case it is a procedure which generates a report), and you should call it with a "P" parameter.
If you find the entity in Management -> Generators -> Reports-> ReportGenerator than its a plain Report and you should call it with the "R" Parameter.

How do I use a stored procedure to completely overwrite an existing table?

I have an existing table that resides in one database, and each night I want to completely overwrite all contents of this existing table (TO_TABLE), with all data from another database/table (FROM_TABLE).
Currently I am manually dropping the TO_TABLE and re-writing it using this:
INTO SDE_SPATIAL.GISADMIN.TO_TABLE
FROM GAVIN..AUTH.FROM_TABLE
This works fine, but I would eventually like to convert this into a stored procedure and get this to happen automatically every 24hrs.
Does anyone know how to do the above a bit better and ready for a stored procedure??
UPDATE:
This is the code as it currently stands. I was getting these two errors occur when I run it, the first was"Incorrect Syntax near 'ON'" and the other was "Incorrect Syntax near 'END'".
I removed the ; characters and run again, this time I was getting no errors, and the procedure was being created successfully.
CREATE
PROCEDURE [_ACC_OVERWRITE_PROPERTY_DETAILS]
AS
BEGIN
SET NOCOUNT ON
TRUNCATE TABLE
SDE_SPATIAL.GISADMIN._ACC_TEMP
INSERT
INTO
SDE_SPATIAL.GISADMIN._ACC_TEMP
(
Parcel ,
Assessment ,
House ,
Street ,
St_Type ,
Title ,
Area ,
Area_Units ,
Suburb
)
SELECT
parc.pcl_num ,
parc.ass_num ,
STAD.HOU_NUM ,
stad.str_nme ,
stad.str_typ ,
parc.fmt_ttl ,
aps.property_area ,
LOWER(aps.AREA_INDICATOR) + '²',
stad.sbr_nme
FROM
GAVIN..AUTH.AUPRSTAD stad,
GAVIN..AUTH.AUSRMAST mast,
GAVIN..AUTH.AV_PROPERTY_SUMMARY aps,
GAVIN..AUTH.AUPRPARC parc
WHERE
PARC.PCL_NUM=STAD.PCL_NUM
AND STAD.STR_NUM=MAST.STR_NUM
AND (
PARC.PCL_FLG='R'
OR PARC.PCL_FLG='P')
AND PARC.PCL_NUM=aps.PARCEL_NUMBER
AND stad.SEQ_NUM = 0
END
This is how I would do it with a SQL Server stored procedure (sorry, but I don't think you named your particular SQL dialect):
CREATE PROCEDURE [ResetSpatialData]
AS
BEGIN
SET NOCOUNT ON;
TRUNCATE TABLE SDE_SPATIAL.GISADMIN.TO_TABLE;
INSERT INTO SDE_SPATIAL.GISADMIN.TO_TABLE
([field1], [field2], [field3], [etc], [you get the idea])
SELECT [field1], [field2], [field3], [etc], [you get the idea]
FROM GAVIN..AUTH.FROM_TABLE;
END
You could then schedule this for regular execution on some time basis by using a SQL Server Agent job.
Note: corrected as per #Nick McDermaid's suggestion.

Oracle job not executing automatically after 30 seconds

I have created this Job to run a procedure. I expect it to run automatically after 30 seconds from the first execution but it does not. What could be the issue. The Job runs if I execute Manually. I am using 9i
DECLARE
X NUMBER;
BEGIN
SYS.DBMS_JOB.SUBMIT
( job => X
,what => 'ALERT_GNARATE;'
,next_date => to_date('25/11/2011 11:43:35','dd/mm/yyyy hh24:mi:ss')
,interval => 'SYSDATE+1/2880'
,no_parse => TRUE
);
SYS.DBMS_OUTPUT.PUT_LINE('Job Number is: ' || to_char(x));
END;

Resources