Using a date field to remove 'duplicates'

Hi all,
Really struggling here, would appreciate some fresh ideas !!
I have a ton of rows in a table that are duplicates with the exception of a date field that differs very slightly.
e.g.
TO_CHAR(START_DATE,'
13-JUN-2007 12:39:03
13-JUN-2007 12:39:10 << dup
18-JUN-2007 05:49:15
18-JUN-2007 05:49:21 << dup
13-JUN-2007 09:02:25
13-JUN-2007 09:02:32 << dup
It would be great if I could identify these dups in SQL and remove them. I've sampled the data and the times are out by between 5 and 7 seconds so if I could weed out all rows that have another row with a time that differs by <10 seconds that would be ideal.
My other, but not as thorough, idea was to drop the seconds and I would be then able to drop them as if they were true duplicates ... run the risk of not catching some that way though.
Any ideas?
Many thanks in advance!
Adam

Assuming that you could legititmately have two records for the same day that are more then 10 seconds apart (and you would not consider these to be duplicates, then something along these lines should do it. In the initial select, I have bolded the "duplicates"
pre]SQL> SELECT * FROM rt;
SNO SDATE
1 13-jun-2007 12:39:03
1 13-jun-2007 12:39:10
1 13-jun-2007 12:39:12
1 13-jun-2007 12:39:45
2 18-jun-2007 05:49:15
2 18-jun-2007 05:49:21
3 13-jun-2007 09:02:25
3 13-jun-2007 09:02:32
SQL> DELETE FROM rt
2 WHERE rowid IN (SELECT rid
3 FROM (SELECT sno, sdate, rowid rid,
4 LAG(sdate) OVER (PARTITION BY sno
5 ORDER BY sdate) rn
6 FROM rt)
7 WHERE (sdate - NVL(rn, sdate))*24*60*60 BETWEEN 1 and 10);
4 rows deleted.
SQL> SELECT * FROM rt;
SNO SDATE
1 13-jun-2007 12:39:03
1 13-jun-2007 12:39:45
2 18-jun-2007 05:49:15
3 13-jun-2007 09:02:25
This keeps the oldest of the duplicates by sdate, if you want to keep the newest, then something like:
SQL> rollback;
Rollback complete.
SQL> DELETE FROM rt
  2  WHERE rowid IN (SELECT rid
  3                  FROM (SELECT sno, sdate, rowid rid,
  4                               LEAD(sdate) OVER (PARTITION BY sno
  5                                                ORDER BY sdate) rn
  6                        FROM rt)
  7                  WHERE (NVL(rn, sdate) - sdate)*24*60*60 BETWEEN 1 and 10);
4 rows deleted.
SQL> SELECT * FROM rt;
       SNO SDATE
         1 13-jun-2007 12:39:12
         1 13-jun-2007 12:39:45
         2 18-jun-2007 05:49:21
         3 13-jun-2007 09:02:32John

Similar Messages

  • How to select data from a table using a date field in the where condition?

    How to select data from a table using a date field in the where condition?
    For eg:
    data itab like equk occurs 0 with header line.
    select * from equk into table itab where werks = 'C001'
                                                      and bdatu = '31129999'.
    thanks.

    Hi Ramesh,
    Specify the date format as YYYYMMDD in where condition.
    Dates are internally stored in SAP as YYYYMMDD only.
    Change your date format in WHERE condition as follows.
    data itab like equk occurs 0 with header line.
    select * from equk into table itab where werks = 'C001'
    and bdatu = <b>'99991231'.</b>
    I doubt check your data base table EQUK on this date for the existince of data.
    Otherwise, just change the conidition on BDATU like below to see all entries prior to this date.
    data itab like equk occurs 0 with header line.
    select * from equk into table itab where werks = 'C001'
    and <b> bdatu <= '99991231'.</b>
    Thanks,
    Vinay
    Thanks,
    Vinay

  • Using a date field in a JDOQL query crashes

    Hello:
    I am trying to use a date field in a JDOQL filter. It appears from the
    log file that the date is not being substituted into the SQL.
    It is not clear from the JDOQL spec how to do date queries.... doing date
    queries in SQL involves several special operators, yet the
    JDOQL defines the ">" and "<" operators as working on dates....and there is
    no mention of date specific operators so I am hoping that I
    can do a filter where I compare a date to an input parameter date using the
    ">" and "<" operators...
    I have enclosed a copy of my driver code, followed by an except of my class
    that contains the date, followed by the kodo exception log
    I can't see where I am doing anything that violates the JDOQL spec and I
    don't see any other way of doing date comparisions.
    Brian
    Here is the driver code that I am attempting:
    public void getDateRange ()
    PersistenceManager pm = JDOFactory.getPersistenceManager ();
    String filter = "leafDates.contains (cdate) & cdate.statusName ==
    myStatus & cdate.datePhaseStarted > myDate";
    Date date = new Date ();
    Calendar calendar = new GregorianCalendar (TimeZone.getDefault ());
    calendar.set (2002, Calendar.DECEMBER, 26);
    date=calendar.getTime();
    Extent extent = pm.getExtent (LeafBase.class, false);
    Query query = pm.newQuery (LeafBase.class, filter);
    query.declareImports ("import aqueduct.*; import java.util.Date");
    query.declareVariables ("aqueduct.LeafDate cdate; Date myDate");
    query.declareParameters ("String myStatus");
    System.out.println ("dated used = " + date);
    Collection results = (Collection) query.execute ("closed", date);
    Iterator iter = results.iterator ();
    while (iter.hasNext () ) {
    LeafBase myLeaf = (LeafBase) iter.next ();
    System.out.println ("My leaf = " + myLeaf);
    pm.close ();
    Here is the class:
    public class LeafDate implements Serializable
    // *******The Attributes***************
    private Date datePhaseStarted = null;
    private boolean isEstimatedDate = false;
    //mark this as non-persistent in the JDO metadata
    private StatusType status = null;
    //put here to enable one-to-many mapping using a single table in JDO
    private LeafBase parent = null;
    Here is the error I am getting:
    C:\bcs\jdo\kodo-jdo-2.4.0\aqueduct>java aqueduct.DealMaint dated used = Thu
    Dec 26 08:47:33 CST 2002
    Exception in thread "main" javax.jdo.JDODataStoreException:
    com.solarmetric.kodo.impl.jdbc.sql.SQLExceptionWrapper:
    [SQL=SELECT DISTINCT t0.ID, t0.JDOCLASS, t0.IS_CONFLICT, t0.CURRENCYX,
    t0.DEALPARENTX, t0.PARENTX, t0.PRODUCTKIND, t0.T_SIZE, t0.STATUSNAME FROM
    JDO_DATE t1, JDO_LEAF t0 WHERE ((t1.STATUSNAME = 'closed' AND t1.DATESTARTED
    *variable*) AND t0.ID = t1.PARENTX) PRE=SELECT DISTINCT t0.ID,
    t0.JDOCLASS, t0.IS_CONFLICT, t0.CURRENCYX, t0.DEALPARENTX, t0.PARENTX,
    t0.PRODUCTKIND, t0.T_SIZE, t0.STATUSNAME FROM JDO_DATE t1, JDO_LEAF t0 WHERE
    ((t1.STATUSNAME = ? AND t1.DATESTARTED > *variable*) AND t0.ID =
    t1.PARENTX)
    ORA-00936: missing expression
    [code=936;state=42000]
    NestedThrowables:com.solarmetric.kodo.impl.jdbc.sql.SQLExceptionWrapper:
    [SQL=SELECT DISTINCT t0.ID, t0.JDOCLASS, t0.IS_CONFLICT, t0.CURRENCYX,
    t0.DEALPA RENTX, t0.PARENTX, t0.PRODUCTKIND, t0.T_SIZE, t0.STATUSNAME FROM
    JDO_DATE t1, JD O_LEAF t0 WHERE ((t1.STATUSNAME = 'closed' AND
    t1.DATESTARTED > *variable*) AND t0.ID = t1.PARENTX)] [PRE=SELECT DISTINCT
    t0.ID, t0.JDOCLASS, t0.IS_CONFLICT, t0.CURRENCYX, t0.DEALPA RENTX,
    t0.PARENTX, t0.PRODUCTKIND, t0.T_SIZE, t0.STATUSNAME FROM JDO_DATE t1, JD
    O_LEAF t0 WHERE ((t1.STATUSNAME = ? AND t1.DATESTARTED > *variable*) AND
    t0.ID = t1.PARENTX)]
    ORA-00936: missing expression
    at
    com.solarmetric.kodo.impl.jdbc.runtime.SQLExceptions.throwDataStore(SQLExcep
    tions.java:23)
    at
    com.solarmetric.kodo.impl.jdbc.runtime.JDBCStoreManager.executeQuery(JDBCSto
    reManager.java:742)
    at
    com.solarmetric.kodo.impl.jdbc.runtime.JDBCQuery.executeQuery(JDBCQuery.java
    :92)
    at com.solarmetric.kodo.query.QueryImpl.executeWithMap(QueryImpl.java:792)
    at com.solarmetric.kodo.query.QueryImpl.executeWithArray(QueryImpl.java:668)
    at com.solarmetric.kodo.query.QueryImpl.execute(QueryImpl.java:623)
    at aqueduct.DealMaint.getDateRange(DealMaint.java:523)
    at
    aqueduct.DealMaint.main(DealMaint.java:35)NestedThrowablesStackTrace:java.sq
    l.SQLException:
    ORA-00936: missing expression
    at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:169)
    at oracle.jdbc.ttc7.TTIoer.processError(TTIoer.java:208)
    at oracle.jdbc.ttc7.Oall7.receive(Oall7.java:543)
    at oracle.jdbc.ttc7.TTC7Protocol.doOall7(TTC7Protocol.java:1405)
    at oracle.jdbc.ttc7.TTC7Protocol.parseExecuteDescribe(TTC7Protocol.java:643)
    at
    oracle.jdbc.driver.OracleStatement.doExecuteQuery(OracleStatement.java:1819)
    at
    oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java
    :2015)
    at
    oracle.jdbc.driver.OraclePreparedStatement.doScrollPstmtExecuteUpdate(Oracle
    PreparedStatement.java:3021)
    at
    oracle.jdbc.driver.OraclePreparedStatement.executeUpdate(OraclePreparedState
    ment.java:416)
    at oracle.jdbc.driver.OraclePreparedStatement.executeQuery(OraclePrepare

    Oh, thanks for pointing this out.... I got caught up in trying to figure out
    the date issues, I missed the obvious.
    Brian
    "Patrick Linskey" <[email protected]> wrote in message
    news:[email protected]...
    Brian,
    The problem is that you're declaring myDate as a variable instead of a
    parameter. Yes, we should be doing better error checking. But that's the
    problem.
    So, change your declareVariables() and declareParameters() statements
    accordingly, and all should work out.
    -Patrick
    Brian Smith wrote:
    Here is the driver code that I am attempting:
    public void getDateRange ()
    PersistenceManager pm = JDOFactory.getPersistenceManager ();
    String filter = "leafDates.contains (cdate) & cdate.statusName ==
    myStatus & cdate.datePhaseStarted > myDate";
    Date date = new Date ();
    Calendar calendar = new GregorianCalendar (TimeZone.getDefault
    >>
    calendar.set (2002, Calendar.DECEMBER, 26);
    date=calendar.getTime();
    Extent extent = pm.getExtent (LeafBase.class, false);
    Query query = pm.newQuery (LeafBase.class, filter);
    query.declareImports ("import aqueduct.*; importjava.util.Date");
    >>
    query.declareVariables ("aqueduct.LeafDate cdate; Date myDate");
    query.declareParameters ("String myStatus");
    System.out.println ("dated used = " + date);
    Collection results = (Collection) query.execute ("closed", date);
    Iterator iter = results.iterator ();
    while (iter.hasNext () ) {
    LeafBase myLeaf = (LeafBase) iter.next ();
    System.out.println ("My leaf = " + myLeaf);
    pm.close ();
    >
    Here is the class:
    public class LeafDate implements Serializable
    // *******The Attributes***************
    private Date datePhaseStarted = null;
    private boolean isEstimatedDate = false;
    //mark this as non-persistent in the JDO metadata
    private StatusType status = null;
    //put here to enable one-to-many mapping using a single table in JDO
    private LeafBase parent = null;
    >
    Here is the error I am getting:
    C:\bcs\jdo\kodo-jdo-2.4.0\aqueduct>java aqueduct.DealMaint dated used
    = Thu
    Dec 26 08:47:33 CST 2002
    Exception in thread "main" javax.jdo.JDODataStoreException:
    com.solarmetric.kodo.impl.jdbc.sql.SQLExceptionWrapper:
    [SQL=SELECT DISTINCT t0.ID, t0.JDOCLASS, t0.IS_CONFLICT, t0.CURRENCYX,
    t0.DEALPARENTX, t0.PARENTX, t0.PRODUCTKIND, t0.T_SIZE, t0.STATUSNAMEFROM> > JDO_DATE t1, JDO_LEAF t0 WHERE ((t1.STATUSNAME = 'closed' AND> > t1.DATESTARTED> >> > >*variable*) AND t0.ID = t1.PARENTX) [PRE=SELECT DISTINCT t0.ID,
    >
    ORA-00936: missing expression
    [code=936;state=42000]
    NestedThrowables:com.solarmetric.kodo.impl.jdbc.sql.SQLExceptionWrapper:
    [SQL=SELECT DISTINCT t0.ID, t0.JDOCLASS, t0.IS_CONFLICT, t0.CURRENCYX,
    t0.DEALPA RENTX, t0.PARENTX, t0.PRODUCTKIND, t0.T_SIZE, t0.STATUSNAMEFROM
    JDO_DATE t1, JD O_LEAF t0 WHERE ((t1.STATUSNAME = 'closed' AND
    t1.DATESTARTED > variable) AND t0.ID = t1.PARENTX)] [PRE=SELECTDISTINCT
    t0.ID, t0.JDOCLASS, t0.IS_CONFLICT, t0.CURRENCYX, t0.DEALPA RENTX,
    t0.PARENTX, t0.PRODUCTKIND, t0.T_SIZE, t0.STATUSNAME FROM JDO_DATE t1,JD
    O_LEAF t0 WHERE ((t1.STATUSNAME = ? AND t1.DATESTARTED > variable) AND
    t0.ID = t1.PARENTX)]
    ORA-00936: missing expression
    at
    com.solarmetric.kodo.impl.jdbc.runtime.SQLExceptions.throwDataStore(SQLExcep
    tions.java:23)
    at
    com.solarmetric.kodo.impl.jdbc.runtime.JDBCStoreManager.executeQuery(JDBCSto
    reManager.java:742)
    at
    com.solarmetric.kodo.impl.jdbc.runtime.JDBCQuery.executeQuery(JDBCQuery.java
    :92)
    atcom.solarmetric.kodo.query.QueryImpl.executeWithMap(QueryImpl.java:792)
    >>
    at
    com.solarmetric.kodo.query.QueryImpl.executeWithArray(QueryImpl.java:668)
    >>
    at com.solarmetric.kodo.query.QueryImpl.execute(QueryImpl.java:623)
    at aqueduct.DealMaint.getDateRange(DealMaint.java:523)
    at
    aqueduct.DealMaint.main(DealMaint.java:35)NestedThrowablesStackTrace:java.sq
    l.SQLException:
    ORA-00936: missing expression
    at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:169)
    at oracle.jdbc.ttc7.TTIoer.processError(TTIoer.java:208)
    at oracle.jdbc.ttc7.Oall7.receive(Oall7.java:543)
    at oracle.jdbc.ttc7.TTC7Protocol.doOall7(TTC7Protocol.java:1405)
    at
    oracle.jdbc.ttc7.TTC7Protocol.parseExecuteDescribe(TTC7Protocol.java:643)
    >>
    at
    oracle.jdbc.driver.OracleStatement.doExecuteQuery(OracleStatement.java:1819)
    >>
    at
    oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java
    :2015)
    at
    oracle.jdbc.driver.OraclePreparedStatement.doScrollPstmtExecuteUpdate(Oracle
    PreparedStatement.java:3021)
    at
    oracle.jdbc.driver.OraclePreparedStatement.executeUpdate(OraclePreparedState
    ment.java:416)
    at oracle.jdbc.driver.OraclePreparedStatement.executeQuery(OraclePrepare
    Patrick Linskey [email protected]
    SolarMetric Inc. http://www.solarmetric.com

  • How do I apply filters or limit the rows on my report using a Date field in SQL report builder 3.0?

    I have a status of completed and a date field in the dataset. The date field is either empty or contains a date. All 2015 dates are holding dates.
    So how can I limit the report to only pull completed status with an empty date or a holding date?
    I have not been able to set an OR option on a date field filter and if I add two filters on the date column one for empty one for > 12/31/2014 then it treats it as an "and" and pulls nothing from the list I have in sharepoint.
    any help will be appreciated.

    Hi MB,
    In Reporting Services, the relationship of  filters is “And”, and there is no option to change the relationship from “And” to “Or”. While we can use “or” operator within the expression to create one filter to integrated all filters to work around this
    issue.
    We can add a filter as follows in the dataset to limit the rows in your report:
    Expression: =Fields!date.Value is nothing or Fields!date.Value>"12/31/2014"    Type: Boolean
    Operator: =
    Value: true
    If there are any other questions, please feel free to ask.
    Thanks,
    Katherine Xiong
    If you have any feedback on our support, please click
    here.
    Katherine Xiong
    TechNet Community Support

  • Creating a Calendar View using alternative date fields

    I have a Sharepoint 2007 calendar list that includes the standard Start and End Date fields.  I also have "Suggested Start Date" and "Suggested End Date" fields that are utilized by users to recommend the Start and End Dates for
    the event.
    I can create a Calendar view that displays the events according to the Start and End dates.
    I cannot create a Calendar view that displays the events according to the Suggested Start and Suggested End date fields.
    In practice, all items are not displayed on this second calendar view that should be displayed even though you can choose these fields as Time Interval values when establishing the calendar.
    Is there a way to create a Calendar View that will use date fields other than the default Start and End date fields?
    Thanks,
    Chris Mang>> JDA Software Group, Inc.

    Hello,
    It seems problem with time value. Have you included time value in custom datatime column wile creating? What happens when you select "date only" from column settings?
    You can also try below suggestion to include "IncludeTimeValue" parameter in CAMl query by designer:
    http://stackoverflow.com/questions/18362853/how-do-i-filter-by-today-and-time-in-sharepoint-list-view
    OR else create two more calculated column and save date only in those columns then filter by them.
    Hope it could help
    Hemendra:Yesterday is just a memory,Tomorrow we may never see
    Please remember to mark the replies as answers if they help and unmark them if they provide no help

  • Problem Querying Oracle Forms Using a Date Field and a Format Mask

    Hello,
    We are experiencing a problem with Oracle Forms that I was wondering if you can help me with.
    We have several Forms that have single database blocks assigned to Oracle tables. The Forms are queryable and one of the fields we’re querying on is assigned to a field on the base table which is Not Null and has a Type of DATE. We are storing date/time information in this field on the database table. The item on the form is set up as a Date field with a Maximum Length of 7, a Format Mask ‘MMDDYY’ and having a Query Length of 10.
    We’ve seen a discrepancy in how these fields are used to query the base table block. On some user’s computers they are able to enter a 6 digit date followed by the % sign (e.g. ‘091808%’) and they get the expected results. Other users get ‘FRM-40301: Query caused no records to be retrieved. Re-enter’. Do you know why we are experiencing this difference?
    - The Oracle Database version we are running is Release 10.1.0.5.0.
    - The Forms Developer version that we’re experiencing the problem with is 4.5.10.15.2
    Thanks,
    Kris

    There is no obvious reason that I can see.
    Version 4.5 is very old so you might have problems calling Oracle Support. If you can reproduce the same problem o0n 10.1.2 you should call have them analyze the problem.

  • Selective Deletion using 0REQUID & Date fields in combination

    We are running SAP NetWeaver 2004s patch 15 I have tried to run a selective deletion with request ID and date fields but we are getting an SQL error.  The cube is compressed but the requests I am after have not been compressed.  Is this an activity I should be able to do?  I have checked SAP messages and found one but it was for version much older than ours  below is the error message I recieve in the Job Log.
    Job started
    Step 001 started (program RSINDEX1, variant &0000000000098, user ID BROWNAW)
    SQL: 2010/12/16 15:06:21
    CREATE TABLE "/BI0/0100000703" (DIMID INTEGER
    NOT NULL) IN CMC#BTAB
    SQL-END: 2010/12/16 15:06:21 00:00:00
    SQL: 2010/12/16 15:06:21
    insert into "/BI0/0100000703" SELECT DISTINCT
    DIMID FROM "/BIC/DZFIGL_STGP" WHERE (
    "DIM"."SID_0REQUID" =  109126
    SQL Error: SQL0206N  "DIM.SID_0REQUID" is not valid in the co ntext where it is used
    SQL-END: 2010/12/16 15:06:21 00:00:00
    System error: CREATE_TABLE_AS_SELECT/RSDU_EXEC_SQL /BI0/0100000703 206-
    Job cancelled after system exception ERROR_MESSAGE

    Thanks for the quick response.  I have validated that the data ranges do exist for the requests.  Part of our process is to use the same selection to output the data before the deletion is ran so we can validate the number of records that are purged and have a backup of the data in case another issue is discovered at a later date. 
    When I run this seleciton for output I get over 30k records.  Unfortunately I cannot just blow away the requests as most contain data that needs to remain.  As well as we use this as a source for delta records that come from multiple sources so the logistics of resetting the delta indicator on the requests and not screwing up other delta's is a big risk.  If I should be able to run a selective deletion with request I am hoping SAP can respond with a fix to the issue.

  • Sending reports to various recipients using a data field on the report

    Hi,
    I am currently running Crystal Reports Server 2008 with SP 3  applied.
    I was wondering if this was possible.
    I have a report that I would like to be sent to an email address field on the table that the report runs from. Fields are something like this:
    Amount Due, Invoice #, Client's email address, Date
    What I would like CRS to do is send out emails depending on what's on the table. Obviously I would need the server to send out the report to a particular client with only the records that should be for them.
    I, for some reason, thought there was an ability to add a field from the report on the email itself using brackets or some sort of variable but I'm not sure if this is true.
    If anyone can help, I would appreciate it greatly.
    Thanks!

    You can use Publications for that. As far as I know this should be supported natively in CRS 2008 with SP3.
    Take a look at the demo on building a data-driver publication here:
    http://www.sap.com/solutions/sap-crystal-solutions/information-infrastructure/sapcrystalserver/featuresfunctions/index.epx
    You have to have CALs (concurrent access licenses) though.
    Regards,
    Stratos

  • How to use 2 date field as delta control in generic extractor.

    Hi colleagues:
    I have developed a generic extractor to extract logistic data: Purchase Orders and Invoice. In order to do that, I have defined a view joining EKBE, EKKO, EKPO, EKET tables on R/3. By this approach, the delta mechanism is supposed to be controlled by the EKBE-BUDAT field and also by the EKPO-AEDAT field. Both fields are available on the view used to create the Datasource. However, the Datasource creation allows us to define just one field as delta control.
    I have a few questions regarding to this scenario:
    <b>1 - Is it possible to define 2 fields as delta control field on Generic Datasource?</b>
    <b>2 - How about creating two similar Datasouces, one having AEDAT as delta control, the other having BUDAT as delta control, and then connect those Datasources to an unique Infosource on the bw side?</b>
    Best regards
    Waldemar

    hi,
    1 - as far as I know it is not possible to define 2 fields
    2 - this workaround is used often in cases like yours.
    Just remember about order of extracting: first you extract new documents then changed
    Regards,
    Andrzej

  • Is there a way to use a date field and conditionally change its LABEL?

    Hi I have 2 date select lists and desire to change the label text at runtime.
    If I use it for one query it would be Order Date, another it would be Start Date.
    ?? BillC

    Vikas,
    ...a page template is a special case since everything is finally rendered on a page.Don't know what you mean.
    references in page templates probably get evaluated first...References in page templates get replaced with their session state values when the portion of the page template containing the references is rendered, e.g., before the box, inside the box, after the box, in the footer..., and within each section each item reference is replaced "when it is encountered" with the current value of the item from session state.
    There is a Before Footer computation that sets that item to the current timestamp.I see an "After Regions" computation. On your page, the form item is rendered using the current (from the previous page request) value of the item in session state. Then your compuation sets a new value. Then the remaining sections of the page template (after the regions) are rendered and you see the newly computed value in the footer section of the template.
    Is there a way to pass in the current form item name to the shortcut so that I can have a generic shortcut that returns a different value for the label depending on which item it is being invoked from?Starting in XE and now in 2.2, you can use the strings #CURRENT_FORM_ELEMENT#, #CURRENT_ITEM_ID#, and #CURRENT_ITEM_NAME# in shortcuts. This makes PL/SQL Function shortcuts such as the following possible:  if '#CURRENT_ITEM_NAME#' = 'P2_ENAME' then
        return ('employee name');
      elsif '#CURRENT_ITEM_NAME#' = 'P2_JOB' then
        return ('job');
      else
        return ('foo');
      end if; Scott

  • Using a Date field to calculate another date equalling + 6 'Working Days'

    I am trying to provide a schedule return date based upon an Issued Date value
    The problem is that I only want the estimated return date value to include working days (6 to be precise), which are Monday to Friday.
    Any assistance in disregarding weekend days from my results would be greatly appreciated

    Try this
    DateTimevar IssueDate:={IssueDate field here};
    DateTimevar Scheduledate;
    Numbervar WeekEnds;
    Scheduledate:=DateAdd('d',6,IssueDate);
    Weekends:= DateDiff('WW',IssueDat,Scheduledate,CrSaturday)+DateDiff('WW',IssueDat,Scheduledate,CrSunday);
    Scheduledate:=Dateadd('d',Weekends,Scheduledate);
    IF DAYOFWEEK( Scheduledate) = CrSaturday THEN
       Scheduledate:= DATEADD('d', 2, Scheduledate);
    IF DAYOFWEEK( Scheduledate) = CrSunday THEN
       Scheduledate:= DATEADD('d', 1, Scheduledate);
    Scheduledate
    Jyothi
    Edited by: Jyothi Yepuri on Sep 3, 2009 6:55 AM
    Edited by: Jyothi Yepuri on Sep 3, 2009 7:07 AM

  • Using powershell to check and removing duplicate entries

    Hi Guys,
    I have been trying to get my head around powershell to check a csv file. It needs to read in each line in the csv and compare it to the last one and only pull out the entry with the newest time stamp. The data is something like this (btw it has no headers
    pulled into the csv file).
    UID,Type,Sub,Blank,deviceID,Brand,V#,OS,DType,Blank,Date/time
    TT1234567,PRINT,7DAY_SUB,,7DD758034,iPad3,6,IOS,Tablet,,2014-09-22T10:59:40.345Z
    TT1234567,PRINT,7DAY_SUB,,7DD758034,iPad3,6,IOS,Tablet,,2014-09-22T11:00:40.500Z
    TT1234567,PRINT,7DAY_SUB,,f04f7c213b0f,kftt,2,KINDLE,Tablet,,2014-09-23T11:25:16.303Z
    TT1234567,PRINT,7DAY_SUB,,f04f7c213b0f,kftt,2,KINDLE,Tablet,,2014-09-23T11:25:18.303Z
    TT1234567,PRINT,7DAY_SUB,,08606eb42491,nexus7,4.4,ANDROID,Tablet,,2014-09-24T14:48:23.668Z
    TT1234567,PRINT,7DAY_SUB,,08606eb42491,nexus7,4,4,ANDROID,Tablet,,2014-09-24T14:48:24.700Z
    [email protected],DIGITAL,DIG_SUB,,08606eb42491,nexus7,4.4,ANDROID,Tablet,,2014-09-24T15:09:08.359Z
    [email protected],DIGITAL,DIG_SUB,,08606eb42491,nexus7,4.4,ANDROID,Tablet,,2014-09-24T15:09:09.468Z
    TT1234567,PRINT,7DAY_SUB,,7DD758034,iPad3,6,IOS,Tablet,,2014-09-25T11:59:40.345Z
    TT1234567,PRINT,7DAY_SUB,,7DD758034,iPad3,6,IOS,Tablet,,2014-09-25T11:59:45.345Z
    Output to file should be like the following.
    TT1234567,PRINT,7DAY_SUB,,7DD758034,iPad3,6,IOS,Tablet,,2014-09-25T11:59:45.345Z
    TT1234567,PRINT,7DAY_SUB,,f04f7c213b0f,kftt,2,KINDLE,Tablet,,2014-09-23T11:25:18.303Z
    TT1234567,PRINT,7DAY_SUB,,08606eb42491,nexus7,4,4,ANDROID,Tablet,,2014-09-24T14:48:24.700Z
    [email protected],DIGITAL,DIG_SUB,,08606eb42491,nexus7,4.4,ANDROID,Tablet,,2014-09-24T15:09:09.468Z
    Same UID can have multiple devices we want to know all the devices and the latest time stamp. As you can see that
    TT1234567 used the ipad on the 2014-09-22T11:00:40.500Z
    but then used it again on the 2014-09-25T11:59:45.345Z we only want the newest time stamp for that device.
    I hope you guys can help me out. 

    Hi Nguyen,
    First of all, add a header for your csv (simplifies things a bit):
    ID,Type,Sub,Blank1,deviceID,Brand,VNum,OS,DType,Blank2,DateTime
    Then this single line will get you what you want:
    import-csv test.csv | group deviceID | %{$_.Group | Sort DateTime | Select -Last 1}
    Please note:
    Make sure your Csv conforms to Csv Standards (especially that the Delimiter is
    only used as delimiter, which in your sample data was not the case). If you cannot ensure this, you need to create a validation routine and fix it before you use this line. Too many delimiters will drop the DateTime from the list, leaving a blank datetime,
    causing the filtering to fail.
    Cheers,
    Fred
    There's no place like 127.0.0.1

  • How to remove duplicates

    Hi
    i am removing duplicate records while importing bulk data into the table...I am checking for some columns...when they are same, i am removing the old records...i have used the following code to remove duplicates...
    execute immediate 'DELETE FROM test1 WHERE ROWID IN (SELECT ROWID FROM (SELECT ROWID,ROW_NUMBER() OVER (PARTITION BY c1,c2 ORDER BY 1) row_no FROM test1)WHERE row_no > 1)';
    here i check c1 and c2 columns...if they are same the old records are to be deleted...but in this code, the new records are deleted..can anyone say how to remove old duplicate records?
    Vally

    Hi
    i am removing duplicate records while importing
    bulk data into the tableWhat you mean by using "while"?
    During the process of importing(read inserting) - you want to delete duplicate records?
    As you say in the following you have C1 and C2 - using both of them - you find duplicates.
    I deem you have other columns besides C1 and C2. And these columns have different fileds in NEW record and OLD record - then why don't you use UPDATE statement?
    ...I am checking for some
    columns...when they are same, i am removing the old
    records...i have used the following code to remove
    duplicates...you should clarify on what criteria you separate old records from new records and place this condition in your query.
    E.g. you have a field DATE_OF_ENTRY
    and the latest one is the new record which shouldn't be deleted
    then you would be able to put it into your delete statement:
    DELETE FROM test1
    WHERE ROWID IN (SELECT ROWID
                       FROM (SELECT ROWID,
                                    ROW_NUMBER() OVER(PARTITION BY c1, c2 ORDER BY DATE_OF_ENTRY desc) row_no
                               FROM test1)
                      WHERE row_no > 1)

  • Javascript for multiple date fields

    Hi all-
    I have to write javascript for 15 different date fields in a form.
    The requirement here is that we convert all date fields on Page 100 from date pickers (editable date fields) to display-only date fields with two controls for the users to set the date.
    If the field is empty (no date registered yet), there will be a green checkmark(X). When the user clicks this checkmark, the current date is entered into the field.
    If the field is not empty (there is a date already in the system), there will be a red X. When the user click this red X, the date from the date field is removed.
    The javascript I am using here is
    </script>
    <script type="text/javascript">
         function init(){
              var datePickerVal = $v2('P100_TODAYS_DATE');
              if(datePickerVal){
                   $x_Show('ToggleDateR');
                   $x_Hide('ToggleDateG');
              }else{
                   $x_Hide('ToggleDateR');
                   $x_Show('ToggleDateG');
         function toggleDateFunc(pValue){
              var sysDate = $v2('P100_DATE');
              if(pValue == 'R'){
                   $x_Hide('ToggleDateR');
                   $x_Show('ToggleDateG');
                   $x_Value('P100_TODAYS_DATE','');
              }else if(pValue == 'G'){
                   $x_Show('ToggleDateR');
                   $x_Hide('ToggleDateG');
                   $x_Value('P100_TODAYS_DATE',sysDate);
         window.onload = init;
    </script>
    This javascript is working for one date field( 'P100_TODAYS_DATE') but i have 15 different date fields in this page(100) all should have same funtionality. Please help me out how to write a logic to use this function for all the date fields.
    Thanks,(apex 3.2)
    Greenhorn
    Edited by: Greenhorn on Jul 19, 2011 12:30 PM

    Hi,
    You can do the needful by re-using the code if you can give the item names as P8_DATE1, P8_DATE_hh1, P8_DATE2, P8_DATEhh2 etc..So your item name just differs by a sequence.
    Now you write function which will return desired date value taking above items as input. Pass item names to this function, get session state using APEX_UTIL.GET_SESSION_STATE('item_name') API.
    Now modify you code as
    FOR i IN 1..30
    LOOP
    v_date_array[i] = f_get_date('P8_DATE'||i, 'P8_DATEhh'||i);
    END LOOP;
    ....Now you have all date valus in array. Just write one update as follows
    UPDATE  TABLE1
    SET date1 = my_date_array[1], date2 = my_date_array[2]..
    WHERE ....Hope it helps :)
    Cheers,
    Hari

  • Loading ODS - Data record exists in duplicate within loaded data

    BI Experts,
    I am attemping to load an ODS with the Unique Data Records flag turned ON.  The flat file I am loading is a crosswalk with four fields, the first 3 fields are being used as Key Fields in order to make the records unique.  I have had this issue before, but gave up in frustration and added an ascending number count field so simply create a unique key.  This time I would like to solve the problem if possible.
    The errors come back referring to two data rows that are duplicate:
    Data record 1 - Request / Data package / Data record: REQU_4CNUD93Q3RCC80XFBG2CZXJ0T/000003/ 339
    Data record 2 - Request / data package / data record: REQU_4CNUD93Q3RCC80XFBG2CZXJ0T/000003/ 338
    And below here are the two records that the error message refers to:
    3     338     3902301480     19C*     *     J1JD     
    3     339     3902301510     19C*     *     J1Q5     
    As you can see, the combination of my three Key Fields should not be creating a duplicate. (3902301480, 19C(asterisk) , (asterisk))   and (3902301510, 19C(asterisk) , (asterisk))  I replaced the *'s because they turn bold!
    Is there something off with the numbering of the data records?  Am I looking in the wrong place?  I have examined my flat file and can not find duplicates and the records that BW say are duplicates are not, I am really having a hard time with this - any and all help greatly appreciated!!!

    Thank you for the response Sabuj....
    I was about to answer your questions but I wanted to try one more thing, and it actually worked.  I simply moved the MOST unique Key Field to the TOP of my Key Field list. It was at the bottom before.
    FYI for other people with this issue -
    Apparantly the ORDER of your Key Fields is important when trying to avoid creating duplicate records.
    I am using four data fields, and was using three data fields as the Key Fields.  Any combination of all three would NOT have a duplicate, however when BW finds that the first two key fields match, sometimes it apparantly doesn't care about the third one which would make the row unique.  By simply changing the order of my Key Fields I was able to stop getting the duplicate row errors...
    Lesson - If you KNOW that your records are unique, and you are STILL getting errors for duplicates, try changing the ORDER of your key fields.

Maybe you are looking for