Best Practice Question for Date Compares

Hello,
I'm far from an expert on Oracle and PL/SQL, so I may have this all wrong.  I'm working on some selection scripts, and the guy that wrote these before me likes to convert parts of dates to numbers in order to do a compare.  It seems to me a trunc(date, part) would be much more efficient.  Can anyone confirm my thoughts here?
I'm seeing this a lot:
AND    TO_NUMBER (TO_CHAR (scheduleddate, 'YYYY')) = TO_NUMBER (TO_CHAR (SYSDATE - 1, 'YYYY'))
Seems to me that I'd be better off just doing:
trunc(scheduleddate, 'YEAR') = trunc(SysDate, 'YEAR').
Does that make sense?
Thanks!
Chad

CSchrieber wrote:
Hello,
I'm far from an expert on Oracle and PL/SQL, so I may have this all wrong.  I'm working on some selection scripts, and the guy that wrote these before me likes to convert parts of dates to numbers in order to do a compare.  It seems to me a trunc(date, part) would be much more efficient.  Can anyone confirm my thoughts here?
I'm seeing this a lot:
AND    TO_NUMBER (TO_CHAR (scheduleddate, 'YYYY')) = TO_NUMBER (TO_CHAR (SYSDATE - 1, 'YYYY'))
Seems to me that I'd be better off just doing:
trunc(scheduleddate, 'YEAR') = trunc(SysDate, 'YEAR').
Does that make sense?
Thanks!
Chad
however , you might want to play around with it a bit to confirm you get the behavior you want in your context.  I've not had much reason to use trunc, and in testing a few things just now to reply to admin1, I got some results that surprised me.  Another little learning project for me now.
But I stand behind the essence of my original reply.  The guy that wrote your original code was jumping through too many hoops (transform functions).

Similar Messages

  • SAP Adapter Best Practice Question for Deployment to Clustered Environment

    I have a best practices question on the iway Adapters around deployment into a clustered environment.
    According to the documentation, you are supposed to run the installer on both nodes in the cluster but configure on just the first node. See below:
    Install Oracle Application Adapters 11g Release 1 (11.1.1.3.0) on both machines.
    Configure a J2CA configuration as a database repository on the first machine.
    Perform the required changes to the ra.xml and weblogic-ra.xml files before deployment.
    This makes sense to me because once you deploy the adapter rar in the next step it the appropriate rar will get staged and deployed on both nodes in the cluster.
    What is the best practice for the 3rdParty adapter directory on the second node? The installer lays it down with the adapter rar and all. Since we only configure the adapter on node 1, the directory on node 2 will remain with the default installation files/values not the configured ones. Is it best practice to copy node 1's 3rdParty directory to node 2 once configured? If we leave node 2 with the default files/values, I suspect this will lead to confusion to someone later on who is troubleshooting because it will appear it was never configured correctly.
    What do folks typically do in this situation? Obviously everything works to leave it as is, but it seems strange to have the two nodes differ.

    What is the version of operating system. If you are any OS version lower than Windows 2012 then you need to add one more voter for quorum.
    Balmukund Lakhani
    Please mark solved if I've answered your question, vote for it as helpful to help other users find a solution quicker
    This posting is provided "AS IS" with no warranties, and confers no rights.
    My Blog |
    Team Blog | @Twitter
    | Facebook
    Author: SQL Server 2012 AlwaysOn -
    Paperback, Kindle

  • SAP Adapter Best Practice Question for Migration of Channels

    I have a best practice question on the SAP adapter when migrating an OSB project from one environment (DEV) to another (QA).
    If my project includes an adapter channel that (e.g., Inbound SAP Proxy listening on a channel), how do I migrate that project to another environment if the channel in the target environment is different.
    I tried using the search and replace mechanism in the sbconsole, but it doesn't find the channel name in the jca and wsdl files.
    What is the recommended way to migrate from one environment to the other when the channel name changes?

    I have a best practice question on the SAP adapter when migrating an OSB project from one environment (DEV) to another (QA).
    If my project includes an adapter channel that (e.g., Inbound SAP Proxy listening on a channel), how do I migrate that project to another environment if the channel in the target environment is different.
    I tried using the search and replace mechanism in the sbconsole, but it doesn't find the channel name in the jca and wsdl files.
    What is the recommended way to migrate from one environment to the other when the channel name changes?

  • Best practice question for Bounded task flows

    We are new to Jdeveloper/ADF and I was wondering if we should always try to use a bounded task flow for our applications... is this considered the best way to develop an app? even the small single page ones?
    Thanks in advance.

    Hi,
    let me turn teh question around: How many tools do you have at home beside of a hammer ? In other words, its the problem you need to solve (and use cases are problems) that should determine the use of bounded task flows and its granularity. Note that for each use case the bounded task flow makes a good candidate for delivering it. Doesn't mean that every single page needs to go into its own task flow. For general bounded best practices have a look here
    http://www.oracle.com/technetwork/developer-tools/jdev/adf-task-flow-design-132904.pdf
    Frank

  • Best practice question for implementing a custom component

    I'm implementing a custom component which renders multiple <input type="text" .../> controls as part of it. The examples I've seen that do something similar use the ResponseWriter to generate the markup "by hand" like:
         writer.startElement("input", component);
         writer.writeAttribute("type", "text", null);
         writer.writeAttribute("id", "foo", null);
         writer.writeAttribute("name", "foo", null);
         writer.writeAttribute("value", "hello", null);
         writer.writeAttribute("size", "20", null);
         writer.endElement("input");
    I don't know about anyone else, but I HATE having to write code that manufactures this stuff - seems to me that there are already classes that do this, so why not just use those? For example, the above could be replaced with:
         HtmlInputText textField = new HtmlInputText();
         textField.setId("foo");
         textField.setValue("hello");
         textField.setSize(20);
         // just to be safe, invoke both encodeBegin() and encodeEnd(),
         // though it seems like encodeEnd() actually does the work in this case,
         // but who knows if they might change it at some point
         textField.encodeBegin(context);
         textField.encodeEnd(context);
    So my question is, why does everyone seem to favor the former over the latter? Why not leverage objects that already do the (encoding) work for you?

    Got it!
    You JSP should have this:
    <h:panelGroup styleClass="jspPanel" id="jspPanel1"></h:panelGroup>
    And your code page ValueChangeListener/ActionListner should have this:
              if (findComponent(getForm1(),"myOutputText") == null)
                   FacesContext facesCtx = FacesContext.getCurrentInstance();
                   System.out.println("Adding component");
                   HtmlOutputText output =
                        (HtmlOutputText) facesCtx.getApplication().createComponent(
                             HtmlOutputText.COMPONENT_TYPE);
                   output.setId("myOutputText");
                   output.setValue("It works");
                   getJspPanel1().getChildren().add(output);          
                   System.out.println("Done");
                   DebugUtil.printTree(FacesContext.getCurrentInstance().getViewRoot(),System.out);
              else
                   System.out.println("component already added");
    I just have to figure out this IOException on the closed stream - probably has to do with [immidiate="true"].
    Thanks.
    [9/15/04 13:05:53:505 EDT] 6e436e43 SystemErr R java.io.IOException: Stream closed
    [9/15/04 13:05:53:536 EDT] 6e436e43 SystemErr R      at java.lang.Throwable.<init>(Throwable.java)
    [9/15/04 13:05:53:536 EDT] 6e436e43 SystemErr R      at java.lang.Throwable.<init>(Throwable.java)
    [9/15/04 13:05:53:536 EDT] 6e436e43 SystemErr R      at org.apache.jasper.runtime.JspWriterImpl.ensureOpen(JspWriterImpl.java:294)
    [9/15/04 13:05:53:536 EDT] 6e436e43 SystemErr R      at org.apache.jasper.runtime.JspWriterImpl.write(JspWriterImpl.java:424)
    [9/15/04 13:05:53:536 EDT] 6e436e43 SystemErr R      at org.apache.jasper.runtime.JspWriterImpl.write(JspWriterImpl.java:452)
    [9/15/04 13:05:53:536 EDT] 6e436e43 SystemErr R      at com.ibm.faces.component.UIJspPanel$ChildrenListEx.add(UIJspPanel.java:114)
    [9/15/04 13:05:53:536 EDT] 6e436e43 SystemErr R      at pagecode.admin.Test.handleListbox1ValueChange(Test.java)
    [9/15/04 13:05:53:536 EDT] 6e436e43 SystemErr R      at java.lang.reflect.AccessibleObject.invokeImpl(Native Method)
    [9/15/04 13:05:53:536 EDT] 6e436e43 SystemErr R      at java.lang.reflect.AccessibleObject.invokeV(AccessibleObject.java:199)
    [9/15/04 13:05:53:536 EDT] 6e436e43 SystemErr R      at java.lang.reflect.Method.invoke(Method.java:252)
    [9/15/04 13:05:53:536 EDT] 6e436e43 SystemErr R      at com.sun.faces.el.MethodBindingImpl.invoke(MethodBindingImpl.java:126)
    [9/15/04 13:05:53:536 EDT] 6e436e43 SystemErr R      at javax.faces.component.UIInput.broadcast(UIInput.java:492)
    [9/15/04 13:05:53:536 EDT] 6e436e43 SystemErr R      at javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:284)
    [9/15/04 13:05:53:536 EDT] 6e436e43 SystemErr R      at javax.faces.component.UIViewRoot.processDecodes(UIViewRoot.java:342)
    [9/15/04 13:05:53:536 EDT] 6e436e43 SystemErr R      at com.sun.faces.lifecycle.ApplyRequestValuesPhase.execute(ApplyRequestValuesPhase.java:79)
    [9/15/04 13:05:53:536 EDT] 6e436e43 SystemErr R      at com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:200)
    [9/15/04 13:05:53:536 EDT] 6e436e43 SystemErr R      at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:90)
    [9/15/04 13:05:53:536 EDT] 6e436e43 SystemErr R      at javax.faces.webapp.FacesServlet.service(FacesServlet.java:197)
    [9/15/04 13:05:53:536 EDT] 6e436e43 SystemErr R      at com.ibm.ws.webcontainer.servlet.StrictServletInstance.doService(StrictServletInstance.java:110)
    [9/15/04 13:05:53:536 EDT] 6e436e43 SystemErr R      at com.ibm.ws.webcontainer.servlet.StrictLifecycleServlet._service(StrictLifecycleServlet.java:174)
    [9/15/04 13:05:53:536 EDT] 6e436e43 SystemErr R      at com.ibm.ws.webcontainer.servlet.IdleServletState.service(StrictLifecycleServlet.java:313)
    [9/15/04 13:05:53:536 EDT] 6e436e43 SystemErr R      at com.ibm.ws.webcontainer.servlet.StrictLifecycleServlet.service(StrictLifecycleServlet.java:116)
    [9/15/04 13:05:53:536 EDT] 6e436e43 SystemErr R      at com.ibm.ws.webcontainer.servlet.ServletInstance.service(ServletInstance.java:283)
    [9/15/04 13:05:53:536 EDT] 6e436e43 SystemErr R      at com.ibm.ws.webcontainer.servlet.ValidServletReferenceState.dispatch(ValidServletReferenceState.java:42)
    [9/15/04 13:05:53:536 EDT] 6e436e43 SystemErr R      at com.ibm.ws.webcontainer.servlet.ServletInstanceReference.dispatch(ServletInstanceReference.java:40)
    [9/15/04 13:05:53:536 EDT] 6e436e43 SystemErr R      at com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.handleWebAppDispatch(WebAppRequestDispatcher.java:948)
    [9/15/04 13:05:53:536 EDT] 6e436e43 SystemErr R      at com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.dispatch(WebAppRequestDispatcher.java:530)
    [9/15/04 13:05:53:536 EDT] 6e436e43 SystemErr R      at com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.forward(WebAppRequestDispatcher.java:176)
    [9/15/04 13:05:53:536 EDT] 6e436e43 SystemErr R      at com.ibm.ws.webcontainer.srt.WebAppInvoker.doForward(WebAppInvoker.java:79)
    [9/15/04 13:05:53:552 EDT] 6e436e43 SystemErr R      at com.ibm.ws.webcontainer.srt.WebAppInvoker.handleInvocationHook(WebAppInvoker.java:201)
    [9/15/04 13:05:53:552 EDT] 6e436e43 SystemErr R      at com.ibm.ws.webcontainer.cache.invocation.CachedInvocation.handleInvocation(CachedInvocation.java:71)
    [9/15/04 13:05:53:552 EDT] 6e436e43 SystemErr R      at com.ibm.ws.webcontainer.srp.ServletRequestProcessor.dispatchByURI(ServletRequestProcessor.java:182)
    [9/15/04 13:05:53:567 EDT] 6e436e43 SystemErr R      at com.ibm.ws.webcontainer.oselistener.OSEListenerDispatcher.service(OSEListener.java:334)
    [9/15/04 13:05:53:567 EDT] 6e436e43 SystemErr R      at com.ibm.ws.webcontainer.http.HttpConnection.handleRequest(HttpConnection.java:56)
    [9/15/04 13:05:53:567 EDT] 6e436e43 SystemErr R      at com.ibm.ws.http.HttpConnection.readAndHandleRequest(HttpConnection.java:610)
    [9/15/04 13:05:53:567 EDT] 6e436e43 SystemErr R      at com.ibm.ws.http.HttpConnection.run(HttpConnection.java:435)
    [9/15/04 13:05:53:567 EDT] 6e436e43 SystemErr R      at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:593)
    [9/15/04 13:05:56:146 EDT] 6e436e43 SystemOut O Done

  • Best practice question for Availability Groups setup

    I have created a 2012 WFC with 2 nodes (server 1 and server2). Each node will host 2 instance of SQL Server 2014. I am planning to use 2 Availability Groups. 
    So
    Server1\instance A
    Server1\instance B
    Server2\instance A
    Server2\instance B
    Thus "instance A" will have AG_A
    instance B will have AG_B,
    What is the recommend configuration for configuring the Quorum witness?  A file share or disk witness?  Note that the WFC does not have any shared disks since I'm only using AG (not a clustered SQL server service).
    Thanks,
    Pete

    What is the version of operating system. If you are any OS version lower than Windows 2012 then you need to add one more voter for quorum.
    Balmukund Lakhani
    Please mark solved if I've answered your question, vote for it as helpful to help other users find a solution quicker
    This posting is provided "AS IS" with no warranties, and confers no rights.
    My Blog |
    Team Blog | @Twitter
    | Facebook
    Author: SQL Server 2012 AlwaysOn -
    Paperback, Kindle

  • SAP Best Practice Guide for QM data pull to BI

    Hello Gurus,
    I am looking for SAP Best Practice Guide for Quality Mangament data modelling required for BI. That will solve my problem, to go through all the documentation before concluding to finalize the SAP Delivered Business Content objects.
    Need your input.
    Thanks,
    Lasya.

    Need your inputs experts.
    Thanks,
    Lasya.

  • Best Practices Question: How to send error message to SSHR web page.

    Best Practices Question: How to send error message to SSHR web page from custom PL\SQL procedure called by SSHR workflow.
    For the Manager Self-Service application we’ve copied various workflows which were modified to meet business needs. Part of this exercise was creating custom PL\SQL Package Procedures that would gather details on the WF using them on custom notification sent by the WF.
    What I’m looking for is if/when the PL\SQL procedure errors, how does one send an failure message back and display it on the SS Page?
    Writing information into a log or table at the database level works for trouble-shooting, but we’re looking for something that will provide the end-user with an intelligent message that the workflow has failed.
    Thanks ahead of time for your responses.
    Rich

    We have implemented the same kind of requirement long back.
    We have defined our PL/SQL procedures with two OUT parameters
    1) Result Type (S:Success, E:Error)
    2) Result Message
    In the PL/SQL procedure we always use below construct when we want to raise any message
    hr_utility.set_message(APPL_NO, 'FND_MESSAGE_NAME');
    hr_utility.raise_error;
    In Exception block we write below( in successful case we just set the p_result_flag := 'S';)
    EXCEPTION
    WHEN APP_EXCEPTION.APPLICATION_EXCEPTION THEN
    p_result_flag := 'E';
    p_result_message := hr_utility.get_message;
    WHEN OTHERS THEN
    p_result_flag := 'E';
    p_result_message := hr_utility.get_message;
    fnd_message.set_name('PER','FFU10_GENERAL_ORACLE_ERROR');
    fnd_message.set_token('2',substr(sqlerrm,1,200));
    fnd_msg_pub.add;
    p_result_message := fnd_msg_pub.get_detail;
    After executing the PL/SQL in java
    We have written some thing similar to
    orclStmt.execute();
    OAExceptionUtils.checkErrors (txn);
    String resultFlag = orclStmt.getString(provide the resultflag bind no);
    if ("E".equalsIgnoreCase(resultFlag)){
    String resultMessage = orclStmt.getString(provide the resultMessage bind no);
    orclStmt.close();
    throw new OAException(resultMessage, OAException.ERROR);
    It safely shows the message to the user with all the data in the page.
    We have been using this construct for a long time for all our projects. They are all working as expected.
    Regards,
    Peddi.

  • Where does one find the Oracle Best Practice/recommendations for how to DR

    What is the Oracle Best Practice for install/deployment and configuration of ODI 11g for Disaster Recovery?
    We have a project that is using Oracle ODI 11g (11.1.1.5).
    We have configured all the other Oracle FMW components as per the Oracle DR EDG guides. Basically using the Host ip name/aliasing concept to ‘trick’ the secondary site into thinking
    it is primary and continue working with minimal (or no) manual reconfiguration. But will this work for ODI? The FMW DR guide has sections for SOA, WebCenter and IdM, but nothing for ODI.
    Since ODI stores so much configuration information in the Master Repository..when this DB gets ‘data guarded’ to the secondary site and promoted to Primary…ODI will still think it is at the ‘other’ site. Will this break the actual agents running the scenarios?
    Where does one find the Oracle Best Practice/recommendations for how to DR ODI properly?
    We are looking for a solution that will allow a graceful switchover/failover with minimal manual re-configuration.

    user8804554 wrote:
    Hi all,
    I m currently testing external components with Windows Server and I want to test Oracle 11g R2.
    The only resource I have is this website and the only binaries seem to be for Linux OS.You have one other HUGE resource that, while it won't answer your current question, you'd better start getting familiar with if you are going to use Oracle. That is the complete and official documentation, found at tahiti.oracle.com
    >
    Does anybody know how I can upgrade my Oracle 11.1.0.7 version to the R2 release?
    Thanks,
    Bertrand

  • Is it a best practice to Input Data directly to Parent Currency ?

    Dear Gurus,
    I understand this question is very simple, but I am wondering is it a best practice to Input data directly into <Parent Currency>?
    I am having a scenario where users do translation in Oracle and they wish to see the same number in HFM. As the process that they follow is unique in nature by Entity->Account [OR] for all Entities->Account, creating Override accounts is not helping us and rapidly increasing the Override hierarchy month-on-month.
    Thanks...
    Satya

    By overriding the accounts, I assume you are referring to accounts that are translated historically as opposed to the default translation performed by HFM?
    If so, I have seen two general approaches to achieve this:
         a) Allowing the user to directly override the translation at IsTransCurr (i.e. <parent currency> if parent is in a currency other then entity)
         b) Entering in a special currency rate in a rate account and then adjusting the translate routine to translate your account by that rate.
    I personally, am a bigger fan of the first option.

  • Oracle Asset (Functional) Practice Questions for Interviews and Exam

    https://www.createspace.com/3495382
    http://www.amazon.com/Functional-Questions-Interviews-Certification-Examination/dp/1456311581/ref=sr_1_4?ie=UTF8&s=books&qid=1289178586&sr=8-4
    List Price: $29.99
    Add to Cart
    Oracle Asset (Functional) Practice Questions for Interviews and Certification Examination (Release 11i and 12)
    Functional Consultant
    Authored by Erp Gold
    This book contains 150 Oracle Asset Practice Questions for functional consultants. Very useful for interviews and certification examinations.
    Publication Date:
    Oct 26 2010
    ISBN/EAN13:
    1456311581 / 9781456311582
    Page Count:
    94
    Binding Type:
    US Trade Paper
    Trim Size:
    6" x 9"
    Language:
    English
    Color:
    Black and White
    Related Categories:
    Computers / General

    Reported as spam!

  • Oracle Asset (Functional) Practice Questions for Interviews and Certificati

    https://www.createspace.com/3495382
    List Price: $29.99
    Add to Cart
    Oracle Asset (Functional) Practice Questions for Interviews and Certification Examination (Release 11i and 12)
    Functional Consultant
    Authored by Erp Gold
    This book contains 150 Oracle Asset Practice Questions for functional consultants. Very useful for interviews and certification examinations.
    Publication Date:
    Oct 26 2010
    ISBN/EAN13:
    1456311581 / 9781456311582
    Page Count:
    94
    Binding Type:
    US Trade Paper
    Trim Size:
    6" x 9"
    Language:
    English
    Color:
    Black and White
    Related Categories:
    Computers / General

    Reported as spam!

  • Best practice question -- copy container, assemble it, build execution plan

    So, this is a design / best practice question:
    I usually copy containers as instructed by docs
    I then set the source system parameters
    I then generate needed parameters / assemble the copied container for ALL subject areas present in the container
    I then build an execution plan JUST FOR THE 4 SUBJECT AREAS and build the execution plan and set whatever is needed before running it.
    QUESTION - When i copy the container, should i delete all not needed subject areas out of it or is it best to do this when building the execution plan? I am basically trying to simplify the container for my own sake and have the container just have few subject areas rather than wait till i build the execution plan and then focus on few subject areas.
    Your thoughts / clarifications are appreciated.
    Regards,

    Hi,
    I would suggest that you leave the subject areas and then just don't include them in the execution plan. Otherwise you have the possibility of running into the situation where you need to include another subject area in the future and you will have to go through the hassle of recreating it in your SSC.
    Regards,
    Matt

  • Is there any Best Practice Document for OEDQ development?Please share.

    Is there any Best Practice Document for OEDQ development?Please share.

    Hello, Please check the below projects, you would get better idea on the best practices like Naming Standards, which processors to use, how to bundle the jobs, external tasks etc.,
    edq-cds-data-quality-health-check-9.0.4.(645).dxi
    edq-cds-initialize-reference-data-9.0.4.(645).dxi
    Regards,
    Bala Govi

  • Any best practice recommendations for controlling access to dashboards?

    Everyone,
         I understand that an Xcelsius dashboard compiled into a .swf file contains no means for providing access control to limit who can or how many times they can run the dashboard. Basically, if they have a copy of the .swf they can use it as much as they'd like. To protect access to sensitive data I'd like to be able to control who can access the dashboard and how many times or how long they can access it for.
         From what I've read it seems the simplest way to do this is to embed the swf file into a web portal that requires a user to authenticate before accessing the file. I suppose I can then handle how long they can access it from the back end.
         If I do this, is there anyway a user can do something like <right click - save as> on the flash file to save it on their local machine? Is there a best practice means for properly protecting the dashboard?
    Any advice would be appreciated,
    Jerry Winner

    Everyone,
         I understand that an Xcelsius dashboard compiled into a .swf file contains no means for providing access control to limit who can or how many times they can run the dashboard. Basically, if they have a copy of the .swf they can use it as much as they'd like. To protect access to sensitive data I'd like to be able to control who can access the dashboard and how many times or how long they can access it for.
         From what I've read it seems the simplest way to do this is to embed the swf file into a web portal that requires a user to authenticate before accessing the file. I suppose I can then handle how long they can access it from the back end.
         If I do this, is there anyway a user can do something like <right click - save as> on the flash file to save it on their local machine? Is there a best practice means for properly protecting the dashboard?
    Any advice would be appreciated,
    Jerry Winner

Maybe you are looking for