Help with a update,select statement

Hi all please can you help me with a update statement i am struggling with.
I have 2 tables
Holiday and data
In the Holiday table i have columns for
Machine_ID NUMBER,
date_from DATE,
date_to DATE,
ID NUMBER
Machine column represents a type of machine, the two dates represent the start and end date of a holiday and ID represents the ID of the machines that the holiday effects (as you can have many machines that are the same, so the ID unique field to seperate them.
i.e.
996     25-DEC-08 00:00:00     27-DEC-08 00:00:00     91     
996     25-DEC-08 00:00:00     27-DEC-08 00:00:00     92     
100     28-DEC-08 00:00:00     29-DEC-08 00:00:00     1
100     28-DEC-08 00:00:00     29-DEC-08 00:00:00     2
In the data table i have the following columns:
DATE DATE
Machine NUMBER
SHIFT1S DATE
SHIFT1F DATE
SHIFT2S DATE
SHIFT2F DATE
CALS DATE
CALF DATE
CAP NUMBER
CALCAP NUMBER
total_hrs_up NUMBER
In here i have data for every date in the calendar. The machines are cross references with the machine in holidays table.
I run two shifts so have shift 1 start, finish. shift 2 start, finish. These are dates with times, so shift1s could be 01-01-08 09:00:00 shift1f could be 01-01-08 17:00:00.
shift2S could be 01-01-08 21:00:00 shift2f could be 01-01-08 23:59:00.
so that machine would be up between them hours of the day.
Other columns include
CALS, ,CALF = calendar start, finish, - This needs to be populated from the holiday table. currently null. So if the date is the 26 DEC and the machine is the same as what is in the holiday table then these two columns should be populated with them data
CAP is the total number of these machines i have available.
CALCAP is the no of machines the holiday affects -currently null
total_hrs_up is the number of hours this machine is up and running -currently null.
So what i need to do is populate the cals, calf calcap, total_hrs_up columns.
total_hrs_up is the important one, this needs to work out based on the two shift patterns the number of hours that the machine is available and then take off the holiday hours to give a final value.
so current data example in data is
date machine shifts shiftf shift2s shift2f cals, calf, cap, calcap, total_hrs
16-JUL-08     100 09:00:00     17:00:00     12:00:00     00:00:00               '','','',1     ,''     
16-JUL-08     105 09:00:00     17:00:00     12:00:00     00:00:00               '','','',1     ,''
16-JUL-08     107 09:00:00     17:00:00     12:00:00     00:00:00               '','','',1     ,''
id like to see based on the holiday table if there is a holiday then this data is updated as such and a total_hrs machine is available populated on that date.
Any help is very much appreciated!
Thanks

Hi,
The following query does what you requested.
It makes the following assumptions:
(a) in data, shift1start <= shift1finish
(b) in holiday, hol_start <= hol_finish
(b) in data, the combination (machine, shift1start) is unique
(c) in holiday, hol_start <= hol_finish
(d) in holiday, rows for the same machine and id never have overlapping dates (including times). For example:
INSERT INTO holiday (machine, id, date_from, date_to)
VALUES (200, 1, '26-DEC-08 07:00:00', '26-DEC-08 09:59:59');
INSERT INTO holiday (machine, id, date_from, date_to)
VALUES (200, 1, '26-DEC-08 09:00:00', '26-DEC-08 09:59:59');will cause a probem. Multiple rows for the same machine and day are okay, however, if the times do not overlap, like the following:
INSERT INTO holiday (machine, id, date_from, date_to)
VALUES (200, 1, '26-DEC-08 07:00:00', '26-DEC-08 08:59:59');
INSERT INTO holiday (machine, id, date_from, date_to)
VALUES (200, 1, '26-DEC-08 09:00:00', '26-DEC-08 09:59:59');Here's the UPDATE statement:
UPDATE     data     m
SET     (     hol_start
     ,     hol_finish
     ,     no_of_available_minutes
     ) =
(     SELECT     MIN (date_from)
     ,     MAX (date_to)
     ,     (     MAX (shift1finish - shift1start)     -- Total from data
          -     ( NVL     ( SUM     ( LEAST (date_to, shift1finish)
                         - GREATEST (date_from, shift1start)
                    , 0
                    )                    -- Total from holiday
               / MAX (total_no_of_machines)          -- Average
          ) * 24 * 60                         -- Convert days to minutes
     FROM          data     d
     LEFT OUTER JOIN     holiday     h     ON     h.machine     = d.machine
                         AND NOT     (     date_from     > shift1finish
                              OR      date_to          < shift1start
     WHERE          d.machine     = m.machine
     AND          d.shift1start     = m.shift1start
);The subquery has to use its own copy of data (that is, in needs d, not m), since the subquery has to return a non-NULL number of minutes when no rows in h match m.

Similar Messages

  • Help with a simple select statement

    $x = oci_parse($c, "select quantity from balance where item_num=101");
    oci_execute($x);
    echo "the quant is: ".$x;
    I try to run this select statement without success
    then I tried...
    $x = oci_parse($c, "select quantity from balance where item_num=101");
    $y= oci_execute($x);
    echo "the quant is: ".$y;
    and it didn't work either...
    What should I change?
    thanks!

    The Oracle library operates a bit differently from some other PHP libraries, notably MySQL/MySQLi. With Oracle (OCI8), you have to execute the statement, and then afterward use an oci_fetch...() function to pull things from your $statement variable. Here's a small example that hopefully will illustrate the basic usage:
    <?php
         $conn = oci_connect('hr','hr','xe');
         if(!$conn) {
              echo 'Could not connect!';
              exit;
         $sql = 'select * from jobs';
         $stmt = oci_parse($conn, $sql);
         if(!$stmt) {
              echo 'Could not parse query.';
              exit;
         $result = oci_execute($stmt, OCI_DEFAULT);
         if(!$result) {
              echo 'Could not execute query.';
              exit;
         echo "Query ran successfully.\n";
         // Fetch rows as associative arrays, so
         // we can ask for values by column name.
         // Other options include oci_fetch_row(),
         // oci_fetch_array(), and oci_fetch_object().
         // Note that oci_fetch_assoc() will create
         // an associative array using upper-case
         // column names for the keys.
         while(($row = oci_fetch_assoc($stmt)) != null)
              echo $row['JOB_ID'] . ': ' . $row['JOB_TITLE'] . "\n";
         echo "All data returned.\n";
         oci_close($conn);
    ?>When I run this, I get the following:
    C:\workspace\php>php select.php
    Query ran successfully.
    AD_PRES: President
    AD_VP: Administration Vice President
    AD_ASST: Administration Assistant
    FI_MGR: Finance Manager
    FI_ACCOUNT: Accountant
    AC_MGR: Accounting Manager
    AC_ACCOUNT: Public Accountant
    SA_MAN: Sales Manager
    SA_REP: Sales Representative
    PU_MAN: Purchasing Manager
    PU_CLERK: Purchasing Clerk
    ST_MAN: Stock Manager
    ST_CLERK: Stock Clerk
    SH_CLERK: Shipping Clerk
    IT_PROG: Programmer
    MK_MAN: Marketing Manager
    MK_REP: Marketing Representative
    HR_REP: Human Resources Representative
    PR_REP: Public Relations Representative
    All data returned.
    C:\workspace\php>For more information, take a look at the OCI8 library documentation in the PHP manual online:
    OCI8
    http://us.php.net/manual/en/book.oci8.php
    Some other examples
    http://us.php.net/manual/en/oci8.examples.php
    Kind regards,
    Christopher L. Simons

  • Need help with correcting the select statement

    I have two tables mkt & error.
    The fields of mkt are
    app_id (xxx)
    c_mkt_id
    app_mkt_id
    The fields of error table are
    mkt_id
    intr_id (its in format xxx.yyy or xxx)
    xyz
    abc
    pqr
    I have to select * fields from error table such that
    ->mkt.app_id = error.intr_id (here i am using combination of sbstr & instr to get the part before "." if present)
    ->mkt.c_mkt_id=error.mkt_id
    Where ever the above two conditions match i have to replace the mkt_id field in my select * from error table query with the
    app_mkt_id field from mkt table. If the above two condtions dont match my select * from error table should return the original mkt_id present in the error table.
    I have presently developed a query(*) which selects the app_mkt_id from mkt table where ever the two conditions match.
    How should i go about using this to get my actual requirement.
    (*)=select app_mkt_id from mkt where app_id in (select case when case_when=1 then substr(intr_id, 1, instr(intr_id,'.')-1) else substr(intr_id, 1) end from (select intr_id, case when instr(intr_id,'.',1)=0 then 0 else 1 end case_when from error)) and
    c_mkt_id in (select mkt_id from error)

    you wrote:
    (*)=select app_mkt_id from mkt where ....What is this?
    If you are writing PL/SQL the syntax is:
    SELECT ....
    INTO ....
    FROM ....
    WHERE ....This seems to be school work and thus you really need to puzzle this out for yourself.

  • Help with this update statement..

    Hi everyone,
    I am trying to update a column in a table .I need to update that column
    with a function that takes patient_nbr and type_x column values as a parameter.
    That table has almost "300,000" records. It is taking long time to complete
    almost 60 min to 90 min.
    Is it usual to take that much time to update that many records?
    I dont know why it is taking this much time.Please help with this update statement.
    select get_partner_id(SUBSTR(patient_nbr,1,9),type_x) partner_id from test_load;
    (it is just taking 20 - 30 sec)
    I am sure that it is not the problem with my function.
    I tried the following update and merge statements .Please correct me if i am wrong
    in the syntax and give me some suggestions how can i make the update statement fast.
    update test_load set partner_id = get_partner_id(SUBSTR(patient_nbr,1,9),type_x);
    merge into test_load a
    using (select patient_nbr,type_x from test_load) b
    on (a.patient_nbr = b.patient_nbr)
    when matched
    then
    update
    set a.partner_id = get_partner_id(SUBSTR(b.patient_nbr,1,9),b.type_x);
    there is a index on patient_nbr column
    and the statistics are gathered on this table.

    Hi Justin,
    As requested here are the explain plans for my update statements.Please correct if i am doing anything wrong.
    update test_load set partner_id = get_partner_id(SUBSTR(patient_nbr,1,9),type_x);
    "PLAN_TABLE_OUTPUT"
    "Plan hash value: 3793814442"
    "| Id  | Operation          | Name             | Rows  | Bytes | Cost (%CPU)| Time     |"
    "|   0 | UPDATE STATEMENT   |                  |   274K|  4552K|  1488   (1)| 00:00:18 |"
    "|   1 |  UPDATE            |        TEST_LOAD |       |       |            |          |"
    "|   2 |   TABLE ACCESS FULL|        TEST_LOAD |   274K|  4552K|  1488   (1)| 00:00:18 |"
    merge into test_load a
    using (select patient_nbr,type_x from test_load) b
    on (a.patient_nbr = b.patient_nbr)
    when matched
    then
    update
    set a.partner_id = get_partner_id(SUBSTR(b.patient_nbr,1,9),b.type_x);
    "PLAN_TABLE_OUTPUT"
    "Plan hash value: 1188928691"
    "| Id  | Operation            | Name             | Rows  | Bytes |TempSpc| Cost (%CPU)| Time     |"
    "|   0 | MERGE STATEMENT      |                  |   274K|  3213K|       |  6660   (1)| 00:01:20 |"
    "|   1 |  MERGE               |        TEST_LOAD |       |       |       |            |          |"
    "|   2 |   VIEW               |                  |       |       |       |            |          |"
    "|*  3 |    HASH JOIN         |                  |   274K|    43M|  7232K|  6660   (1)| 00:01:20 |"
    "|   4 |     TABLE ACCESS FULL|        TEST_LOAD |   274K|  4017K|       |  1482   (1)| 00:00:18 |"
    "|   5 |     TABLE ACCESS FULL|        TEST_LOAD |   274K|    40M|       |  1496   (2)| 00:00:18 |"
    "Predicate Information (identified by operation id):"
    "   3 - access("A"."patient_nbr"="patient_nbr")"Please give some suggestions..
    what's the best approach for doing the updates for huge tables?
    Thanks

  • TDE Issue with UPDATE/SELECT statement

    We just implemented TDE on a table and now our import script is getting errors. The import script has not changed and has been running fine for over a year. The script failed right after applying TDE on the table.
    Oracle 10g Release 2 on Solaris.
    Here are the encrypted colums:
    COLUMN_NAME ENCRYPTION_ALG SALT
    PERSON_ID AES 192 bits key NO
    PERSON_KEY AES 192 bits key NO
    USERNAME AES 192 bits key NO
    FIRST_NAME AES 192 bits key NO
    MIDDLE_NAME AES 192 bits key NO
    LAST_NAME AES 192 bits key NO
    NICKNAME AES 192 bits key NO
    EMAIL_ADDRESS AES 192 bits key NO
    AKO_EMAIL AES 192 bits key NO
    CREATION_DATE AES 192 bits key NO
    Here is the UPDATE/SELECT statement that is failing:
    UPDATE cslmo_framework.users a
           SET ( person_id
               , username
               , first_name
               , middle_name
               , last_name
               , suffix
               , user_status_seq
             = (
                 SELECT person_id
                      , username
                      , first_name
                      , middle_name
                      , last_name
                      , suffix
                      , user_status_seq
                   FROM cslmo.vw_import_employee i
                  WHERE i.person_key = a.person_key
         WHERE EXISTS
                   SELECT 1
                     FROM cslmo.vw_import_employee i
                    WHERE i.person_key = a.person_key
                      AND (    NVL(a.person_id,0)        <> NVL(i.person_id,0)
                            OR NVL(a.username,' ')       <> NVL(i.username,' ')
                            OR NVL(a.first_name,' ')     <> NVL(i.first_name,' ')
                            OR NVL(a.middle_name,' ')    <> NVL(i.middle_name,' ')
                            OR NVL(a.last_name,' ')      <> NVL(i.last_name,' ')
                            OR NVL(a.suffix,' ')         <> NVL(i.suffix,' ')
                            OR NVL(a.user_status_seq,99) <> NVL(i.user_status_seq,99)
    cslmo@awpswebj-dev> exec cslmo.pkg_acpers_import.p_users
    Error importing USERS table.START p_users UPDATE
    Error Message: ORA-01483: invalid length for DATE or NUMBER bind variableI rewrote the procedure using BULK COLLECT and a FORALL statement and that seems to work fine. Here is the new code:
    declare
       bulk_errors EXCEPTION ;
       PRAGMA EXCEPTION_INIT(bulk_errors,-24381) ;
       l_idx      NUMBER ;
       l_err_msg  VARCHAR2(2000) ;
       l_err_code NUMBER ;
       l_update   NUMBER := 0 ;
       l_count    NUMBER := 0 ;
       TYPE person_key_tt
           IS
               TABLE OF cslmo_framework.users.person_key%TYPE
                    INDEX BY BINARY_INTEGER ;
       arr_person_key   person_key_tt ;
       TYPE person_id_tt
           IS
              TABLE OF cslmo_framework.users.person_id%TYPE
                    INDEX BY BINARY_INTEGER ;
       arr_person_id   person_id_tt ;
       TYPE username_tt
          IS
              TABLE OF cslmo_framework.users.username%TYPE
                   INDEX BY BINARY_INTEGER ;
       arr_username   username_tt ;
       TYPE first_name_tt
          IS
             TABLE OF cslmo_framework.users.first_name%TYPE
                  INDEX BY BINARY_INTEGER ;
       arr_first_name   first_name_tt ;
       TYPE middle_name_tt
         IS
             TABLE OF cslmo_framework.users.middle_name%TYPE
                 INDEX BY BINARY_INTEGER ;
       arr_middle_name   middle_name_tt ;
       TYPE last_name_tt
             IS
                TABLE OF cslmo_framework.users.last_name%TYPE
                     INDEX BY BINARY_INTEGER ;
       arr_last_name   last_name_tt ;
       TYPE suffix_tt
             IS
                TABLE OF cslmo_framework.users.suffix%TYPE
                     INDEX BY BINARY_INTEGER ;
       arr_suffix   suffix_tt ;
       TYPE user_status_seq_tt
             IS
                TABLE OF cslmo_framework.users.user_status_seq%TYPE
                     INDEX BY BINARY_INTEGER ;
       arr_user_status_seq   user_status_seq_tt ;
       CURSOR users_upd IS
          SELECT  i.person_key
                 ,i.person_id
                 ,i.username
                 ,i.first_name
                 ,i.middle_name
                 ,i.last_name
                 ,i.suffix
                 ,i.user_status_seq
          FROM   cslmo.vw_import_employee i ,
                 cslmo_framework.users    u
          WHERE  i.person_key = u.person_key ;
    begin
       OPEN users_upd ;
       LOOP
            FETCH   users_upd
             BULK
          COLLECT
             INTO    arr_person_key
                   , arr_person_id
                   , arr_username
                   , arr_first_name
                   , arr_middle_name
                   , arr_last_name
                   , arr_suffix
                   , arr_user_status_seq
            LIMIT         100 ;
            FORALL idx IN 1 ..  arr_person_key.COUNT
                SAVE EXCEPTIONS
                UPDATE cslmo_framework.users u
                  SET
                       person_id                =   arr_person_id(idx)
                     , username                 =   arr_username(idx)
                     , first_name               =   arr_first_name(idx)
                     , middle_name              =   arr_middle_name(idx)
                     , last_name                =   arr_last_name(idx)
                     , suffix                   =   arr_suffix(idx)
                     , user_status_seq          =   arr_user_status_seq(idx)
                 WHERE u.person_key = arr_person_key(idx)
                 AND
                       ( NVL(u.person_id,0) != NVL(arr_person_id(idx),0)
                 OR
                         NVL(u.username,' ') != NVL(arr_username(idx),' ')
                 OR
                         NVL(u.first_name,' ') != NVL(arr_first_name(idx),' ')
                 OR
                         NVL(u.middle_name, ' ') != NVL(arr_middle_name(idx), ' ')
                 OR
                         NVL(u.last_name,' ') != NVL(arr_last_name(idx),' ')
                 OR
                         NVL(u.suffix,' ') != NVL(arr_suffix(idx),' ')
                 OR
                         NVL(u.user_status_seq,99) != NVL(arr_user_status_seq(idx),99)
          l_count := arr_person_key.COUNT ;
          l_update := l_update + l_count ;
          EXIT WHEN users_upd%NOTFOUND ;
       END LOOP ;
       CLOSE users_upd ;
       COMMIT ;
       dbms_output.put_line('updated records: ' || l_update);
       EXCEPTION
          WHEN bulk_errors THEN
               FOR i IN 1 .. sql%BULK_EXCEPTIONS.COUNT
               LOOP
                  l_err_code   :=   sql%BULK_EXCEPTIONS(i).error_code ;
                  l_err_msg    :=   sqlerrm(-l_err_code) ;
                  l_idx        :=   sql%BULK_EXCEPTIONS(i).error_index;
                  dbms_output.put_line('error code: ' || l_err_code);
                  dbms_output.put_line('error msg: ' || l_err_msg);
                  dbms_output.put_line('at index: ' || l_idx);
               END LOOP ;
               ROLLBACK;
               RAISE;
    end ;
    cslmo@awpswebj-dev> @cslmo_users_update
    updated records: 1274There are about 20 or so other procedure in the import script. I don't want to rewrite them.
    Does anyone know why the UPDATE/SELECT is failing? I checked Metalink and could not find anything about this problem.

    This is now an Oracle bug, #9182070 on Metalink.
    TDE (transparent data encryption) does not work when an update/select statement references a remote database.

  • How to get the inserted row primary key with out  using select statement

    how to return the primary key of inserted row ,with out using select statement
    Edited by: 849614 on Apr 4, 2011 6:13 AM

    yes thanks to all ,who helped me .its working fine
    getGeneratedKeys
    String hh = "INSERT INTO DIPOFFERTE (DIPOFFERTEID,AUDITUSERIDMODIFIED)VALUES(DIPOFFERTE_SEQ.nextval,?)";
              String generatedColumns[] = {"DIPOFFERTEID"};
              PreparedStatement preparedStatement = null;
              try {
                   //String gen[] = {"DIPOFFERTEID"};
                   PreparedStatement pstmt = conn.prepareStatement(hh, generatedColumns);
                   pstmt.setLong(1, 1);
                   pstmt.executeUpdate();
                   ResultSet rs = pstmt.getGeneratedKeys();
                   rs.next();
    //               The generated order id
                   long orderId = rs.getLong(1);

  • Can anyone help with problem updating iphone5s cant get anything only apple on screen sometimes screen flashes blue

    can anyone help with problem updating iphone5s cant get anything only apple on screen sometimes screen flashes blue

    Hey damien555,
    Thanks for the question, I understand how frustrating this may be. It sounds like the update process may have been interrupted, and to resolve the issue, we’ll need to restore your device in recovery mode with iTunes:
    If you can't update or restore your iOS device
    http://support.apple.com/kb/HT1808
    Thanks,
    Matt M.

  • Help with an update query

    I have two tables, one is sierra_price, which just has a part_number and a sierra_list
    I have another table called products which is already populated with the parts from sierra_price, just no prices. It also has other products in it that are not included in sierra_price
    What I need to do is update products with the base_price where products.sku is the same as sierra_price.part_number
    I'm using db 10.2
    I'm having trouble with this query...
    UPDATE products
    SET base_price = (select sierra_list from sierra_price where products.sku = sierra_price.part_number)
    WHERE products.mfg_account_id = 4
    I get the error:
    ORA-01427: single-row subquery returns more than one row
    Edited by: user10785816 on Jan 16, 2009 9:18 AM

    I got it to run with the query:
    Update
    (Select base_price bp, sierra_list sp from products p, sierra_price s where p.sku = s.part_number and p.mfg_account_id = 4)
    SET bp = sp
    I also had to set the primary key in sierra_price to the part_number to get it to work.
    I'm quite new to SQL, but cheers for trying to help me!

  • Need help with understanding updates, partitions, firmware etc.

    I went to update my QuickTime and in doing so was told to update my OS which included QT updates. Now I'm getting all kinds of messages about partitions, firmware etc. do not understand at all what's going on.

    THIS IS MY STEP BY STEP situation with my updates:
    I go to the Apple Icon and selected Software Update and it reads I have 2 items:
    MacBook EFI Firmware Update 1.2
    MacBook SMC Firmware Update 1.4
    I select Install and then it state Installs completed successfully.
    BUT THEN I recieve and new icon and this message below: 
    To update the SMC firmware on your MacBook:
    Your computer's power cord must be connected and plugged into a working power source, or your battery must be at least 25% charged.
    For more information see 'http://support.apple.com/kb/TS3499'.
    1. Quit all other open applications.
    2. Click Restart in the MacBook SMC Firmware Update window and wait for your computer to restart.
    The SMC firmware update starts automatically. A status bar indicates the progress of the update. During the update your computer fans will run at full speed, but will return to normal once the update completes.
    Important: Do not interrupt the update.
    Your computer restarts automatically when the update is completed and opens the MacBook SMC Firmware Update.
    3.  Click OK. The SMC firmware is now up-to-date.
    If these instructions appear on your screen again, the SMC firmware update was not successful. Repeat steps 2 and 3.
    I follow the instructions and then I get this: (could get my image to attach but here's what it said)
    the first error message heading of:
    MacBook SMC Firmware Update 1.4
    Your firmware could not be updated, the hard drive partition scheme may not be supported.  You must be booted from a GUID partition or RAID scheme.
    see http://support.apple.com/kb/HT2434 for more information (internal error 28:3)
    THEN ANOTHER ONE POPS UP saying:
    Your Hard Drive partition scheme is not supported, you must be booted from a GUID partition scheme.
    see http://docs.info.apple.com/article.html? artnum=303609 for more information
    I went to those URL and tried to understand what it was telling me but I did not understand.  I can't figure, by reading thru forums, etc, if I need to do this or not and what exactly it is.
    So back to just pushing a simplet update has thrown all this unknown info. my way and I have no clue what to do.
    Thank you. Hope this is more clear.

  • Help with a large compound statement - sort of

    Hi all. Hopefully you can help me. I'm trying to develop a little application in htmldb/ application express and having troubles with one little box.
    I have a page item that will have a value between 2003 and 2036. I will be referencing the value of this item from the session state, no worries. The next item in the page will be based on this value and the session state will trigger one of 33 possible queries for this 2nd item. I know that sounds complex but it has to be that way unfortunately, the queries that will be triggered by this :ITEM_1 value are very different so there is no pretty way of doing that bit.
    So say the value of Item1 = :ITEM1(session state value)
    I need to do something like
    IF
    :ITEM1 = '2004'
    THEN
    select column.name from table.name where condition
    ELSEIF
    :ITEM = '2005'
    THEN
    select column.name from table.name where condition
    ELSEIF
    :ITEM = '2006'
    THEN
    ''you get the idea
    I need to repeat this the 33 times for 33 different SELECT statements. I've tried to figure out the best way to approach it, whether that is an IF statement, a WHERE statement or similar but am really struggling. I have no training in any of this and am not an IT person or programmer, just a cartograpaher who got an extra job to do :)
    Which is the best approach for me here? And what is the syntax I need to use? I tried the IF statements but must be making some really fundamental mistakes in syntax. Forums are the only support available to me. Please help.....
    Cheers and thanks for your time. Michael

    :ITEM1 = '2004' ... :ITEM = '2005'
    select column.name from table.name where conditionAssuming ITEM1 and ITEM is just a typo and if the select statement is the same, you can use
    if :ITEM BETWEEN TO_NUMBER('2004') and TO_NUMBER('2005') THEN
    select column.name from table.name where condition
    end if;
    HTH
    Ghulam

  • Help with a update query from a subquery

    Hello All,
    I wanted to see if someone can help me with an update query.
    I need to grab a latitude & longitude from a the same user that is in two accounts. therefore i am trying to update lat/long in a users table for one account based off of the same user in another account. I am matching the users up by phone number and last name. I tried a subquery but am having difficulty.
    I was thinking of something like the following:
    update users
    set lat = getlat, long = getlong
    inner join (select lat as getlat, long as get long from users where account_id = '1')
    on phone = phone and last name = lastname
    where account_id = '2' and lat IS NULL and long IS NULL
    Am I going in the right direction???
    Thanks in advance for any assistance!!!!

    What difficulty are you having? Have you tried what you posted and get an error?
    Although someone may be able to give you sql advice here, I would try posting this over at Stack Overflow as its not really related to Coldfusion.

  • Help with replicating/updating vendor master data

    Hi,
    Currently, we run the bbp_vendor_sync program to do the replication. It does the job of both bbpgetvd (new vendor creation) and bbpupdvd (update existing vendor).
    But the problem is, we have two number ranges for vendors. One is Numeric and other one is Alpha.
    Group -->AB     From 0010000000     to 0699999999
    Group -->AZ     From A     to ZZZZZZZZZZ
    The vendor synchronization program can consider only one number range at a time i.e.
    either Numeric or Alpha. So, we have to switch the active number range
    and run the program twice., first for numeric and then for alpha.
    In order to avoid this, I'm looking at implementing bbp_transdata_prep which I was told would take care of this issue.
    I looked around for documentation/sample code for bbp_transdata badi and couldnt find any on SAP help site or SDN.
    Wondering if someone can help with the documentation/sample code and difficuly level of implementing this BADI.
    Any help would be highly appreciated and suitable points would be awarded for your help.
    Also, if there is another way to solve this issue without implementing transdata badi, pls. let me know.
    TIA,
    Seyed

    Hi
    <u>Please go through this -></u>
    http://help.sap.com/saphelp_srm50/helpdata/en/56/54f137a5e6740ae10000009b38f8cf/frameset.htm
    http://help.sap.com/saphelp_srm50/helpdata/en/62/fb7d3cb7f58910e10000000a114084/frameset.htm
    http://help.sap.com/saphelp_srm50/helpdata/en/42/d3b671ba67136fe10000000a1553f7/frameset.htm
    http://help.sap.com/saphelp_srm50/helpdata/en/bb/6c0e3b02616a42e10000000a11402f/frameset.htm
    <b><u>Sample BADI Implementation
    BADI Definition - BBP_TRANSDATA_PREP
    Purpose -> Impl. for BBP_TRANSDATA_PREP, Delete Invalid Mail Addresses</u></b>
    <u>PREPARE_REPLICATION_DATA method -></u>
    method IF_EX_BBP_TRANSDATA_PREP~PREPARE_REPLICATION_DATA.
      FIELD-SYMBOLS: <LFS_ADR6> TYPE ADR6.
      LOOP AT CT_ADR6 ASSIGNING <LFS_ADR6>.
        IF <LFS_ADR6>-SMTP_ADDR NS '@'.
          DELETE CT_ADR6.
        ENDIF.
      ENDLOOP.
    endmethod.
    <u>PREPARE_UPDATE_DATA method -></u>
    method IF_EX_BBP_TRANSDATA_PREP~PREPARE_UPDATE_DATA.
      FIELD-SYMBOLS: <LFS_ADR6> TYPE ADR6.
      LOOP AT CT_ADR6 ASSIGNING <LFS_ADR6>.
        IF <LFS_ADR6>-SMTP_ADDR NS '@'.
          DELETE CT_ADR6.
        ENDIF.
      ENDLOOP.
    endmethod.
    Hope this will help.
    Regards
    - Atul

  • Retrieve floating point data with an sql select statement

    Hi
    I'm quite new to using sql but I have a system working where I can read and write strings to an access database.
    Now I want to retrieve a a float, from a field where another field in the same post corresponds to a specified float, with a select statement.
    When using strings I wrote
    SELECT column_name FROM [table_name] WHERE column2_name='value'
    in my query.
    But instead of getting the desired value I get an error message telling me that I have a
    "Data type mismatch in criteria expression".
    I think I understand why but does anybody know what I should have written instead?

    Is the data type of column2_name String?  If it's not, I think the single-quotes you have around 'value' will cause that error.
    Jim
    You're entirely bonkers. But I'll tell you a secret. All the best people are. ~ Alice

  • Help with CS5 Updates Failed, Updates could not be applied, Error Code U43M1D207

    CS5 Updates Failed, Updates could not be applied, Error Code U43M1D207
    Can anyone help with this error code?
    Products installed and activated on new laptop
    Unable to update using Adobe Application Manager
    Thank you

    I followed up on the Photoshop Error code and found some suggestions by Jeff Tranberry and Pete Green here.
    Michael

  • Help with a union all statement

    Hello
    I am pulling a query much like this:
    (select ID, Created_timestamp from snapshot1
    where created_timestamp >= to_date ('8/15/2007 12:00:00 AM','MM/DD/YYYY HH:MI:SS AM')
    and created_timestamp < to_date('8/18/2007 12:00:00 AM','MM/DD/YYYY HH:MI:SS AM'))
    UNION ALL
    (select ID, created_timestamp from snapshot2
    where created_timestamp >= to_date ('8/15/2007 12:00:00 AM','MM/DD/YYYY HH:MI:SS AM')
    and created_timestamp < to_date('8/18/2007 12:00:00 AM','MM/DD/YYYY HH:MI:SS AM'))
    UNION ALL
    (select ID, created_timestamp from data_history
    where created_timestamp >= to_date ('8/15/2007 12:00:00 AM','MM/DD/YYYY HH:MI:SS AM')
    and created_timestamp < to_date('8/18/2007 12:00:00 AM','MM/DD/YYYY HH:MI:SS AM'))
    Is there an easier way to handle created_timestamp?
    I would like to put it at the beginning so I only have to change it in one place.

    I don't understand.
    I try your with statement and get: "end_date" invalid identifier as an error
    I start my query out:
    WITH start_date as
    (select to_date ('08/15/2007 12:00:00 AM','MM/DD/YYYY HH:MI:SS AM') from dual),
    end_date as (select to_date ('08/18/2007 12:00:00 AM','MM/DD/YYYY HH:MI:SS AM) from dual)
    select sales.id, start_date as callstart, end_date as callend
    where sales.created_timestamp >= start_date
    and sales.created_timestamp < end_date
    UNION ALL
    <<<<<<<here is where you take the last select statement and replace sales with manufacturing>>>>>>>>>>>>>
    UNION ALL
    <<<<<<<here is where you take the last select statement and replace sales with engineering>>>>>>>>>>>>>
    and it still fails.

Maybe you are looking for

  • How to find the supplier user who done the confirmation

    We have the setup- Supplier can confirm either through Web UI or by uploading a XL file into SNC. we have several supplier user account per BP, Say (user1,user2...user5 - BP 2000010). Now i need to find which user have made the confirmation and Publi

  • Temp tables

    Does Oracle support #temp tables like SQL Server 7? And if it does, then how? Thank you very much in advance.

  • List of script and smart forms(except TNAPR) with output type or print prog

    How to find out List of SAP SCRIPT and SMART FORMS (except TNAPR)with output type or print program..I like to chk in output type WMTA  whch form should use.kindly help on this

  • HTPC Coaxial Help / Quest

    Hi everyone, I just joined this forum and am fairly new to the HTPC world. I am confused about how coaxial works when connecting to a receiver, and more importantly, what X-Fi product (or other product) I should purchase for my needs. I want to be ab

  • I want to view report when a filter is not selected

    Hi, I made a report with 3 filters and the report runs fine. But i want it to make a report such that it works if i doesn't give values to filters. Thanks in advance, Ganesh