How to use where condition in an update statement

Oracle forms 6i
Hai All

I generate table of attendance. My name of the table is daily_attend and fields

name varchar

empcode number

Date of the respondent

Outtime date

number of working_hrs

Date of Attend_date

Attend_status varchar

So here, I calculate the hours of work of an employee by

Update dail_att set wtime = lpad (((outtime-intime) * 24 * 60), 4, 0);

It works great for example for one day

When I want to do on a daily basis, I have to give in the where Clause and how I can give attend_date in where Clause

Thank you in advance

Srikkanth.M

change this to more well-intentioned and reusable procedure... Remove commit inside of the procedure

PROCEDURE W_TIME(p_date date)

IS
BEGIN
update dail_att set wtime= lpad(((outtime-intime)*24*60),4,0)
where trunc(attend_date) = trunc(p_date);

END;

and whenever you want to call it simply call

begin
 ......
 w_time('12-APR-2010');
 commit;
....

Tags: Oracle Development

Similar Questions

  • How can I use multiple row subqueries in update statement

    Hai All

    I'm using the Group feature in my update statement... and I need to update several lines so I need to use several rows

    subquery pls tell me how to use multiple row subqueries in update statement


    For example

    while I use it like this I got an error

    Update dail_att set outtime to (select max (r2.ptime) in the temp_att where empcode = r2.enpno and)

    bar code = r2.cardn and group attend_date = r2.pdate by enpno, update, cardn);


    Pls tell me how to use for example


    Thanks and greetings

    Srikkanth.M

    Hello

    for r2 loop p1

    R2 is a line of the cursor,

    Max (R2. PtIMe)? It is always equal to r2.ptime if the select statement returns rows.

  • How to use the conditional and made mandatory

    Hello

    I need to use the conditional and made mandatory something jspx page. Following line gives an error:

    rendered = "#{Bindings.type.inputValue! = 'abc' & & bindings.proofId.inputValue! ="} ' "

    Error: Name expected instead of &.

    What is the right way?



    Note: I use Jdev 10.1.3

    Boring, but you can use & #38; & #38; (remove the space after the &) for this.

    Timo

    Published by: Timo Hahn on 24.11.2009 08:46

    Published by: Timo Hahn on 24.11.2009 08:48

  • WHERE condition in a sql statement

    Hello people,

    I have a screen with data grid where one of the columns is STATES_CODES and other VOLUMES one. Grid consists of several lines. I need to create a CUSTOM SEARCH field that will be filtering on this database.

    Unfortunately a customer wants to enter a search string with custom functions: '+' (plus) to include in the selection of the result and "-" (less) to exclude from the selection of the results. For example: "+ IT + -100". Based on this string, I need to return only the States HE and and exclude volumes with a value of 100.

    A tip how to build a query where condition, so it will be more effective as possible?

    Simple example:

    test data:

    with t (select 'IT' State, volume 90 of any union double

    Select 'IT' State, 100 volumes of all the double union

    Select 'IT' State, 100 volumes of all the double union

    Select 'OF' State, 90 volume of all the double union

    Select 'OF' State, in 100 volumes of all the double union

    Select 'OF' State, in 100 volumes of all the double union

    Select 'NL' State, 90 volume of all the double union

    Select 'NL' State, 100 volumes of all the double union

    Select 'NL' State, 100 volumes of all the double union

    Select 'FR' State, 90 volume of all the double union

    Select 'FR' State, in 100 volumes of all the double union

    Select 'FR' State, in 100 volumes of all the double union

    Select 'ARE' State, 90 volume of all the double union

    Select 'ARE' State, in 100 volumes of all the double union

    Select 'ARE' State, 100 volumes of double

    )

    Select * from t

    Search string: "+ IT + - 100".

    I thought to somehow using regular expressions REGEXP_LIKE condition, but do not know how to change the entered search string in above format as long as the regular expression.

    And if you want to be specific about the characters representing the State and the numbers represent the amount then you will need to divide them into more...

    SQL > with t (select 'IT' State, 90 volume of all the double union)
    2 Select 'IT' State, 100 volumes of all the double union
    3 select 'IT' State, 100 volumes of all the double union
    4. Select 'FROM' State, 90 volume of all the double union


    5. Select 'FROM' State, in 100 volumes of all the double union
    6. Select 'FROM' State, in 100 volumes of all the double union
    7 select 'NL' State, 90 volume of all the double union
    8 select 'NL' State, 100 volumes of all the double union
    9 select 'NL' State, 100 volumes of all the double union
    10. Select 'FR' State, 90 volume of all the double union
    11. Select 'FR' State, in 100 volumes of all the double union
    12. Select 'FR' State, in 100 volumes of all the double union
    13. Select 'ARE' State, 90 volume of all the double union
    14 select 'ARE' State, in 100 volumes of all the double union
    15 select 'ARE' State, in 100 volumes of double
    16              )
    17, ch. as (select "+ IT + -100"as the double criterion)
    18, split as (select regexp_substr (trim (', ' regexp_replace (criteria,'([+ -]) ', ', \1')), "[^,] +', 1, level") as a criterion of)
    19 c
    20 connect the regexp_substr (trim (', ' regexp_replace (criteria,'([+ -]) ', ', \1')), "[^,] +', 1, level") is not null
    21                 )
    22, inc_state as (select substr(criteria,2) as a criterion
    23 split
    where the 24 regexp_like(criteria,'^\+[A-Z]+')
    25                     )
    26, inc_vol as (select substr(criteria,2) as a criterion
    27 split
    where the 28 regexp_like(criteria,'^\+[0-9]+')
    29                    )
    30, exc_state as (select substr(criteria,2) as a criterion
    31 split
    where the 32 regexp_like(criteria,'^\-[A-Z]+')
    33                     )
    34, exc_vol as (select substr(criteria,2) as a criterion
    35 split
    where the 36 regexp_like(criteria,'^\-[0-9]+')
    37                    )
    38-
    39 select *.
    40 t
    where the 41 (exists (select 1
    inc_state 42
    43 where inc_state.criteria = t.state
    ((44) or (select count (*) in inc_state) = 0)
    45 and (exists (select 1
    46 by inc_vol
    where the 47 inc_vol.criteria = t.volume
    ((48) or (select count (*) in inc_vol) = 0)
    49 and (not exists (select 1
    50 to exc_state
    where the 51 exc_state.criteria = t.state
    ((52) or (select count (*) in exc_state) = 0)
    53 and (not exists (select 1
    exc_vol 54
    where the 55 exc_vol.criteria = t.volume
    ((56) or (select count (*) in exc_vol) = 0)
    57.

    ST VOLUME
    -- ----------
    HE 90
    90

  • How to use the conditions where there are more than two options

    I have a blade that collects information from the user and then makes decisions based on the values entered. On a slide I use the widget drop-down list and list of"basic", "Intermediate" and "Advanced". I hoped to do is use the Coditional Structure as follows:

    1. If the Basic was selected slide goto BasicQuickQuiz
    2. If the intermediary has been selected goto slide IntermediateQuickQuiz
    3. If Advanced was selected slide goto AdvancedQuick Quiz

    I can make this work for Basic or intermediate, but I don't see how (or even if) I have a multi level if statement.
    My work is about:
    1. a button added logic:
    So basic, then got otherwise BasicQuickQuiz goto IntermediateQuickQuiz

    2. on the Enter slide on IntermediateQuickQuiz event:
    If the intermediary, then keep, otherwise goto slide AdvancedQuick Quiz

    It works, but it seems awkward - y at - it another way that this goal could be achieved?

    Tim

    What I was hoping to see was the ability to create several Else If statements within the only condition. I've changed it now to add two conditional statements, one after the other, but still find this unscrupulous feature.
    I will record a feature request to add a Select Case block / Switch style fuction to this group.
    However, since it is new I can live with the workflow (for this version of Cp anyway!)

    Tim

  • How to use if condition to determine the passage of sequence not

    I have a sequence where I need determine his pass fail condition by comparing the two values. The values are returned by different screws LabVIEW, say. Locals.ValueReturnedByVI_1 and a value other than Locals.ValueReturnedByVI_2. Now, I intend to compare these values using an If-Else Condition and determine if this sequence has passed or failed.

    If (Locals.ValueReturnedByVI_1 is Locals.ValueReturnedByVI_2)

    / * This sequence has failed * /.

    on the other

    / * This sequence passed * /.

    End

    I don't know what needs to be done inside the blocks conditon said English of the sequence.

    Or is there a better way to do it?

    Another option would be to use a Test pass/fail without adapter step. The value of the Expression of Locals.ValueReturnedByVI_1 Data Source is Locals.ValueReturnedByVI_2.

    The biggest difference I see, this is how the result will appear in a report. I'll keep that in mind as you choose how the issue.

  • How to use the web service to update the data?

    Hi team,

    Need help in establishing a procedure for updating data using the web service, in the first instance, I think that it's the same reading webservice but I will produce an error:

    29273 00000 - "the HTTP request failed.

    * Cause: The UTL_HTTP package cannot run the HTTP request.

    * Action: Use get_detailed_sqlerrm to check the detailed error message.

    Correct the error and restart the HTTP request.

    using this tag soap_request.

    < ns1:Request >

    < ns1:header >

    < ns1:InterfaceName > OSMMVNECreateOrder < / ns1:InterfaceName >

    < ns1:InterfaceId > OSM - XXX < / ns1:InterfaceId >

    < ns1:CorrelationId > TEST-06262015 < / ns1:CorrelationId >

    < / ns1:header >

    < ns1:Mvno > MTI < / ns1:Mvno >

    < ns1:orderId > < / ns1:orderId >

    < ns1:orderType > CHANGE_STATUS < / ns1:orderType >

    < ns1:orderDetails >

    < ns1:subscriberId > 9469273 < / ns1:subscriberId >

    < ns1:newStatusId > 2 < / ns1:newStatusId >

    < / ns1:orderDetails >

    < / ns1:Request >

    the < ns1:subscriberId > 9469273 < / ns1:subscriberId > the Subscriber must search and

    < ns1:newStatusId > 2 < / ns1:newStatusId > will replace the current state.



    any suggestion on how to do it?



    Best regards

    Nelz Ki

    There is no difference between calling a web service to write data, against the appellant for reading data. SOAP is SOAP. He cares not.

    Example to interact with a web service is in Re: PLSQL webservice call

    Regarding your error - stack display Tower full of error to see what said the trace of the error. The data you've posted unfortunately no sense to isolate the error.

  • How to use if condition inside a statement case?

    Hi all

    It's my code and the error. Please help me.

    SQL > select case when value (1000) then null
    2 when the user in ('ABC'), then the user
    3 when area ("Denver") then
    4. If value = 2000 then 'Service1 '.
    5 other value = 3000 and then "Service2.
    6 end if
    7 another null
    8 end as service_usoc_ref num_code;
    If main = 2000 then "Omaha".
    *
    ERROR on line 4:
    ORA-00905: lack of keyword

    Thank you...

    Try this...

    select
         case
              when value in (1000) then null
               when user in ('ABC') then user
               when area in ('DENVER') then
                      decode(value, 2000 , 'Service1', 3000 ,'Service2')
               else null
          end as num_code
    from service_usoc_ref;
     
    

    Here is the reference for more information on Decode for your use:
    http://www.techonthenet.com/Oracle/functions/decode.php

    Kind regards
    Lifexisxnotxsoxbeautiful

  • WHERE conditional clause with CASE statement

    Hi experts,

    I have a table:

    CREATE THE TABLE HR. TABLE_Y

    (

    NUMBER (2),

    ID NUMBER (2),

    NUMBER (5) CALC

    )

    Insert into human resources. TABLE_Y

    (TYPE, ID, CALC)

    Values

    (1, 1, 10);

    Insert into human resources. TABLE_Y

    (TYPE, ID, CALC)

    Values

    (1, 2, 15);

    Insert into human resources. TABLE_Y

    (TYPE, ID, CALC)

    Values

    (1, 3, 17);

    Insert into human resources. TABLE_Y

    (TYPE, ID, CALC)

    Values

    (1, 4, 20);

    Insert into human resources. TABLE_Y

    (TYPE, ID, CALC)

    Values

    (2, 2, 11);

    Insert into human resources. TABLE_Y

    (TYPE, ID, CALC)

    Values

    (1, 2, 14);

    Insert into human resources. TABLE_Y

    (TYPE, ID, CALC)

    Values

    (2, 3, 18);

    Insert into human resources. TABLE_Y

    (TYPE, ID, CALC)

    Values

    (3, 1, 30);

    COMMIT;

    SQL > SELECT * FROM TABLE_Y ORDER BY 1.2;

    TYPE ID CALC

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

    1          1         10

    1          2         15

    1          3         17

    1          4         20

    2          1         14

    2          2         11

    2          3         18

    3          1         30

    I have the query as below,

    I pass a TYPE and an IDENTITY value as a condition for a query.

    SELECT THE TYPE, ID, CALC

    OF TABLE_Y

    WHERE TYPE =: TYPE

    AND IN THE CASE OF IDENTITY

    WHEN: TYPE = 1

    THEN 2

    WHEN: TYPE = 2

    THEN 1

    End

    ;

    When passing a TYPE = 1

    Output

    ID of TYPE CALC

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

    1                2           15

    When passing a TYPE = 2

    Output

    ID of TYPE CALC

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

    2               1               14

    I want to move a TYPE and ID more values as a condition for a query.

    I'm trying

    SELECT THE VALUE TYPE, ID,

    OF TABLE_Y

    WHERE TYPE =: TYPE

    AND IN THE CASE OF IDENTITY

    WHEN: TYPE = 1

    THEN (1,3)

    WHEN: TYPE = 2

    THEN (1,2)

    End

    ;

    But gives me error:

    ORA-00907: lack of right parenthesis

    During the passage of a desired output TYPE, = 1

    TYPE ID CALC

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

    1            1            10

    1            3            17

    During the passage of a desired output TYPE, = 2

    TYPE ID CALC

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

    2           1              14

    2           2              11

    Thanks in advance

    BANNER

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

    Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - production

    PL/SQL Release 10.2.0.4.0 - Production

    CORE 10.2.0.4.0;     Production

    AMT for Solaris: release 10.2.0.4.0 - Production

    NLSRTL Version 10.2.0.4.0 - Production

    Hello

    Here's one way:

    SELECT the type, id, value

    OF table_Y

    WHERE type =: type

    AND ((: type = 1))

    AND id IN (1, 3)

    )

    OR (: type = 2)

    AND id IN (1, 2)

    )

    )

    ;

  • How to use the Substring function with Case statement.

    Hi all

    I have a requirement where I have to use the substring function on the ground for the report criteria.
    FOR EXAMPLE
    I branch domain name where I have all the information of the branch names, now some of the branch names are too large with an extension after the name.
    now I want substing it, but the length of characters varies for each branch.
    so is it possible where we use a box where we can define if the character of name plug exceed a value then he substing with this length.

    Try something like this:

    LENGTH WHEN CARTER (tablename. Branch_Name) > n THEN SUBSTRING (...) Of ANOTHER tablename. Branch_Name END

    where n is the number of characters that you want to start the break.

  • WHERE condition has decoded the statement

    Hi all

    I have a requirement to have two or three conditions based on a condition in the WHERE clause. Please do the needful. Thank you.

    If the context value is PROJECTS BILLS, then must have conditons

    (due_date-nvl(rt.printing_lead_days,31)) < sysdate
    and aps.customer_trx_id = rct.customer_trx_id
    and rt.term_id (+) = rct.term_id
    and aps.customer_trx_id = (select customer_trx_id
    of ra_customer_trx_all
    where trx_number =
    (: $FLEX$ .AR_RAXINV_TRX_NUMBER)

    If the context value is other than the PROJECT INVOICES, the

    (aps.customer_trx_id = rct.customer_trx_id
    and rt.term_id (+) = rct.term_id
    and aps.customer_trx_id = (select customer_trx_id
    of ra_customer_trx_all
    where trx_number =
    (: $FLEX$ .AR_RAXINV_TRX_NUMBER)


    Ex:

    I tried, but received the error.

    Select terms_sequence_number
    ar_payment_schedules_all aps, RA_CUSTOMER_TRX_ALL CTN, ra_terms rt
    where
    DECODE (rct.interface_header_context,'PROJECTS BILLS, (aps.customer_trx_id = rct.customer_trx_id)
    and rt.term_id (+) = rct.term_id
    and aps.customer_trx_id = (select customer_trx_id
    of ra_customer_trx_all
    where trx_number = '80000062')),
    ((due_date-nvl(rt.printing_lead_days,31)) < sysdate and)
    APS.customer_trx_id = rct.customer_trx_id
    and rt.term_id (+) = rct.term_id
    and aps.customer_trx_id = (select customer_trx_id
    of ra_customer_trx_all
    where trx_number = '80000062')))

    Thank you
    Abdul

    Select...
    Of...
    where (rct.interface_header_context = 'INVOICES of PROJECTS'
    OR (rct.interface_header_context! = "PROJECTS BILLS" and (due_date-nvl(rt.printing_lead_days,31))
    )< sysdate="">
    and aps.customer_trx_id = rct.customer_trx_id
    and rt.term_id = rct.term_id
    and aps.customer_trx_id = (select customer_trx_id from the ra_customer_trx_all where trx_number = '80000062')

  • Merger of statement: with several Update statement.

    Hello

    I'm trying under the merge statement. However to get the error "not correctly completed 0ra-00933 sql command.

    In fact, my join conditions are the same, but I wanted to update the different columns based on the different places where clause in the update statement.

    for example.

    FUSION
    IN abc3 tgt
    With the HELP of abc CBC
    WE (src.cust = tgt.cust)
    WHEN MATCHED
    THEN
    UPDATE
    SET tgt.sales = src.sales
    where tgt.cust = 'Cust3'
    UPDATE
    SET tgt.sales1 = src.sales
    where tgt.cust = 'Cust2';

    Please let me know if there is no work around for this.

    Hi, pm

    You can try this please.

    MERGE
     INTO ABC3 TGT
     USING ABC SRC
      ON (src.cust = tgt.cust)
    WHEN MATCHED THEN
    UPDATE SET TGT.SALES = DECODE(TGT.CUST,'Cust3',SRC.SALES,TGT.SALES),
               TGT.SALES1 = DECODE(TGT.CUST,'Cust2',SRC.SALES,TGT.SALES1)
    WHERE TGT.CUST='Cust3' OR tgt.cust='Cust2';
    
  • I get request to update my Flash Player from Adobe. What is c? Where to find info on how to use it?

    I don't really know how to use this thing, I'm seriously "physically challenged and a slow-learner." and my computer repair man keeps changing computers about me.  (In this I am not sure that it helps me.  Once I have to get used to some programs, there are 'new '.   His "real confusion.  For example, I got a real easy to use-address book that had all my personal and business addresses and telephone #s in there.  The computer got a 'blue screen' several times, so he came and changed my "Dell XPS" computer professional with a 'new' (a ' Dell 7 Ultimate' it was 'better'.    If I could afford it, I buy a new one and start over) so I rarely know 'where' I am, or what to do when I'm 'where I am.  With a full-time job and a serious hobby of computer repair, it doesn't have the time to help me with "operational" issues This put an unfair burden on anyone trying to help me, but I HAD TO GET HELP - SOMEWHERE, so if I'm not a gene with what will be long-term issues (because I don't know much about the computer operations), can I impose to ask what might be the basic questions?  Of course, they cannot be "basic", but what I know.     I read "... for Dummies" books, but they did not answer my questions.  I'll try to be brief, but it's not my nature.          So, let's go...

    Sometimes I get request to "update my Adobe Flash Player."  I have looked under Start programs and everything I find is "Adobe Flash Player";  I do not use reader because I do not know how, or its purpose.  But I feel like I'm missing out on thing, why would he says in the 1st place?  (I don't want to watch videos, and somewhere, I think I remember it may have something to do with it.  If so, I peut have a NEED for him.  And if so, where can I find information on how to use it.  Once again, if so, I also NEED the Flash Player?

    Original title: * e-mail address is removed from the privacy *.

    Flash Player is used by some web sites to improve how their web page or pages are displayed. If you go on a site that uses Adobe Flash and Flash Player is not installed on your computer, you will see a request to install Flash Player. When Flash Player is installed, then you can never know its duration as its transparent you when loading a web page.

    In your case and on my computer I installed Flash Player, and for this purpose, I see the same update request that you see. It is best to install the update to the latest version of bugs or security risks that may currently exist in the old version install on your PC.

    J W Stuart: http://www.pagestart.com

  • Automatic updates is stuck, includes most of it resources, is not download the updates (windows xp) & how to use FixIt

    Automatic updates is stuck and includes most of the computing resources, does not download updates (windows xp).

    After restarting a couple of times and the computer almost melt it finally resolved itself but would like to know how to solve/speed "constipation" where it would happen again.

    Have automatic updates set in place to be notified, but not to download or install before you have manually committed.  Launched the download but then icon taskbar disappeared and cannot cancel downloads when the computer started to overheat.  Restarted.

    East went to the Microsoft Update Web site, but got stock without ever generating the list of updates.  Restarted.

    Went to link to FixIt for this type of problem and it just downloaded WindowsUpdateDiagnostic.diagcab and indicated that nothing was available to open this type of file.  Should a FixIt application be installed first?  He is yet to provide suggestions on how to proceed.

    Aversion to disable the automatic updates if would like more information on how to have a greater mastery of the process that it hogs computer and interfere with the realization of planned work.

    Kind regards.

    Thanks for the reply.

    I agree that it is not dust on the fan - read my response above.

    As I said above, I have concluded that the solution to the problem of automatic updates are unruly must all just use to be notified when updates are available, but then go on the site of Microsoft Updates and make the download / installation of the updates from there.  Doing it this way is much less likely to cause problems and offer better control of the user.  Once Microsoft Updates ends the taskbar icon disappears until the next time updates are available.

  • explain query plan uses no unique index with where condition

    Hi all

    I use in the 10.2.0.5 oracle database Enterprise edition 64-bit on 64-bit windows server 2008.

    I'm following this tutorial on my own table

    Guide to understanding Oracle QUERY PLAN - 10 minutes

    my questions are below

    Analyze table LIB_CLASSIFICATIONS compute statistics;
    explain plan for  SELECT class_id  FROM lib_classifications WHERE class_no = '538' ;
    select * from table(dbms_xplan.display);
    

    the result is less than

    Hash value of plan: 3022072076

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

    | ID | Operation | Name                | Lines | Bytes | Cost (% CPU). Time |

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

    |   0 | SELECT STATEMENT |                     |     1.    10.     5 (0) | 00:00:01 |

    |*  1 |  TABLE ACCESS FULL | LIB_CLASSIFICATIONS |     1.    10.     5 (0) | 00:00:01 |

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

    Information of predicates (identified by the operation identity card):

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

    1 - filter ("CLASS_NO" = '538')

    DESC LIB_CLASSIFICATIONS

    Name of Type Null

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

    CLASS_ID NOT NULL NUMBER (10)

    CLASS_DESC VARCHAR2 (50)

    REMARKS VARCHAR2 (250)

    CLASS_NO VARCHAR2 (20)

    CLASS_TYPE VARCHAR2 (10)

    CREATE_USER VARCHAR2 (10)

    MODIFY_USER VARCHAR2 (10)

    CREATE_DATE DATE

    MODIFY_DATE DATE

    CLASS_CATEGORY_ID VARCHAR2 (10)

    class_id has a primary key.

    now when I remove the condition where the query, the result is lower;

    Analyze table LIB_CLASSIFICATIONS compute statistics;
    explain plan for  SELECT class_id  FROM lib_classifications ;
    select * from table(dbms_xplan.display);
    

    the result is less than

    Hash value of plan: 262704430

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

    | ID | Operation | Name | Lines | Bytes | Cost (% CPU). Time |

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

    |   0 | SELECT STATEMENT |             |  1558.  6232.     2 (0) | 00:00:01 |

    |   1.  FULL RESTRICTED INDEX SCAN FAST | SYS_C005653 |  1558.  6232.     2 (0) | 00:00:01 |

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

    now it's using indexes with INDEX FAST FULL SCAN.

    I need the index using the WHERE condition as well.

    How to do this?

    Thank you.

    you have indexes on the column class_id not on class_no column how u would expect index to use when there is no index on the column class_no

Maybe you are looking for