Procedure of checking of letters in a collum

Hi,I have a table called "check_in_time"

I have columns

Integer ID

client_name varchar2 (10 BTYES)

check_in_time (5 BTYES)

check_out_time varchar2 (5 BTYES)

Because this scheme is managed by someone else I can't change the data type for him.

The question is now that this system users some featuring letters in the 'check_in_time' instead of 12:00 by one example

and for this reason another application in looking at 'check_in_time' appears an error and it's beginning of the different issues because

you are not sure what time the guest access to your room.

to stop this I want to rewrite a pl/sql procedure that runs every 12 hours and then send me and send me. If the check_in_time column

as a letter or something other than time as 00:00 to 23:59.

is this possible? If Yes please can you show me and example.

Thank you

You can add a constraint to the table?

In this case, you can check for the correct format. Of course, you will need to change all the defective data first.

Example:

SQL > create table test_time (check_in_time varchar2 (5));

Table created.

SQL > alter table test_time Add (constraint ck_check_in_time1

2 check (regexp_like (check_in_time, ' ^ ([0-1].)) ([0-9] | 2 [0-3]):[0-5][0-9]$')));

Modified table.

SQL > insert into test_time values (12:34 ');

1 line of creation.

SQL > insert into test_time values (23:59 ');

1 line of creation.

SQL > insert into test_time values (2:34 ');

1 line of creation.

SQL > insert into test_time values (24:21 ');

insert into test_time values (24:21 ')

*

ERROR on line 1:

ORA-02290: check constraint (P1ECOM. CK_CHECK_IN_TIME1) violated

SQL > insert into test_time values (' ab: 14 ");

insert into test_time values (' ab: 14 ')

*

ERROR on line 1:

ORA-02290: check constraint (P1ECOM. CK_CHECK_IN_TIME1) violated

SQL > select * from test_time;

CHECK

-----

12:34

23:59

02:34

SQL > drop table test_time;

Deleted table.

But of course, it is always better to keep the time as a time of (date), and not as a string.

Tags: Database

Similar Questions

  • Create the procedure to check existing data, then update, if not then insert.

    Dear all,

    Help, please
    I create a procedure to check the current data are available or not tables, if not match, the row in the table will insert another table, if matched, data will be updated.
    table source: Table_read;
    check table: stor_matdata;
    key to two table ID is (assy_no and t.produced_number).
    Here's the code I create, but he still has an error...
    ---------------------------------------------------------------------

    create or replace
    procedure Matched
    as
    Start
    Fusion in stor_matdata m using double on (m.assy_no = t.produced_number)
    When not matched then insert into stor_matdata (sequence_id, assy_no, package, basic_type, materialnumber, factor, mattype)
    Select rownum, t.producednumber, t.package_name, t.basic_type, t.consumed_number, t.factor, t.mattype FROM (select * from Table_read xxxx) t
    when matched, then update package set = t.package_name, basic_type = t.basic_type, materialnumber = t.consumed_number, = t.factor, mattype = t.mattype, sequence_id = rownum factor;
    end Matched;


    Thank you and best regards,

    Hadi

    There is a support missing after values

            VALUES (
                    t.r
                   ,t.producednumber
                   ,t.package_name
                   ,t.basic_type
                   ,t.consumed_number
                   ,t.factor
                   ,t.mattype
                   );
    

    Concerning
    Marcus

  • How to write a pl/sql procedure that checks the remote db?

    Hi all

    I have one criticism PROD remote database I want to check every 10 minutes for its connectivity. If the connection fails then an email and a text Message is sent to me.
    My question is what is the best way to check if the remote database is running?

    Can I use sqlplus system/manager@PROD? But sometimes this has taken so long and suspended. I want the best response time?

    How can I write a pl/sql procedure control connection? What do something like the ff:

    I created a table for my tnsname.ora entries.
    cursor is c1 select dbname from tnsnames_tbl;
    begin
        connect system/[email protected];
        print c1.dbname || 'DB Connection OK';
        exception
           when others;
            print c1.dbname || 'DB Connection Not OK';
        end;
    end;
    Something like that?

    Thank you
    Kinz

    Not really feasible at the level of PL/SQL.

    The reason is that the greatest strength of TCP's robustness. TCP will try as hard as possible to succeed, before failing. It was designed to still work on the severely damaged or broken communication as a result of nuclear infrastructure. A TCP connection can take up to 15 minutes, maybe even more, before failing. It can be as slow as a turtle-, but he's wearing a hardshell. (unlike the UDP, which is the opposite)

    So if you want to test the TCP connectivity, you must design your own custom code to implement your assumptions about the latency of packets, earthquakes and drops and so on.

    Otherwise, you will need to use a standard TCP socket, set a time limit, try to login - and hope for the best.

    This approach, I have demonstrated in {message identifier: = 10111306}.

    If the TCP test works, it means that the listener is in place. Does not mean that the database itself is in place. Which means then using a database link to be tested. And this in turn can hang due to problems with archive record being stuck, not enough idle servers shared, etc..

  • I ve got a message from hotmail asking my password by saying that if I send my account will be inactive. He said that it is a procedure for checking of inactive accounts.

    is this a phishing?

    Hello

    It's a SCAM

    do not take account of this

  • What is the best way/procedure to check the s10-3/Lenovo updates?

    What is the best way to get updates and drivers Lenovo... ect for my new s10-3.  Thank you, Bill

    Yes, that's correct. In addition, you will notice that most of the drivers have been downloaded 12/31/09. Something more recent that this means that it is a driver newly updated and you can download it.

  • When trying to start the disk check procedure, I get the answer, "cannot open volume for direct access. How can I fix?

    I get the above answer everytime I turn on the computer. (This is with AutoCorrect blocks checked). If I leave blocks unchecked, it follows a procedure 3 pass without rebooting and does not produce a result.

    * original title - to try to start the procedure of checking disk I get the answer, "cannot open volume for direct access. How can I fix? I ran the GET Microsoft virus check tnd an own result.*

    The application-specific permission settings do not authorization for the application server COM with the CLSID
    {DCBCA92E-7DBE-4EDA-8B7B-3AAEA4DD412B}
    the user NT AUTHORITY\SYSTEM SID (S-1-5-18). This security permission can be modified using the Component Services administrative tool.

    In the opposite case

    http://blog.ray1.NET/2008/01/WinXP-SP3-DCOM-system-error-dcbca92e.html

    http://TechNet.Microsoft.com/en-us/network/bb545879

    http://www.blackviper.com/wiki/Network_Access_Protection_Agent

  • Procedure check constraint

    Hi all

    My procedure should check, if the constraints are violated, and if they do then the insertion must be rejected.

    How can I insert a code to this procedure to verify if the constraints are vilolated?

    Procedure:

    CREATE PROCEDURE add_new_customer)
    IN cust_no customer. CUST_NO % TYPE,
    c_name IN client. C_NAME % TYPE,
    IN c_city customer. C_CITY % TYPE,
    client IN c_telno. C_TELNO % TYPE,
    client IN c_faxno. C_FAXNO % TYPE,
    client IN cust_code. CUST_CODE % TYPE,
    client IN office_no. OFFICE_NO % TYPE)
    AS

    v_cust_no NUMBER (5);
    v_c_name VARCHAR (30): = 'John ';
    v_c_city VARCHAR (30): = "London";
    v_c_telno VARCHAR (20): = '07812586060';
    v_c_faxno varchar (20): = ";
    v_cust_code VARCHAR (2): = ';
    v_office_no NUMBER (5): = 125;

    BEGIN
    INSERT INTO customer (cust_no, c_name, c_city, c_telno, c_faxno, cust_code, office_no)
    VALUES (CUST_NO_SEQ. NEXTVAL, Upper (v_c_name), Upper (v_c_city), v_c_telno, v_c_faxno, Upper (v_cust_code), v_office_no);
    END;
    /



    Constraints are the following:

    Check the cust_code IN('A+','A','B1','B2','C1','C2',null) CUSTOMER_CUST_CODE_CK
    Primary_Key CUSTOMER_CUST_NO_PK
    Foreign_Key CUSTOMER_OFFICE_NO_FK
    SYS_C009827 check the "CUST_NO" IS NOT NULL
    SYS_C009828 check the "C_NAME' IS NOT NULL
    SYS_C009829 check the "C_CITY' IS NOT NULL
    SYS_C009830 check the 'C_TELNO' IS NOT NULL


    Thank you very much!!!

    Published by: 899335 on December 12, 2011 11:38

    Published by: 899335 on December 12, 2011 11:39

    >

    My code does not work:

    It is probably for this reason

    e_values EXCEPTION;
    

    It is declared in the executable section, when it should be declared in the declaration section.
    This is how the variables.

    There are other problems with your procedure. I have listed below as well as additional comments on things
    You should and should not do.

    -- 1.
    -- Use CREATE OR REPLACE - Much easier to work with
    CREATE OR REPLACE PROCEDURE add_new_customer (
    -- 2.
    -- Naming formal parameters exactly like table columns is not a good
    -- idea. You can run into hard to detect scope problems.
    -- The convention is some prefix, like P_ or IN_
      in_cust_no     IN customer.cust_no%TYPE,
      in_c_name      IN customer.c_name%TYPE,
      in_c_city      IN customer.c_city%TYPE,
      in_c_telno     IN customer.c_telno%TYPE,
      in_c_faxno     IN customer.c_faxno%TYPE,
      in_cust_code   IN customer.cust_code%TYPE,
      in_office_no   IN customer.office_no%TYPE
    ) AS
    
    -- 3.
    -- These variables are exactly the same as input parameters, you don't need them
    --  v_cust_no     NUMBER (5);
    --  v_c_name      VARCHAR (30) := 'Marcelo';
    --  v_c_city      VARCHAR (30) := 'London';
    --  v_c_telno     VARCHAR (20) := '07812586857';
    --  v_c_faxno     VARCHAR (20) := '';
    --  v_cust_code   VARCHAR (2) := '';
    --  v_office_no   NUMBER (5) := 125;
    BEGIN
    -- 4.
    -- You cannot declare anything here, you are in executable section
      -- e_values EXCEPTION;
      INSERT INTO customer (cust_no,
                            c_name,
                            c_city,
                            c_telno,
                            c_faxno,
                            cust_code,
                            office_no
                           )
    -- 4.
    -- You probably want to use the procedure's input parameters here, otherwise they aren't used.
      VALUES      (cust_no_seq.NEXTVAL,
                   UPPER (in_c_name),
                   UPPER (in_c_city),
                   in_c_telno,
                   in_c_faxno,
                   UPPER (in_cust_code),
                   in_office_no
                  );
    
    -- 5.
    -- This is dead code, like in never reached. If v_cust_code were null,
    -- this would not be reached since the INSERT INTO would have raised an
    -- exception.
    --   IF v_cust_code = NULL THEN
    --     RAISE e_values;
    --   END IF;
    
    -- 5.
    -- Most often it is a bad idea to COMMIT inside a stored procedure.
    -- If you do the procedure will not be useful as part of a bigger transaction.
    --  COMMIT;
    
    -- 6.
    -- If you do not have anything reasonable to do with exceptions, don't handle it.
    -- Printing it out is not exception handling. You gain nothing, compared to letting
    -- it be (Called let it propagate).
    -- It is perfectly fine to let exceptios propagate, and very common.
    -- EXCEPTION
    --   WHEN e_values THEN
    --     DBMS_OUTPUT.put_line ('Cust Code cannot be empty.');
    
    -- 7.
    -- Use End Identifiers. Especially, once you start working with packages, they
    -- are very useful to keep track of where things end and what ends.
    END add_new_customer;
    /
    

    So, if I remove all my comments now, your procedure now looks like:
    (I also gave it a slightly different name, because I bet that you will add all guests are 'new')

    CREATE OR REPLACE PROCEDURE add_customer (
      in_cust_no     IN customer.cust_no%TYPE,
      in_c_name      IN customer.c_name%TYPE,
      in_c_city      IN customer.c_city%TYPE,
      in_c_telno     IN customer.c_telno%TYPE,
      in_c_faxno     IN customer.c_faxno%TYPE,
      in_cust_code   IN customer.cust_code%TYPE,
      in_office_no   IN customer.office_no%TYPE
    ) AS
    BEGIN
      INSERT INTO customer (cust_no,
                            c_name,
                            c_city,
                            c_telno,
                            c_faxno,
                            cust_code,
                            office_no
                           )
      VALUES      (cust_no_seq.NEXTVAL,
                   UPPER (in_c_name),
                   UPPER (in_c_city),
                   in_c_telno,
                   in_c_faxno,
                   UPPER (in_cust_code),
                   in_office_no
                  );
    END add_customer;
    /
    

    Nice, isn't it?

    Then, you create a PACKAGE, say CUST and place your new procedure inside that, instead
    to leave a standalone procedure, which is rarely used.

    Best regards
    Peter

  • SQL stored procedure input and output parameters

    Hello Gang,

    My dead end trying to call a stored procedure in SQL Server 2008 with the LV database tool.

    for purposes of experimentation, I've created a small procedure with an input parameter that returns an integer as return value.  It works describing a query, but all attempts at LV produce an error-2147217900 when executing query VI.  I did find examples of that.

    Sending a bunch of parameters to a stored procedure and checking the value of return seems to be pretty common stuff.

    I'll appreciate any help.

    Thank you

    Roger

    Hi Roger,

    There are a few prerequisites which I will list below. If you have not checked these things, so don't hesitate, as your hiccups can be there.

    Prerequisites:

    1. Ensure that you can read from a table in the database to verify that you can access the database (user permissions) and ensure that your login details are correct. Among other things, make sure that the. DSN switches to the correct database. (See the simple example below, SQL Select.vi)
    2. Make sure that your user (if you use SQL authentication) has permissions to run the STORED procedure by running the procedure in SQL Server Management Studio (you seem to have already done this)

    Example by calling a procedure without parameters (attached as SPROC_No_Parameters.vi):

    Example by calling a procedure with parameters (attached as SPROC_Parameters.vi):

    An article on the execution of stored procedures is here:

    http://digital.NI.com/public.nsf/allkb/07FD130746083E0686257300006326C4

    Don't forget to download the example VI since it includes the cases where you want an output parameter of the procedure rather than a table.

    I tested these against two very simple SPROCs and it worked fine (on SQL Server 2005, but 2008 should be the same).  Stored procedures have been:

    CREATE PROCEDURE [dbo]. [GetContacts]

    AS
    BEGIN
    -SET NOCOUNT ON added to avoid additional results sets from
    -interfering with SELECT statements.
    SET NOCOUNT ON;

    -Controls insert for procedure here
    SELECT * FROM Contacts
    END

    and

    CREATE PROCEDURE [dbo]. [MultiplyAges]
    @param1 INT = 1
    AS
    BEGIN
    -SET NOCOUNT ON added to avoid additional results sets from
    -interfering with SELECT statements.
    SET NOCOUNT ON;

    -Controls insert for procedure here
    SELECT (age * @param1) OF Contacts
    END

    I would like to know if these examples work for you or if you have any other questions.  Don't forget to go through this KB article and articles related to it, they should cover other situations.

    Matt

  • malware has damaged, is there a system to SP3 File Checker

    This would be true practice to add to the difficulty It Center. Most of the people not the SP3 update online and the their CD SP2 System File Checker will not work.

    Specifically, all my USB drives will launch is more like a real storage unit unless I restart the computer in the diagnosis of msconfig startup.  I have various blue screen of death crash, especially when the search indexer is running, or the computer launches a windows update.  There were several problems of malware found by a number of cleaning products, all are now indicating a clean computer, but the damage is done.  SFC SP2 indicate a number of places during the scan, he wants to get a new file from my XP Pro CD, but does not recognize the CD as the current operating system.  I expect that new operating system would have a procedure to check and repair/replace its files.

    Your expectations exceed reality.

    If you reinstall XP and then download and install SP3 and then reinstall all your apps again and then restore your backup of the data, you still won't be able to run sfc/scannow, use your SP2 CD in the future.

    The best option is if you have a genuine XP installation bootable CD with a plu SP is to do a new installation CD that has SP3 'slipstreamed' inside so what comes out the other end is a new installation of XP you create will be integrated into SP3.  You must already have a genuine XP bootable installation CD to do this.

    What you end up with is a XP installation CD with SP3 integrated into it (and you can book your old version).  Which will make happy sfc/scannow, sfc/scannow is not for fixing problems on a system.  sfc/scannow is designed to run only once when you install XP to populate the folder dllcache with a list of 3498 system protected files which are backups in the case where a protected file come missing later on your system.  That's what all this.  It is not to solve problems, unless your problem is that your dllcache folder must be updated, or your problem is you have too much time and need to lose some of them.

    Here's a method that works the first time if you follow the directions:

    http://www.bleepingcomputer.com/tutorials/slipstreaming-Windows-XP-to-create-bootable-CD/

    Here's another:

    http://Lifehacker.com/386526/slipstream-Service-Pack-3-into-your-Windows-XP-installation-CD

    If you do a search on Google for something like:

    Slipstream XP

    you will find other methods.

    If you run sfc/scannow to completion and you have all the pieces in place, it should find nothing to do.   It ' feels 'good when it is running and can't find anything to do well. "

    However, even if you break your system on purpose to remove or damage a file in the dllcache folder and sfc/scannow is a file in the dllcache folder that needs to be replaced and replace it (it IS what it is), you won't know about it since the only thing you will see when the Observer newspaper is that :

    Event type: Information
    Event source: Windows File Protection
    Event category: no
    Event ID: 64016
    Analysis of file File Protection Windows has been started.

    Event type: Information
    Event source: Windows File Protection
    Event category: no
    Event ID: 64017
    Windows File Protection file analysis completed successfully.

    Even if sfc/scannow finds something to do, you will never know about it.  It is not his goal.  Its purpose is to populate the dllcache folder.  In the above example, sfc/scannow replaced the 2 files that I've damaged on purpose for a mission of training and test, but you won't see anything about this in the case where log Viewer.

    When you did, come back with your other questions and we can see i we can solve.

  • How to check if a value exists in a column

    Hello Experts,

    version: 10.1.0.5

    I am a novice in pl/sql programming. I am trying to create a procedure that checks if a value exists in a column and if it is not it inserts. Here's the procedure and errors,

    SQL > CREATE OR REPLACE PACKAGE BODY manr.audit_pkg

    2 PROCEDURE audit_proc (number of p_sessionid, p_username VARCHAR2, date of the p_date) IS

    3 BEGIN

    4 If p_sessionid not in (select manr.audit_history sessionid)

    5. can

    6 INSERT INTO manr.audit_history VALUES (p_sessionid, p_username, p_date);

    7 validation;

    8 end if;

    9 END;

    10 END audit_pkg;

    11.

    WARNING: The body of a Package created with compilation errors.

    SQL > show error

    PACKAGE BODY HÉLÈNE errors. AUDIT_PKG:

    LINE/COL ERROR

    -------- -----------------------------------------------------------------

    4/1 PL/SQL: statement ignored

    4/22 PLS-00405: subquery not allowed in this context

    Could you please tell me where I'm wrong. Thanks for your help.

    Rocky

    Hello

    If p_sessionid not in (select manr.audit_history sessionid)

    Try:

    .....

    Select count (*) in the v_sessionid of manr.audit_history

    where sessionid = p_sessionid;

    If v_sessionid > 0 then

    .....

    on the other

    ....

    end if;

    Ziut

  • From the list of values in the procedure and trying to validate values

    Hello

    I create a procedure that will allow to validate data entered by the user.  Users can add values in a text box on my web page and I need to pass to an oracle procedure and check the table if these values exist.  I need to return a list of values that do not exist.  That's what I have so far

    CREATE OR REPLACE PROCEDURE VALIDATE 
    (
      P_VLIST IN VARCHAR2 ,
      P_RECORDS OUT SYS_REFCURSOR
    )
    AS
      V_SQL VARCHAR2(4000) := '' ;
    BEGIN
    V_SQL :=          'SELECT VAL '||CHR(10) ;
    V_SQL := V_SQL || 'FROM DVALUES '||CHR(10) ;
    V_SQL := V_SQL || 'WHERE VAL NOT IN (' || P_VLIST || ')'||CHR(10) ;
    V_SQL := V_SQL || ' ORDER BY VAL' ||CHR(10) ;
    OPEN P_RECORDS FOR V_SQL;
    END VALIDATE ;
    /
    

    My problem is that it will return all the values of DVALUES.  Can I put my list into a temporary table and do a left join to DVALUES and where the values of the two tables I can create a bool column that has a 1 or 0 indicating whether or not the value is good then select on the table and return the list of bad values?

    Thank you

    SQL > CREATE OR REPLACE
    PROCEDURE (2) P_VALIDATE
    3 P_VLIST IN VARCHAR2,
    4 P_RECORDS OF THE SYS_REFCURSOR
    5                        )
    6 AS
    V_STMT 7 VARCHAR2 (4000);
    BEGIN 8
    9 V_STMT: = ' SELECT ELEMENT FROM (SELECT ";)
    10 V_STMT: = V_STMT | REPLACE (P_VLIST, ',', 'ELEMENT OF DOUBLE UNION ALL SELECT');
    11 V_STMT: = V_STMT | FROM DUAL) WHERE THERE IS NO (SELECT 1 FROM DVALUES WHERE VAL = ELEMENT)';
    12. OPEN P_RECORDS TO V_STMT;
    13 END P_VALIDATE;
    14.

    Created procedure.

    SQL > EXEC P_VALIDATE('10,15,20,25,30,35,40',:V_CUR)

    PL/SQL procedure successfully completed.

    SQL > V_CUR PRINT

    ELEMENT
    ----------
    15
    25
    35

    SQL >

    SY.

  • The exception of procedure management


    Hello guys,.

    I have a code below:

    BEGIN

    -Appeal procedure B;

    END;

    B() PROC

    AS

    USER_DEF EXCEPTION;

    BEGIN

    IF < SOME_CONDITION > THEN

    RAISE USER_DEF;

    END IF;

    END;

    I want to throw an exception of PROCEDURE B and want to handle in the calling PL/SQL block.

    IS THIS POSSIBLE?

    Can anyone guide me on this please?

    Thank you

    Rajendra

    Hello

    given that the exception is defined in B the calling procedure may not see it.

    You can create a package with your exceptions, then B would raise errorpackage.user_def and the calling procedure can check WHEN errorpackage.user_def.

    Concerning

    Marcus

    Edit:

    Example of

    CREATE or REPLACE PACKAGE my_errors

    AS

    e_user_defined EXCEPTION;

    c_user_defined CONSTANT INTEGER: =-20500;

    PRAGMA EXCEPTION_INIT (e_user_defined,-20500);

    ...

    Now, you can

    RAISE my_errors.e_user_defined;

    and search for

    WHEN my_errors.e_user_defined THEN

    And your exception will be associated with SQLCODE-20500

    See also 101 PL/SQL: exception handling

  • Db link verification procedure

    Hello

    I have n databases and database, I need to create the procedure to check the database link is there or not if the database link is not available, create the database link

    I am new to pl/sql somebody can suggest me

    Thank you
    Prakash

    using vdb_name, vserver_name;

    in the insert statement, they are interchangeable. Should be

    ... using vserver_name, vdb_name;
    
  • How to debug the Oracle procedure

    Hi friends,

    I've migrated oracle procedure from Oracle 8.0.4 DB of NT to DB Oracle 9.2.0 on IBM AIX.
    When I test/execute the procedure on the Db 9.2.0, she still runs and did not end.

    How to debug an Oracle procedure to check if it's a loop on the same block foever, what "current" values is owner and what tables he read to, or procedure does never loops as if it is not to satisfy one of the conditions?

    Thank you very much

    Is coding "infinite loop" a bad habit of programming?

    Yes, you can call it such.
    Personally, I prefer to use loops.
    See http://tahiti.oracle.com for the different types of loops that you can use.

    How can I change this infinite loop in a "finite" without changing the logic of the program?

    You can use EXIT WHEN "certain conditions."
    For example, you can add OUTPUT WHEN cursorname % notfound, or some counter to reach a specific value in your loop, to 'force' the loop to stop.
    See the docs or do a search on this forum for more examples.

  • How do to execute the statement commit in a procedure possibly?

    We have a procedure which has DML operations and at the end there is a statement commit.
    I want to execute the command eventually commit.
    As when the procedure is executed directly to execute the command commit, but when this procedure is called by a trigger does not commit.
    As you know validation operation is not allowed in triggers.
    How do I understant the code is triggered by a trigger or another (or another procedure manual exec).
    I'm looking for the word reserved who solve my problem. As the INSERT, delete...

    Serkan
    Thank you.

    Add another 'CALLED_BY' parameter to the procedure and have the procedure call or fill it a trigger.
    If you do not want to change another existing code, by default to NULL then existing procedures do not have to fill only relax, but it can be changed from its own name or just the string "TRIGGER."
    The procedure then checks CALLED_BY.

Maybe you are looking for