function that will only insert Monday-Friday?

I've created a function that will insert a customer into the database, I just wondered if it was possible to make it so it will only except inserts on Monday to Friday days at how this would be done in Oracle SQL?

Here is the code for the function that is running and works

FUNCTION CREATE_CUSTOMER(        
       Country IN VARCHAR2
      ,First_Name IN VARCHAR2
      ,Last_Name IN VARCHAR2
      ,Birth_Date IN VARCHAR2
      ,Customer_Type IN VARCHAR2
      ,Address IN VARCHAR2
) return VARCHAR2 IS
  new_customer_id VARCHAR2(8);
BEGIN
SELECT custid_seq.NEXTVAL
INTO new_customer_id
FROM DUAL;
INSERT INTO customer (Customer_id, Country, First_Name, Last_name, Birth_date, Customer_Type, Address)
VALUES (new_customer_id, Country, First_Name, Last_name, Birth_date, Customer_Type, Address);
total_customers := total_customers + 1;
RETURN (new_customer_id);
end;

Anyone got any idea how to develop this or if its possible?

thanks

Answers


You want the insert statement to run only on Weekdays? If so, you can check the day of the weeks using

to_char(sysdate,'D')

It returns numbers 1-7(Sunday to Saturday). Based on this you can decide whether to insert or not.


Need Your Help

Three second https connection times on 3G networks

iphone ios ssl https ssl-certificate

Ping to the server on the 3G network is 80ms, about the same as on Wifi (60ms), yet the time to set up an SSL connection is 3.5 seconds on 3G, 0.5 on Wifi. This is the same using both a laptop and an

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.