How to prevent entering procedure date earlier than admission - visual-studio-2010

I have a form in which i have four date boxes. Arrival date and time and Procedure date and time. How to prevent entering date/time into procedure that is earlier than Arrival?

This can be done in the AfterUpdate event or perhaps even in the table. Each Field has validation rules that can be written and they always run and will stop bad data.
What have you already tried?

Related

I can't add a data date value to firebird when the day portion is greater than 12

I have an odd problem about VB6.0 programming when I add a value to database firebird from DtPicker or Calendar. When I add a date where the day is 1 to 12 it can add it into the database, but when I try to add a date where the day is the 13th or above it shows error message
Run-time error '-2147467259'(80004005)':
[ODBC Firebird Driver][Firebird]conversion error from string "13/08/2017"
The type in database is "DATE", but when I turn the type in database into "VARCHAR" everything is fine, but "VARCHAR" cannot do the function Date.
If you pass date value as a string or in context of a concatenated statement, make sure you set the value in 'YYYY-MM-DD' format (ISO_8601).
If you have prepared statements with parameters, then driver itself will handle safely data type conversions automagically. At least it should.
Last option is recommended.

PL/SQL That runs on 30th of every month

I am working on a Data Base for a library type project.
I have These tables from which I need data: Books, Reports, Articles.
Using oracle btw.
I need something (trigger or procedure or something else) that runs on the 30th of every month (or the last day), it will then analyze the date of creation of every file in those 3 tables (Books, Reports, Articles) and if the date is older than sysdate - 5 years, then a message should appear with the details of that file (name,date,author).
You have mentioned that message should appear with the details of that file (name,date,author) I am not sure where this should appear.
Still I will give an approach for this problem, you can write a procedure/function in oracle which would write such records(name,date,author) to a log table from which you can see all the details, you can also add a create date, timestamp field to the table (if you want to pull out records based on date). You can use DBMS_SCHEDULER to run the procedure/function every last day of the month. Hope this approach helps.

Create PL/SQL WatchDog/Daemon in Oracle 11gr2

I should create a watchdog that monitor a field in a table every 5 minutes, in Oracle DB. If field has a specific value (a date older than x) an action should be performed.
Is it possible to do it in PL/SQL?
If it's not, I should create a script shell and call it from crontab, or maybe use the Scheduler.
If field has a specific value (a date older than x) an action should be performed.
You could create a TRIGGER. If a new row is inserted such that the date column has a specific value, then you perform some action in the trigger.
Perhaps, you need an AFTER INSERT TRIGGER FOR EACH ROW, since you need to reference the :NEW values.
Here is the link to documentation regarding CREATE TRIGGER.
If you really want to do it as a scheduled job, then you could use DBMS_SCHEDULER. Prior to 10g releases, it was DBMS_JOB.
What you need is to use the DBMS_SCHEDULER package
The DBMS_SCHEDULER package provides a collection of scheduling functions and procedures that are callable from any PL/SQL program. (...)
The Scheduler uses a rich calendaring syntax to enable you to define repeating schedules, such as "every Tuesday and Friday at 4:00 p.m." or "the second Wednesday of every month."
Sorry, maybe I've omitted a detail the field to monitor is for a specific row. I mean if the result of the query:
select up_date from mytab where name_id='test'
is older than 15minutes
then
update mytab set value_col='no' where name_id='test'
But I don't know if it's possible to do it with a trigger. With SCHEDULER I could check at interval time and could be a good work-around.
You may still have a AFTER UPDATE trigger and in that trigger check if the updated row is the one you want to watch. Something like this:
IF :old.name_id = 'test' THEN
-- do something here
END IF;

Make column readonly on specific condition oracle

I am trying to create some kind of trigger to prevent a row being edited if it is after today's date (will use SYSDATE to get that).
I am unsure about how to do this as I am new to PL/SQL and would think perhaps some kind of package that gets the date using a cursor then uses a function to return a boolean to a procedure which then somehow stops the DML statement from firing?
Thanks in advance
Obviously you need a date column as your target. Truncating SYSDATE will give you midnight. Consequently if a truncated SYSDATE is greater than another date it must be at least the next day.
Raising an application error will cause the update to fail. Note that if you're updating multiple rows a single failure will rollback all the changes.
create or replace trigger your_trg
before update on your_table
for each row
begin
if trunc(sysdate) > :old.whatever_date then
raise_application_error(-20000, 'It is too late to change this record');
end if;
end;
the solution you are looking for is VPD Column masking.
mainly used for security purposes, VPD enables you to define row/colums level rules for data access and display.

Procedure to insert records asynchronously

I have a package where I am calling a procedure to insert records to a table and I am calling this procedure twice with a interval of 2 minutes using sys.DBMS_LOCK.sleep (<>);
Problem I facing is my calling form which is from application is still open till the insertion completes.
How can I make sure that when I submit my page and page should close, insertion should happen in backend some kind of asynchronous call. In database procedure are there any asynchronous key word to do this kind of activity?
Thanks
Update
putData(empNo,EmpName);
sys.DBMS_LOCK.sleep (<>);
putData(empNo,EmpName);
and due to the above my page stays till the second procedure finishes. I would like to close the page as soon as the first procedure finishes or when user submits the page.
Update 2
DBMS_JOB.SUBMIT(ln_dummy, 'begin putData('||empNo,EmpName||'); end;');
gives me compilation error wrong number of arguments to call Submit.
How can I resolve this?
Your PutData() procedure is expecting two parameters. You might think you're passing two parameters but you're not. Also, if EmpName is a string - which seems likely - you'll need to wrap it in escaped quotes. Basically you're writing dynamic SQL here, which is always tricky.
Try this:
DBMS_JOB.SUBMIT(ln_dummy, 'begin putData('||empNo||','''||EmpName||'''); end;');
"Other problem is how to run the these jobs at a interval of 10
minutes"
SUBMIT() can take an INTERVAL parameter. It's in the documentation for DBMS_JOB. Find out more.
However, if you want each iterationn to work with different parameter values you probably need to re-think your application design. You should have a procedure which polls a table for values to process.
Or use a queue. It depends on what you're really trying to achieve.

Resources