Function to validate the hour

«I got this feature to a friend, to validade the text field where the time format of type user as 11:30:45 ' with: "... but, this function just works, if the format is just time/min... do not work to the hour/min/segs... I have difficulty this also works with the seconds...»

If anyone can help in what should be changed...

-----------------------------------------------------------------------------------------------------
create or replace FUNCTION verifica_hora_min(
  p_campo IN VARCHAR2
)
RETURN BOOLEAN
IS
v_texto varchar(5);
v_texto1 varchar2(2);
v_texto2 varchar2(2);
v_valor1 number;
v_valor2 number;
v_palavra varchar2(75);
v_compara1 varchar2(30);
v_compara2 varchar2(30);
BEGIN
v_palavra := 'ABCDEFGHIJKLMNOPQRSTUVXYWZabcdefghijklmnopqrstuvxywz*/\|<>.,+-{}[]!?%$&^~; ';
v_texto := p_campo;

IF(v_texto IS NOT NULL)THEN
FOR i in 1..LENGTH(v_texto)LOOP
    v_compara1 := SUBSTR(v_texto, i,1);
       FOR j in 1..LENGTH(v_palavra) LOOP
            v_compara2 := SUBSTR(v_palavra, j,1);
            IF(v_compara1 = v_compara2)THEN
              RETURN FALSE;
            END IF;
       END LOOP;
END LOOP;

IF(INSTR(v_texto,':') = 3) AND LENGTH(v_texto) = 5
AND INSTR(SUBSTR(v_texto,INSTR(v_texto,':')+1), ':') = 0
THEN
  v_texto1 := SUBSTR(v_texto, 1,2);
  v_texto2 := SUBSTR(v_texto, 4,5);

  v_valor1 := TO_NUMBER(v_texto1);
  v_valor2 := TO_NUMBER(v_texto2);
  IF(v_valor1 > 23) OR (v_valor2 > 59)THEN
  return FALSE;
  ELSE
  return TRUE;
  END IF;

  ELSE
  return FALSE;
  END IF;

ELSE
   return TRUE;
END IF;
EXCEPTION
  WHEN OTHERS THEN
    RETURN FALSE;
END;
----------------------------------------------------------------------------------

tnks a lot

Published by: brugo 10/28/2009 08:00

And what you have tried so far?
Where is your attempt to implement this really bad past?

I must say it seems awfully complex for validation of time. Can not just do something like

SQL> ed
Wrote file afiedt.buf

  1  create or replace FUNCTION verifica_hora_min(p_campo IN VARCHAR2) RETURN BOOLEAN IS
  2    v_date DATE;
  3  BEGIN
  4    v_date := TO_DATE(p_campo,'HH24:MI:SS');
  5    RETURN TRUE;
  6  EXCEPTION
  7    WHEN OTHERS THEN
  8      RETURN FALSE;
  9* END;
SQL> /

Function created.

SQL> declare
  2    v_test BOOLEAN;
  3  begin
  4    v_test := verifica_hora_min('10:20:30');
  5    dbms_output.put_line(CASE WHEN v_test THEN 'TRUE' ELSE 'FALSE' END);
  6    v_test := verifica_hora_min('10:70:30');
  7    dbms_output.put_line(CASE WHEN v_test THEN 'TRUE' ELSE 'FALSE' END);
  8    v_test := verifica_hora_min('XX:XX:XX');
  9    dbms_output.put_line(CASE WHEN v_test THEN 'TRUE' ELSE 'FALSE' END);
 10  END;
 11  /
TRUE
FALSE
FALSE

PL/SQL procedure successfully completed.

Published by: BluShadow on October 28, 2009 15:11
removed the unnecessary code

Tags: Database

Similar Questions

  • Need to validate the syntax of the url by using the functions of DBMS

    All,

    I need to validate the syntax of the url in a table. Please suggest is there any function of DBMS is available to do
    action in PL/SQL, stored procedure. Help, please.

    use regular expressions... check by using the following in regexp_like...

    ^ http\: / / [a-zA-Z0 - 9-------.] +. [a-zA-Z] {2,3} (/ \S*)?$)

  • How to choose between the hours in the field Date IR with the functionality of the search bar?

    Hello

    I have an IR with a Date field (point) and when you use the features of the default IR search bar, it is possible to search for dates between 2 dates (date time), but I can't find a way to be able to allow the user to search between the hours of the date (s). I am interested in using the operator betwenn as I would like to provide to the user the possibility to choose for a period of time in the dates.

    How can I get this feature?

    TIA

    Hello

    Change the Date Format of application at: HH24:MI:SS JJ/MM/AAAA

    Sorry - I actually had this setting in my application (which is not often the case!)

    Andy

  • How to validate the field "Reason for change" in the commercial indications using JavaScript?

    How to validate the field "reason for change" in the commercial directions Summary tab using JavaScript?

    Current version of PLM4P: v6.1.1.5.2

    Please help me to validate the fields using JavaScript.

    Thank you

    Nefertari

    Developed using some of the Javascript predefined functions that we offer, it's just JavaScript and jQuery.

    But here is an example.

    (Use Internet Explorer F12 developer tools to find the IDS of the fields to work with.)

    $(document).ready(function() { 
    
        if (UI_Ext_isSpecInEditMode && UI_Ext_HasWorkflowBehavior('1005'))
        {
           //normally, we can use jquery to retrieve elements ($('#ifOfInput).val()), but it seems to fail when the id and the name attributes are the same. so we just use javascript document.getElementById instead.
           var reasonForChange = document.getElementById('ctl01$SpecSummaryctl1$ctlCollapsibleContentContainer$ctl00$txtChangeReason')
    
           if (reasonForChange != null) { 
    
                if (reasonForChange.value == null || reasonForChange.value.length == 0) {
                     UI_Ext_MarkFieldAsRequired('ctl01_SpecSummaryctl1_ctlCollapsibleContentContainer_ctl00_lblSpecSummaryReasonforChange');
                     alert('Reason For Change is required');
                }
           }
        }
    }); 
    

    However, not the user registration or workflow specification. If you were to do this, you must remove record them and workflow buttons and links, and this probably isn't the best practice. On the contrary, you would write validation server that would give you this error message if they try to save/workflow. (So most customers do not use Extensions of the user interface for this type of validation).

    Kind regards

    Ron

  • Text field to validate the entered text? -with the help of Acrobat Pro

    I use Adobe Acrobat Pro. I have created a form and I need to validate the same field to make sure that something has been entered, if nothing, then error message is displayed.

    I already have the format and typing Javascript writes:

    At the level of the JavaScript document

    function alpha() {}

    Definition of regular non-committed
    var re = / ^ [a-zA-Z \-s]+$/;

    Get all of the characters that the user has entered
    var value = AFMergeChange (event);


    Allow the land to be developed
    If (! value) return;


    If {(event.willCommit)

    Set the regular expression are committed
    var re = / ^ [a-zA-Z \-s]+$/;

    } else {/ / not committed}


    Allow only characters that match the regular expression
    Event.RC = re.test (value);
    }
    }

    Event.Value = event.value.toUpperCase ();

    Custom keystroke script

    Alpha();

    Figured it out:

    onBlur for field I entered into this:

    If (event.value =="") {}

    App.Alert ("required field: Please enter a valid name, the field cannot be empty." "");

    }

  • How to validate the interactive transformation?

    When I hit enter or double-click to validate the interactive processing stage, I get an error.

    Turn into double layer

    function InteractiveTransform() {}

    app.runMenuItem (charIDToTypeID ("FrTr"));

    };

    InteractiveTransform();

    Error:

    error.PNG

    InteractiveTransform() is a function someone wrote wrote and it looks like the the function intercepts not a cancellation or any changes made by the user.  surround the function with a try catch or difficulty of the function add a try catch inside...

    try {InteractiveTransform()}

    catch (e) {alert ("Image transform cancelled") ;}}

    try {}

    InteractiveTransform()

    }

    {catch (e)}

    = Interactive Transform =.

    function InteractiveTransform() {}

    Edit > free transform

    var desc1 = new ActionDescriptor();

    var ref1 = new ActionReference();

    Ref1.putEnumerated (cTID ('Mn'), ('MnIt') cTID, cTID ("FrTr"));

    DESC1.putReference (cTID ('null'), ref1);

    try {}

    executeAction (cTID ('slct'), desc1, DialogModes.NO);

    }

    {catch (e)}

    };

  • Validate the Date Format

    Apex 3.2

    I have a field called P14_START_DATE.

    Display as a type is Date Picker (jj. MM. YYYY).

    Now, if the user is using the pop-up calendar, the field is filled with for example 07.12.2013.

    I have 2 standard validations, not null and specified element is a valid date.

    If the user decides to enter the date, they can use a different format, for example 12/07/2013, I don't want to happen.

    How can I validate the field, so that they get an error if they do not use the exact format

    Gus

    GusC wrote:

    If the user decides to enter the date, they can use a different format, for example 12/07/2013, I don't want to happen.

    How can I validate the field, so that they get an error if they do not use the exact format

    Create a PL/SQL function to return Boolean validation for the article and try to convert the value of the element to a date by using the format mask FX to require an exact match between character data and the model format.

    declare
    
      d date;
    
      invalid_date_format exception;
        pragma exception_init(invalid_date_format, -1861);
    
      invalid_date_length exception;
        pragma exception_init(invalid_date_length, -1862);
    
    begin
    
      d := to_date(:p14_start_date, 'fxdd.mm.yyyy');
    
      return true;
    
    exception
    
      when invalid_date_format or invalid_date_length
      then
        return false;
    
    end;
    
  • Function to calculate the Minutes of business between two Dates

    Hello

    I use the version of database Oracle 11.2.1. I would like to calculate the number of minutes of work between the two dates where working hours are Monday - Thursday from 08:45 to 17:00 and Friday from 08:45 to 16:30

    I found the following function useful in a similar position but wanted help picking up the days and the hours above into account

    CREATE OR REPLACE
      FUNCTION get_bus_minutes_between(
                                       p_start_date DATE,
                                       p_end_date DATE
                                      )
        RETURN NUMBER
        IS
            v_return NUMBER;
        BEGIN
            with t as (
                       select  case level
                                 when 1 then greatest(p_start_date,trunc(p_start_date) + 9 / 24)
                                 else trunc(p_start_date) + level - 15 / 24
                               end start_dt,
                               case connect_by_isleaf
                                 when 1 then least(p_end_date,trunc(p_end_date) + 18 / 24)
                                 else trunc(p_start_date) + level - 8 / 24
                               end end_dt
                         from  dual
                         connect by level <= trunc(p_end_date) - trunc(p_start_date) + 1
                      )
            select  sum(greatest(end_dt - start_dt,0)) * 24 * 60 work_minutes
              into  v_return
              from  t
              where trunc(start_dt) - trunc(start_dt,'iw') < 5; -- exclude weekends
            RETURN v_return;
    END;
    /

    Can anyone help?

    Hello

    Think about what you do.

    sliderrules wrote:

    SELECT TO_CHAR (DATE ' 1-1-1' + business_end_time, 'HH24:MI:SS')-TO_CHAR (DATE ' 1-1-1' + business_start_time, 'HH24:MI:SS') * 24 * 60

    of time_dim

    where full_date = July 1, 2013.

    AND working_day = 'Y ';

    The following error is returned:

    ORA-01722: invalid number

    The time is converted to character reslting with this error. Is there a better way to subrtacting types of data INTERVAL DAY (1) SECOND (2) (business_end_time - business_start_time)

    To_char, as its name implies, returns a string of characters.  You say that

    TO_CHAR (...) - TO_CHAR (...) * 24 * 60

    If you ask for the string returned by the 2nd TO_CHAR be multiplied by 24.  Does make any sense to you?

    Maybe you wanted to do the subtraction first, which would be

    (TO_CHAR (...) - TO_CHAR (...)) * 24 * 60

    but still would be a mistake, because you can't subtract a string to another string (or anything else).

    .

    Last Friday, I proposed this:

    SELECT SUM (LESS (end_dt, v_end_dt)

    -Most GREAT (start_dt, v_start_dt)

    ) * 24 * 60...

    where start_dt and end_dt were the DATE in the table columns, as the value returned by TO_DATE (08 11 July 2013:45 ', "DD-Mon-YYYY HH24").

    If I understand correctly, you would store stores rather 3 columns: full_date (a DATE, where the time part is 00:00:00) as well as business_start_time and business_end_time (the two INTERVAL DAY TO SECOND).  In this case, you can modify the code above to say:

    SELECT SUM (LESS (full_date + business_end_time, v_end_dt)

    -GREATEST (full_date + business_start_time, v_start_dt)

    ) * 24 * 60...

    You can add a DATE at an INTERVAL;  the result will be a DATE.  There is no need to convert anything to a data type to the other.

  • Add the hours and minutes so far

    Hello
    I need to write a function that has two input parameters.
    Parameter1 = > Date data type, the value is in GMT.
    Parameter1 = > string value that indicates the time difference and it has the following format.

    GMT (sign) HH24Mi
    for the examples:
    GMT + 400, GMT-1400

    I need to add the offset (param2) to date (param1) and returned as output.

    I wrote a simple code but cannot make it work. I would like to know if there is another way to do it.
    create or replace
    Function         F_FUNCTION_NAME(dt date,timeZoneOffset   in   varchar2)
    return date
    As
        offset  varchar2(9);    
    Begin
        Offset := (To_Char(Substr(Substr(Timezoneoffset,4),0,Length(Substr(Timezoneoffset,4))-2)||':'||Substr(Substr(Timezoneoffset,4),-2)));
        return Dt + interval Offset hour to minute;
    End;
    Thank you.

    Hello

    Delete GMT and use the colon between the hours and minutes in this way:

    ALTER SESSION SET nls_date_format='DD-MON-YYYY HH24:MI:SS';
    
    SELECT SYSDATE
         , CAST (CAST (SYSDATE AS TIMESTAMP WITH TIME ZONE) AT TIME ZONE '+4:00' AS DATE) offset_date
      FROM DUAL;
    
    SYSDATE                OFFSET_DATE
    ---------------------- ----------------------
    06-MAR-2013 12:08:01   06-MAR-2013 15:08:01  
    

    Kind regards.
    Al

  • Conditional 'function' to play the timeline

    Hi all:

    I can't something, that I thought would be easier. I have done this in AS / Flash but it doesn't seem to work on board. I have a little animation in the timeline (1 s alpha animation 0-alpha 100 the Group of objects) and I wish she could play more accurately at a given time.

    I created a function called updateClock() which checks the time system and gets the hours and minutes and I call this function every second, so it updates with setTimeout. I have a conditional to playback of the animation at any given time (you may need to change this line) that starts at the 1000 Member, otherwise, it freezes the timeline on this same framework. Finally, I call the function.

    Currently this code is in .compositionReady, but I also tried a trigger to 1000 m to help with this would be appreciated. 1000 ms trigger sym.stop () works. Now, not even that works and the animation plays by itself.

    function updateClock() {
        var now = new Date(); // current date
                var m = d.getMinutes();
                var h = d.getHours();
    
    
        // call this function again in 1000ms
        setTimeout(updateClock, 1000);
       
        if(h== 20 && m== 56) {
    //run the animation
    sym.play(1000); 
      }
      
      else {
      sym.stop(1000);
      }
    }
    
    
    updateClock(); // initial call
    

    Thank you in advance for any help you can provide.

    Hello

    Where do you set this variable: d?

    var now = new Date();

    var m = now.getMinutes ();

    var h = now.getHours ();

    or

    var d = new Date();

    var m = d.getMinutes ();

    var h = d.getHours ();

  • OSB does not validate the XML response automatically

    Hello

    I do a synchronization in OSB Service, which is a WSDL based Service of Proxy, which in turn calls a business service that points to a target URL.
    Request XML code is passed the URI of the Proxy endpoint and response is checked.

    The WSDL and XSD to the target system are different and contain more number of fields in their 'result' of the same schema element.

    It has been observed that although XSD and WSDL present in MW have less fields mentioned in their element of 'result', OSB receives all of the fields from the target and it as response.

    Is this a normal behavior?

    Thank you.

    Hello

    I did not understand your message clearly, but I think you have one of the two questions:

    The OSB Q1 Proxy Service) receives input without validating input, and a caller he calls the target system?
    Years > OSB server does not validate the incoming request until you put only the action post.

    Proxy OSB Q2 service) receives the response from the target service (you Business Service) is still the answer is not correct and then passes the response to the caller of the Proxy function?
    Years > same as above. It should be the responsibility of the service target to receive good application and send a clean answer. OSB will validate the response (from the target service) that if you put an action validate on the response received from the target service.

    I hope this clarifies your question?

    Thank you
    Sanjay

  • How to validate the columns in tabular form date?

    Hello


    I have two columns in tabular form date

    1.start_date 2.End_date so here I need validate the end_date shouldn't be less than column start_date

    so any solution for this?

    Hello

    use a validation of type "Function returning a Boolean" and the following code:

    IF to_date(:YOUR_END_DATE,'YYYY-MM-DD') < to_date(:YOUR_START_DATE,'YYYY-MM-DD') THEN RETURN FALSE;
    ELSE RETURN TRUE;
    END IF;
    

    The date format is of course your choice.

    I hope this helps...

    Thank you
    Sandro

  • Try to download on our FTP Muse site recognizes the following FTP screen then stands up and says... "Unable to validate the specified domain that is associated with the server FTP. Still? "FYI, until I update to the 2014 version it worked fine. Pl help

    Try to download on our FTP site

    Muse recognizes the FTP

    Then the next screen appears and says...

    "Unable to validate the specified domain that is associated with the server FTP. Still? »

    FYI, before I update to version 2014 there worked well.

    Help please. Thank you. Chuck

    OK, I spent about 2 hours on the phone with the support guys Muse and here's what finally worked...

    When the second screen, enter ftp, your domain.com NOT www.yourdomain.com

    then put the name of next folder as usual.

    Why it works that way...? who knows... but it works.

    I would like to know how you do them.

    Chuck

  • Validate the Mail ID

    Hello

    I use the code to validate below mail id, but I need to validate the name of field too, at the end of the mail, it must be behive.com. If the user enters [email protected] function should return true, otherwise if the user enters [email protected] it should return false no matter what id of mail that does not end with @behive.com that should return false


    with t as (select '[email protected]' double e-mail)
    Select regexp_substr (email,'[a-zA-Z0-9.]) {1,} @([a-zA-Z0-9]{1,}\.) {1} [a-zA-Z0-9] {1,}') mail from t

    The regex above does not need your suggestion please

    Thank you
    Sudhir

    As... (Not tested)

    SQL> with t as
      2  (select '[email protected]' email
      3  from dual
      4  union all
      5  select '[email protected]' email
      6  from dual
      7  union all
      8  select '[email protected]@behive.com' email
      9  from dual
     10  union all
     11  select '[email protected]' email
     12  from dual)
     13  select email,
     14         case when regexp_like(lower(email),
     15             '^[a-z]+[a-z|0-9|\.|\_]*\@behive.com$')
     16             then 'True'
     17         else 'False' end flag
     18  from t
     19  /
    
    EMAIL                     FLAG
    ------------------------- -----
    [email protected] False
    [email protected]  True
    [email protected]@behive.com False
    [email protected] False
    
  • How can I get the hour (24-hour format) stored time value

    I have a field called start_time in a database mysql and all I have to do, but unable to do so far is part time 24-hour (without leading zeros) in this field.  I tried all the date functions, including date('G'), getdate and start_time table [hours].

    I get either today's date & time, or just first digit of he in time.

    What follows is the closest, he came to work, but it's the ethat on is back just the first digit of the hour if there are two numbers in 24-hour format (ex: 14:00 = 14, it returns oly 1)

    <? PHP

    ;

    ;

    ;

    $start_time = $row ['start_time'];
    $hour = $start_time [h];

    ;

    ;

    ;

    ? >

    Help, please!  I spent too much time on such work of subordinate.  According to me, part of my problem is that I am under PHP 4.

    Thanks in advance,

    Marcus

    marcusinfla wrote:

    Do you mean similar to the following?  I don't seem to get a value

    No, it should be part of the SQL statement:

    $lookup = "SELECT *, HOUR(start_time) AS start_hour FROM $tbl";
    

Maybe you are looking for

  • FaceTime/imessage journal by mistake on macbook 10.11.6.

    Hello I have problems with my login Factime/imessage on macbook 10.11.6. I did all the appleid checking online and my facetime/imessage works perfectly on my iphone. I deleted all the antiviruses MacBook and restarted my macbook several times. But I'

  • PREMIUM HP: HP PREMIUM: Howto recover a CASE FUNCTION

    I write a feature of the CASE, in my case I call it VP(). In the case of Mode, I want back this feature. Of course, if I have keys Alpha (with Maj!) I can type VP (3), and it works. So, I want to find my VP() function in a menu. So I try the key to t

  • Online use of relaxation on the cDAQ-9181 with a cRIO-9401 module

    I'm trying to accomplish something very simple with the cDAQ-9181 and cRIO-9401 material: when a trigger occurs, wait 20 ms and then set some digital output lines. Reading the documentation for the cDAQ-9181 and cRIO-9401, I see that there is a trigg

  • HP Compaq Pro 6300 short SMART test failed

    Hi all My HP Compaq Pro 6300 could not start. When I tried to launch short INTELLIGENT diagnosis, I have the following message: dst short: failure failure ID: mag004-000778-x87t0k-60v303 product ID: h4u35es #acb Please notify. Kind regards Arnold

  • I want to install my Vista in a new machine, will be what will have registration problems?

    Remember - this is a public forum so never post private information such as numbers of mail or telephone! Ideas: I have I removed my Vista on my computer because of the lack of Vista operating system file cache, I understand that there is now a patch