How Can I Change the  Where Condition In the First SQL Query?

SELECT IND_SSN, BEG_SVC_DT, END_SVC_DT,
TRUNC(MONTHS_BETWEEN((TO_DATE('19'||END_SVC_DT,'YYYYMMDD')),BEG_SVC_DT)/12),
mod(trunc(months_between((to_date('19'||end_svc_dt,'YYYYMMDD')),BEG_SVC_DT)),12),
DECODE((SUBSTR(END_SVC_DT,5,2) - SUBSTR(BEG_SVC_DT,1,2)+1),-1,((SUBSTR(END_SVC_DT,5,2)+ 31) - SUBSTR(BEG_SVC_DT,1,2)),
-2,((SUBSTR(END_SVC_DT,5,2)+ 31) - SUBSTR(BEG_SVC_DT,1,2)),
-3,((SUBSTR(END_SVC_DT,5,2)+ 31) - SUBSTR(BEG_SVC_DT,1,2)),
-4,((SUBSTR(END_SVC_DT,5,2)+ 31) - SUBSTR(BEG_SVC_DT,1,2)),
-5,((SUBSTR(END_SVC_DT,5,2)+ 31) - SUBSTR(BEG_SVC_DT,1,2)),
-6,((SUBSTR(END_SVC_DT,5,2)+ 31) - SUBSTR(BEG_SVC_DT,1,2)),
-7,((SUBSTR(END_SVC_DT,5,2)+ 31) - SUBSTR(BEG_SVC_DT,1,2)),
-8,((SUBSTR(END_SVC_DT,5,2)+ 31) - SUBSTR(BEG_SVC_DT,1,2)),
-9,((SUBSTR(END_SVC_DT,5,2)+ 31) - SUBSTR(BEG_SVC_DT,1,2)),
-10,((SUBSTR(END_SVC_DT,5,2)+ 31) - SUBSTR(BEG_SVC_DT,1,2)),
-11,((SUBSTR(END_SVC_DT,5,2)+ 31) - SUBSTR(BEG_SVC_DT,1,2)),
-12,((SUBSTR(END_SVC_DT,5,2)+ 31) - SUBSTR(BEG_SVC_DT,1,2)),
-13,((SUBSTR(END_SVC_DT,5,2)+ 31) - SUBSTR(BEG_SVC_DT,1,2)),
-14,((SUBSTR(END_SVC_DT,5,2)+ 31) - SUBSTR(BEG_SVC_DT,1,2)),
-15,((SUBSTR(END_SVC_DT,5,2)+ 31) - SUBSTR(BEG_SVC_DT,1,2)),
-16,((SUBSTR(END_SVC_DT,5,2)+ 31) - SUBSTR(BEG_SVC_DT,1,2)),
-17,((SUBSTR(END_SVC_DT,5,2)+ 31) - SUBSTR(BEG_SVC_DT,1,2)),
-18,((SUBSTR(END_SVC_DT,5,2)+ 31) - SUBSTR(BEG_SVC_DT,1,2)),
-19,((SUBSTR(END_SVC_DT,5,2)+ 31) - SUBSTR(BEG_SVC_DT,1,2)),
-20,((SUBSTR(END_SVC_DT,5,2)+ 31) - SUBSTR(BEG_SVC_DT,1,2)),
-21,((SUBSTR(END_SVC_DT,5,2)+ 31) - SUBSTR(BEG_SVC_DT,1,2)),
-22,((SUBSTR(END_SVC_DT,5,2)+ 31) - SUBSTR(BEG_SVC_DT,1,2)),
-23,((SUBSTR(END_SVC_DT,5,2)+ 31) - SUBSTR(BEG_SVC_DT,1,2)),
-24,((SUBSTR(END_SVC_DT,5,2)+ 31) - SUBSTR(BEG_SVC_DT,1,2)),
-25,((SUBSTR(END_SVC_DT,5,2)+ 31) - SUBSTR(BEG_SVC_DT,1,2)),
-26,((SUBSTR(END_SVC_DT,5,2)+ 31) - SUBSTR(BEG_SVC_DT,1,2)),
-27,((SUBSTR(END_SVC_DT,5,2)+ 31) - SUBSTR(BEG_SVC_DT,1,2)),
-28,((SUBSTR(END_SVC_DT,5,2)+ 31) - SUBSTR(BEG_SVC_DT,1,2)),
-29,((SUBSTR(END_SVC_DT,5,2)+ 31) - SUBSTR(BEG_SVC_DT,1,2)),
-30,((SUBSTR(END_SVC_DT,5,2)+ 31) - SUBSTR(BEG_SVC_DT,1,2)),
-31,((SUBSTR(END_SVC_DT,5,2)+ 31) - SUBSTR(BEG_SVC_DT,1,2)),
30,0,
(SUBSTR(END_SVC_DT,5,2) - SUBSTR(BEG_SVC_DT,1,2)+1))
FROM SVC_OCCURRENCES
WHERE end_svc_dt not in ('PRESENT')
AND SUBSTR(END_SVC_DT,1,1) IN '9'
AND SUBSTR(END_SVC_DT,5,2) NOT IN ('31')
and (SUBSTR(END_SVC_DT,5,2) - SUBSTR(BEG_SVC_DT,1,2)+1) not in ('30')
UNION
SELECT IND_SSN, BEG_SVC_DT, END_SVC_DT, NULL, NULL, NULL
FROM SVC_OCCURRENCES
WHERE SUBSTR(END_SVC_DT,1,1) IN 'P'
The above code works fine and I get the correct numeric values from the SQL
query when the varchar2 end_svc_dt field is numeric however if I have encoded
the word 'PRESENT' in the varchar2 end_svc dt field the SQL query aborts at
the last statement in the WHERE condition. The beg_svc_dt field is a Date field.
and (SUBSTR(END_SVC_DT,5,2) - SUBSTR(BEG_SVC_DT,1,2)+1) not in ('30')
I get the following error message
ERROR ORA-0722 INVALID NUMBER
I encode the word 'PRESENT' in a varchar2 end_svc_dt field on an Oracle form. This is the only word that can be encoded.
Is there some way that I can bypass the last statement in the where condition and
compute the values from the SQL query without having the SQL query abort?
Eventually I want to do this in a report. I know that this sounds strange but can it be done?

The above code works fine and I get the correct
numeric values from the SQL
query when the varchar2 end_svc_dt field is numeric
however if I have encoded
the word 'PRESENT' in the varchar2 end_svc dt field
the SQL query aborts at
the last statement in the WHERE condition.Ouch!
Storting dates in VARCHAR2 columns is bad practice, poor design and makes for horrible code.
The beg_svc_dt field is a Date field.
and (SUBSTR(END_SVC_DT,5,2) -
SUBSTR(BEG_SVC_DT,1,2)+1) not in ('30')If it's a date field then why on earth are you trying to SUBSTR it. SUBSTR = sub-string i.e. take a sub section of a string not sub-date.
I get the following error message
ERROR ORA-0722 INVALID NUMBERAnd you're surprised by this?
Is there some way that I can bypass the last
statement in the where condition and
compute the values from the SQL query without having
the SQL query abort?Store your dates properly, use additional flag columns for non-date information and code your SQL properly.
Eventually I want to do this in a report. I know
that this sounds strange but can it be done?Yes, most things are possible.

Similar Messages

  • How can i change the default text "Query by Example"

    Studio Edition Version 11.1.1.3.0
    how can i change the default text *"Query by Example"* in a Panel Collection
    Thx

    Hi thieto,
    The label you are looking for is af_panelCollection.LABEL_MENUITEM_QBE*
    I'm currently writing a blogpost on this issue. In short, you will have to create a skin resource bundle.
    In the skin definition, refer to this bundle class.
    <?xml version="1.0" encoding="ISO-8859-1"?>
    <skins xmlns="http://myfaces.apache.org/trinidad/skin">
      <skin>
        <id>mySkin.desktop</id>
        <family>MySkin</family>
        <extends>blafplus-rich.desktop</extends>
        <render-kit-id>org.apache.myfaces.trinidad.desktop</render-kit-id>
        <style-sheet-name>skins/MySkin.css</style-sheet-name>
        <bundle-name>com.blogspot.lucbors.view.bundles.MySkinBundle </bundle-name>
      </skin>
    </skins>In this class, adjust the label text to your needs.
    package com.blogspot.lucbors.view.bundles;
    import java.util.ListResourceBundle;
    public class MySkinBundle extends ListResourceBundle {
      public MySkinBundle() {
        super();
    @Override
      public Object[][] getContents() {
        return _CONTENTS;
    static private final Object[][] _CONTENTS = {
         {"af_panelCollection.LABEL_MENUITEM_QBE","the text that you want"}
    }More in the blogpost
    Good luck
    Luc Bors
    Edited by: lucbors on Jul 26, 2010 11:39 AM (blogpost finished - URL added)

  • HT2486 How can I change the first contact that appears when I open address book?

    Every time I open Address book, it opens on the same person. Someone I don't really want as the first contact I see every day!...
    Is there a setting to change this? or a way to set a "Key Contact"?
    Thanks

    Use the Settings app
    Settings > iTunes and App Store > tap on the incorrect Apple ID that appears > Sign Out > then sign in with your correct Apple ID.
    Keep in mind that all apps downloaded or purchased are always associated with the Apple ID used to purchase or download them. As those apps have updates you will need to enter the Apple ID and password that was used for them. If you want to avoid this delete all of the apps purchased or downloaded with a previous Apple ID and download them again with the current Apple ID. You will have purchase any apps that are not free.

  • How can I change the first number within the counter of a lightbox?

    Muse remembers the order the images are submitted to. So when I move the images around, into another order, the counter is mixed up.
    For example; I have 9 images, when I want photo 8 on place 1, the counter still says 8 - 9 instead of 1 - 9.

    Hi
    Have you tried changing the position of targets , if you change the position of Target then the counter will show that image with proper order number changed.
    Thanks,
    Sanjit

  • How can i track the all sql/query executed from application

    How we can track all sql/query that has executed or being executing on oracle database server 10g r2.
    regards
    Prabhaker

    select s.sid,
           s.status,
           s.process,
           s.osuser,
           a.sql_text,
           p.program
    from v$session s,
         v$sqlarea a,
         v$process p
    where s.sql_hash_value = a.hash_value
      and s.sql_address    = a.address
      and s.paddr          = p.addr
      and s.schemaname     = '&1'
      and s.status         = 'ACTIVE'

  • How can I change the name to my I-Pod Shuffle?

    Hi, this is Gloria writing.
    I have a little problem. I have just received a new Ipod shuffle and when I connected it to my PC, I made an error giving to my IPOD a wrong name.
    Could anybody help me? Could somebody explain me how can I change the first name?
    I know this is a stupid problem, but I would like to give a nice name...
    Please give me some suggestions!
    Thanks in advance!
    Gloria

    Select the iPod in the iTunes source list, click on its name, and type a new name.
    (22017)

  • How can i change the color of the graph in agreement of the program's condition

    Hi,
    I am using labview 5.1 in my graduation's project final. (sorry by my english, but i am ina hurry)
    How can i change the color of the graph in agreement of the program's condition?
    I am developing a VI to control the temperature of termistors,but i have another sensor too.
    In a graph i have the situation of the termistors,but i want to change the color of the graph when the sensor is active.
    Thanks a lot
    Rafael Wajnsztajn - Brasil

    To change the color of the line itself, you can use the attribute Plot>>Plot Color.
    To change the color of the points, you can use the attribute Cursor>>Cursor Color.
    To select the color, you should have a color box constant inside the Numeric>>Additional Numeric Constants palette.
    This is all in LV 7.0. I'm not sure how it similar it is in 5.1.
    One important thing is to place the attribute node inside a case structure which will execute only when your condition has been filled.
    If this didn't help you, I suggest you post the relevant piece of code, or at least an image of it (no BMPs, please).
    Try to take over the world!

  • How can i change the automatic ID that apppears in my iPhone where in fact itis not my apple ID in the first place?

    how can i change the automatic ID that apppears in my iPhone where in fact it is not my apple ID in the first place?

    The automatic ID DaintyDaisy is talking about is when you go to your app store and it shows you as logged in under a certain Apple ID, and asks you for the password to log in.  If this is not the correct Apple ID, then we (including me!!!) need to know where to go to re set it.  I followed some other discussions and one link http://support.apple.com/kb/HT5796  shows you how to sign out, but when the Apple ID is greyed out, it doesn't help!!! Typical Apple world... get tangled and suffer for endless hours trying to fix one problem... but there is a million more to fix (like getting the righ App to download pictures from one's iPhone).

  • I have used the resume tablet and put my resume into format but when emailing it, it will not open on windows. How can I change the format to where they will be able to open and view it?

    I have used the resume tablet and put my resume into format but when emailing it, it will not open on windows. How can I change the format to where they will be able to open and view it?

    I guess you mean one of the resume templates.
    What "format" have you saved your finished resume in?
    The only formats a Windows user will be able to open are .doc (Word), .pdf and rtf. The 1st 2 are usually the best.
    There is no Windows version of Pages.
    Peter

  • How can i  change the column label text in a alv table display

    how can i change the column label text in a alv table display??
    A similar kinda of question was posted previuosly where the requirement was the label text was needed and following below code was given as solution :
    <i>*  declare column, settings, header object
    DATA: lr_column TYPE REF TO cl_salv_wd_column.
    DATA: lr_column_settings TYPE REF TO if_salv_wd_column_settings.
    DATA: lr_column_header type ref to CL_SALV_WD_COLUMN_HEADER.
    get column by specifying column name.
    lr_column = lr_column_settings->get_column( 'COLUMN_NAME1' ).
    set Header Text as null
    lr_column_header = lr_column->get_header( ).
    lr_column_header->set_text( ' ' ).</i>
    My specific requirement is i have an input field on the screen and i want reflect that value as the column label for one of the column in the alv table. I have used he above code with slight modification in the MODIFYVIEW method of the view since it is a process after input. The component gets activated without any errors but while run time i get an error stating
    <i>"The following error text was processed in the system CDV : Access via 'NULL' object reference not possible."</i>
    i have checked in debugging and the error occured at the statement :
    <i>lr_column = lr_column_settings->get_column( 'CURRENT_YEAR' ).</i>Please can you provide me an alternative for my requirement or correct me if i have done it wrong.
    Thanks,
    Suri

    I found it myself how to do it. The error says that it is not able to find the reference object i.e  it is asking us to refer to the table. The following piece of code will solve this problem. Have to implement this in WDDOMODIFYVIEW method of the view. This thing works comrades enjoy...
      DATA : lr_cmp_usage TYPE REF TO if_wd_component_usage,
             lr_if_controller  TYPE REF TO iwci_salv_wd_table,
             lr_cmdl   TYPE REF TO cl_salv_wd_config_table,
             lr_col    TYPE REF TO cl_salv_wd_column.
      DATA : node_year  TYPE REF TO if_wd_context_node,
             elem_year  TYPE REF TO if_wd_context_element,
             stru_year  TYPE if_alv_layout=>element_importing,
             item_year  LIKE stru_year-i_current_year,
             lf_string    TYPE char(x),
      DATA: lr_column TYPE REF TO cl_salv_wd_column.
      DATA: lr_column_header TYPE REF TO cl_salv_wd_column_header.
      DATA: lr_column_settings TYPE REF TO if_salv_wd_column_settings.
    Get the entered value from the input field of the screen
    node_year  = wd_context->get_child_node( name = 'IMPORTING_NODE' ).
    elem_year  = node_year->get_element( ).
      elem_year->get_attribute(
       EXPORTING
        name = 'IMPORT_NODE-PARAMETER'
       IMPORTING
        value = L_IMPORT_PARAM ).
      WRITE L_IMPORT_PARAM TO lf_string.
    Get the reference of the table
      lr_cmp_usage  =  wd_this->wd_cpuse_alv( ).
      IF lr_cmp_usage->has_active_component( ) IS INITIAL.
        lr_cmp_usage->create_component( ).
      ENDIF.
      lr_if_controller  = wd_this->wd_cpifc_alv( ).
      lr_column_settings = lr_if_controller->get_model( ).
    get column by specifying column name.
      IF lr_column_settings IS BOUND.
        lr_column = lr_column_settings->get_column( 'COLUMN_NAME').
    set Header Text as null
        lr_column_header = lr_column->get_header( ).
        lr_column_header->set_text( lf_string ).
    endif.

  • Hi,how can i change the default settings on my adobe readerX1 such that it will display all my pdf files according to their individual cover pages (as cover picture thumbnails)before i click them to open and read........i really enjoyed this feature as a

    hi,how can i change the default settings on my adobe readerX1 such that it will display all my pdf files according to their individual cover pages (as cover picture thumbnails)before i click them to open and read........i really enjoyed this feature as a default settings upon installation in previous editions of adobe reader .i use a windows 8 pc now.thank

    For sideloaded content the nook pulls the metadata from ePub file itself.  I would suggest looking at a program like Sigil or Calibre that will let you edit the metadata in the book to make it appear like you want.
    For the PDF vs ePub - No, that's the way PDFs work (think of them as graphics, not text), wheres ePubs are Web Pages - so  no you can't them to behave exactly alike without converting the files.

  • How can I change the default  driver to OracleXADataSource in JDeveloper

    Hello,
    How can I change the default oracle driver: oracle.jdbc.OracleDriver to oracle.jdbc.xa.client.OracleXADataSource in JDeveloper Studio Edition Version 11.1.1.0.2, Build JDEVADF_MAIN.BOXER_GENERIC_090328.0229.5205.
    If I modify the file connections.xml from jdeveloper\system\system11.1.1.0.31.52.05\o.jdevimpl.rescat2\connections in the sense that I change the driver class, then in JDeveloper when I test my connection I have this problem: Test failed: oracle.jdbc.xa.client.OracleXADataSource cannot be cast to java.sql.Driver
    Why do I need this XA version of the oracle driver? Well I tried, from a book to reproduce the model of an application: entities, stateless and stateful session beans, mdb, web services and a client to test one part of the model.
    And because of the JMS server I need an XA driver.
    I deployed to the integrated wls 10.3 and when I test my client, if I use the default driver for the connection the an error message appears tell me either to emulate two-phase commit or to use XA driver.
    My application works very well, if I configured in the console of the integrated wls 10.3 a datasource with the same name as my ide/application connection that has for the Driver Class Name: oracle.jdbc.xa.client.OracleXADataSource in the Connection Pool tab.
    Thank you.

    Open DIsk Utility and in the toolbar select Disk Image. The file selector will open and you'll have to do three things: 1) just as with any file, name it and point the file selector to where you want it to be saved, 2) near the bottom you'll see name - type iWork 2013 and 3) below that select the image size. Click on size, choose custom and type 1500 MB then click on the Create button.
    Some time will pass and then you'll see an external disk pop up on your desktop and/or the Finder window sidebar. Drag the three programs into it and eject it like any other external disk. Now delete the programs from your applications window.
    Where ever it was you pointed the file selector to you'll see the file you created. Double click on it and the disk image will mount again.

  • Mail -- How can I change the default email account from which my messages go, without having to change it each time I draft a message?  It currently assumes an email account that I rarely use. Thanks.

    How can I change the default email account from which my messages go, without having to change it each time I draft a message?  It currently assumes an email account that I rarely use. Thanks.

    sorry, but I can't find the mail preference in the latest Yosemite OS. Do you know where I can find it?
    Thank you
    Don

  • How can I change the page size of a pdf so i can view it on my iphone more clearly?

    How can I change the page size of a pdf so i can view it on my iphone more clearly?

    I think there may be more to this question than you say.
    If your PDF page is say, 8 x 12 inches, and you found a way to scale it to 25%, changing it to 2 x 3 inch, shrinking everything on the page to quarter size - wouldn't it look exactly the same on the iPhone? It's just going to be the same as zooming.
    Or were you hoping for something more like in Word, where changing the page size keeps everything the same size and spreads it over more pages? That isn't something you can do.

  • How can I change the color of all folders from light blue to another color?

    My computer was just upgraded from Tiger to Leopard, and now all the file folder icons are pale blue on the desktop and elsewhere. My desktop is green and those light blue folders do not look good on a green background.
    How can I change the color of the folder icons to another color?

    Hi ys,
    You appear to have taken a wrong turn on the information highway and would up in the backwater known as the AppleWorks forum. This is a place for discussion of issues and techniques connected with the now discontinued Apple productivity application AppleWorks.
    Yours is a System question, concerned with how to accomplish something in the Finder, part of the Mac OS X software you recently upgraded. The question will be better served in the Mac OS X v10.5 Leopard section of discussions. The link will take you to that section, where I'd suggest using the Finder and Dock forum.
    Regards,
    Barry

  • How can I change the date format in Reminders and in Notes?

    How can I change the date format in both Notes and Reminders? Preference on Imac and Settings in IOS do not allow me to change the format in those 2 apps.
    I Like to see 10oct rather than 10/10, as an example.

    pierre
    I do not have Mavericks or iOS - but the first thing I would do is reset the defaults - I'll use Mavericks as an example
    From If the wrong date or time is displayed in some apps on your Mac - Apple Support
    OS X Yosemite and Mavericks
        Open System Preferences.
        From the View menu, choose Language & Region.
        Click the Advanced button.
        Click the Dates tab.
        Click the Restore Defaults button.
        Click the Times tab.
        Click the Restore Defaults button.
        Click OK.
        Quit the app where you were seeing incorrect dates or times displayed.
        Open the app again, and verify that the dates and times are now displayed correctly.
    Then customize to taste - OS X Mavericks: Customize formats to display dates, times, and more
    OS X Mavericks: Customize formats to display dates, times, and more
    Change the language and formats used to display dates, times, numbers, and currencies in Finder windows, Mail, and other apps. For example, if the region for your Mac is set to United States, but the format language is set to French, then dates in Finder windows and email messages appear in French.
        Choose Apple menu > System Preferences, then click Language & Region.
        Choose a geographic region from the Region pop-up menu, to use the region’s date, time, number, and currency formats.
        To customize the formats or change the language used to display them, click Advanced, then set options.
        In the General pane, you can choose the language to use for showing dates, times, and numbers, and set formats for numbers, currency, and measurements.
        In the Dates and Times panes, you can type in the Short, Medium, Long, and Full fields, and rearrange or delete elements. You can also drag new elements, such as Quarter or Milliseconds, into the fields.
        When you’re done customizing formats, click OK.
        The region name in Language & Region preferences now includes “Custom” to indicate you customized formats.
    To undo all of your changes for a region, choose the region again from the Region pop-up menu. To undo your changes only to advanced options, click Advanced, click the pane where you want to undo your changes, then click Restore Defaults.
    To change how time is shown in the menu bar, select the “Time format” checkbox in Language & Region preferences, or select the option in Date & Time preferences.
    Here's the result AppleScript i use to grab the " 'Short Date' ' + ' 'Short Time' "  to paste into download filenames - works good until I try to post it here - the colon " : " is a no-no but is fine in the Finder
    Looks like iOS Settings are a bit less robust
    - Date/Time formats are displayed according to 'tradition' of your region > http://help.apple.com/ipad/8/#/iPad245ed123
    buenos tardes
    ÇÇÇ

Maybe you are looking for

  • IPhone OS 3.1 changed my ipod albums!!

    I listen to music on the ipod on my iphone by albums and when I updated to OS 3.1 it screwed everything up. If an album has features or different artists my albums list now shows that song as another album(same name) and not part of a whole album. Ex

  • MIME Upload: Operation is not allowed (M_APP_P) take #2

    Hello folks, with respect to the following thread: Operation is not allowed (M_APP_P) System Info: NW AS 7.03 ABAP Stack 731 Level 9, ECC 606 (EHP 6) with SAP_HR 604 Level 73 and EA_HR 607 (HR-Renewal 1) Level 24 Background: One of our external colle

  • Invitee in Calendar is not working~

    Hi, I would like to seek assistance in resolving a problem that I'm encountering. My iPhone 4 is currently running on iOS 5.1.1 and email is not sent out to invitees even when the entry is successful.  Using Gmail as default email.  iCloud for calend

  • Change TM drive ---deleteing TM files

    I've got TM up and running smoothly, with several backups on my external drive. 1) Can I now copy my TM data to another (larger) drive (via a simple drag and drop in Finder), then change my destination drive in TM and have it continue to update that

  • Bid Invitation Approval Workflow

    Hi All, We are having issues implementing SRM standard bid invitation workflow approval becos of the absence of a web transaction acknowledged by SAP. Our implementation requires this functionality, could anyone assist us with a work around, or an al