Decoding the date to sysdate and return the result as possible

Hello

I would like to create an expression that compares a date with the sysdate field and then he categorizes with decoding, this is what I tried so far but it through a mistake of the closing parenthesis.
SQL*Plus: Release 10.2.0.1.0 - Production on Mon Aug 31 16:51:21 2009

Copyright (c) 1982, 2005, Oracle.  All rights reserved.

SQL> SELECT DECODE((date_expired < sysdate), date_expired, 'CURRENT')
  2    FROM tablename
  3  /
SELECT DECODE((date_expired < sysdate), date_expired, 'CURRENT')
                            *
ERROR at line 1:
ORA-00907: missing right parenthesis

SQL>
The error corresponds to the 28 column that lies between date_expired and <.

Thank you
Ben

Hi Ben,

Decode is a function SQL and SQL ignores Boolean values. If the Analyzer does not provide the< sign="" and="" expects="" a="" right="" parenthesis="" at="" that="">

You can use something like:

case
  when date_expired < sysdate then ...
  when date_expired = sysdate then ...
  else ...
end

Kind regards
Rob.

Tags: Database

Similar Questions

  • How to generate date thru sysdate and day of the week

    Hello world!

    Please give me a hand with this:

    I need calculate a date thru sysdate and day of the week.

    For example:

    SYSDATE: 22/08/2013

    DAY: TUESDAY

    Result: 27/08/2013 (the date for Tuesday next from today ' hui).

    Another example:

    SYSDATE: 22/08/2013

    DAY: FRIDAY

    Result: 23/08/2013 (the date for Friday next today).

    My version of oracle's 8i (I work with a legacy database).

    Thanks in advance! ... and sorry for my English

    Search the NEXT_DAY function it does exactly what you want

  • using PIN messages to send the query and return data

    I am working on an app that will send a request to another blackberry and return the data all via PIN messages. There is a user interface where the user selects the contact and start the PIN message with the request. There is a background application that listens to these requests. When we arrive, he must inform the user and allow them to send the requested data or reject the request. If they choose to send, it will undertake a PIN to the sender with the requested data, which will then be returned to the screen. Is it possible by using PIN messages, and if so, can I prevent their display in the list of messages?

    You * can * remove PIN of the Inbox messages. For all purposes useful, this is just a specific instance of an ELECTRONIC message.

  • Procedure to take income data set and return the result set

    Hi all

    I have a situation where there will be a 'standard' set of data (source_data below), and I need to get information on outcomes for certain groups of customers (client_data for example). As SQL right it would be very easy (see below) - real world problem is a bit more complicated. However, what I would do is set up a procedure so that I can pass on my data of client variables and it will spit back on a set of data that is identical to the output of the given SQL.

    A pointer in the right direction would be appreciated. If I could 'pass customer data' as a string that contains an SQL query, which would be even better, for example

    GetResults ("select client_id, min (whatever_date) from some_client_data which...", MyOutputRefCursor?)
    create table source_data
    (client_id integer,
    tdate date,
    amount number(6,2));
    
    create table client_data
    (client_id integer,
    critical_date date);
    
    insert into source_data values(1,to_date('20090104','yyyymmdd'),1000);
    insert into source_data values(1,to_date('20100104','yyyymmdd'),2000);
    insert into source_data values(1,to_date('20110104','yyyymmdd'),3000);
    insert into source_data values(1,to_date('20120104','yyyymmdd'),4000);
    insert into source_data values(2,to_date('20090104','yyyymmdd'),5000);
    insert into source_data values(2,to_date('20090604','yyyymmdd'),1000);
    insert into source_data values(2,to_date('20100104','yyyymmdd'),2000);
    insert into source_data values(3,to_date('20091004','yyyymmdd'),3000);
    insert into source_data values(3,to_date('20091104','yyyymmdd'),4000);
    insert into source_data values(4,to_date('20090104','yyyymmdd'),5000);
    insert into source_data values(4,to_date('20090604','yyyymmdd'),2000);
    
    insert into client_data values(1,to_date('20110104','yyyymmdd'));
    insert into client_data values(2,to_date('20090604','yyyymmdd'));
    
    
    select c.client_id,
      sum(CASE WHEN tdate < critical_date then amount else null end) used_before,
      sum(CASE WHEN tdate >= critical_date then amount else null end) used_after
    from source_data s
    inner join client_data c on s.client_id = c.client_id
    GROUP BY c.client_id;
    Thank you

    Jon

    Hello

    You can do this with a view. Make settings of the view a global temporary table:

    create GLOBAL TEMPORARY table client_data
    (       client_id       integer
    ,     critical_date      date
    )
    ON COMMIT PRESERVE ROWS
    ;
    

    Then, you can create a view based on your real of the table and the parameter array:

    CREATE OR REPLACE VIEW     special_clients
    AS
    select c.client_id,
      sum(CASE WHEN tdate < critical_date then amount else null end) used_before,
      sum(CASE WHEN tdate >= critical_date then amount else null end) used_after
    from source_data s
    inner join client_data c on s.client_id = c.client_id
    GROUP BY c.client_id;
    

    Because the table of parameters is a global temporary table, each session will have its own private copy of the table of parameters and therefore his own private version of the view.

  • default value of the parameter date problematic SYSDATE

    Hello

    I finally discovered why a report of problems, but have no solution to the problem.

    After the first run of the report and MORE (DESKTOP is no problem), I can open is no longer the LOV for any of the settings. The LOV icon is available, but nothing happens when you click it.

    Now, I know the problem is a specific condition based on a date parameter.

    The State is testing a date field against a setting that is based on NONE and has a default value of today. If I use effective dates in the setting I have no problem. If I use today or SYSDATE, then I can only run the report once. After that I can't choose any LOV in any of the settings. If I change the today or SYSDATE to a real, date is well again.

    The State of origin that was used was based on a calculated field due2 defined as: DECODE (:due,'TODAY',SYSDATE,TO_DATE(:due,'DD/MM/YY'))

    I tried to change the condition of:

    date field < = TO_DATE(:due,'dd/mm/yyyy')

    but also causing problems if I used SYSDATE or today in the parameter.

    I then tried to change the calculated field to due2:
    Decode (:due,'TODAY',to_date(sysdate,'dd/mm/yyyy'),to_date(:due,'DD/mm/YY'))
    but it does not work.

    Any suggestions?

    Thank you.
    Leah

    Hi Lea,.
    Try using 'CASES' instead of 'Decode' in your state:

    -case when: due = trunc (sysdate) then 'Today'
    of other end TO_DATE(:due,'DD/MM/YY')

    Maybe it will solve your problem.

    Note that this is problematic, because if the user enters an invalid date you will probably get an error.

    I could do this a bit different...
    1. create an optional parameter based on the date (so that I'll have the calendar)
    2 create a condition where the parameter is empty, it will use SYSDATE.
    for example:
    =: due
    OR (: due is null AND = trunc (sysdate))

    Tamir

  • How to make the difference between data (different sensors and actuators) is tans/recvd using series com

    Hello

    I get 2 different types of data from the controller. How to differentiate b/w them.

    After receiving my code in deccissions. There are 6 different control elements in my project attached to the controller. Thanks for give me idea how I send data to the controller for this controller to differentiate that exit to be active or low

    First, look at the couple of serial examples that come with LabVIEW. You use the VISA functions to read and write. Your technique to separate the values will work as well in LabVIEW. You would be to convert the string returned by VISA reading to a digital (i.e. with the Scan of the chain). Then do the comparison, then the result of wire to one of the two indicators. Put the terminal of each indicator inside a case statement would be a way to do it.

  • How to execute a Perl script and returns the value as a string?

    Hi, I am trying to build an application using the eclipse 2.0.0 with the Blackberry SDK 7.1 plug-in. currently I tested Simulator 9900 version 7.1.0.523. I need to use the Perl language to access the raw biological database and returns as a string without having to write a longer program using java.

    In a stand alone Java SDK, I can use the line:

    Process p = Runtime.getRuntime () .exec ("perl script.pl")

    but when I tried to use it on the IDE for a Blackberry project, the project will not compile. It is said:

    Method exec (String) is undefined for the type of Runtime

    Hopes, can someone show me the correct syntex to use, but if no class is available, could someone show me a sample for unified research process? The names of blackberry dev is very complicated, I can't find any samples for her.

    Thank you.

    Seems interesting.

    Your idea was to download the data to the BlackBerry and then directly execute queries.

    Although there are a number of other obstacles, the first fall you in East platforms supporting Perl.  Here is the list:

    http://perldoc.Perl.org/perlport.html#supported-platforms

    BlackBerry OS Java is not included - in fact the only ' included phone OS is Symbian.  Interestingly, it seems likely that PlayBook and BB10, because they are based on the QNX operating system.

    If we discard Perl as a query language, then you will need to provide another option to search.  I think that unified search is an option, but you will have some work to do to use it.  The first thing you should do is find out if in fact, you can download the database on the BlackBerry.  The only available on the Blackberry database engine's SQL, so if you want the database can be exported to a SQL database, there is a chance that it would work.  I had a quick glance around the site, and I can't tell what the "database" is in the format.  Then I suggest that look you at that next.

    I hope this helps.

  • How can blackBerry smartphones, I get rid of the enterprise of the screen activation and return to a screen of configuration of e-mail.

    Hi, I just got a used 9800. When I went to set up my emails, the enterprise activation screen was presented. I don't know how to get rid of it and return to the e-mail address set up the screen.

    Thank you

    When you go to the configuration screen, you are ONLY with the enterprise activation icon or link?

    No personal email configuration?

    Do you have a data Plan BlackBerry enabled on your account with your carrier or mobile provider?  You have to, to get the push RIM email functions you are looking for, as well as services of BlackBerry data such as the Web browser, Facebook for BlackBerry, BlackBerry Messenger and much more.

    Then call your carrier and you learn about to have added to your account BlackBerry data Plan. Once you do, you will see the icon of personal email configuration.

    Good luck.

  • After I close my browser IE 9 and return to the office, my office programs are not available.

    After I close my browser IE 9 and return to the office, my office programs are not available. I have hover over a program and click, nothing happens for a few minutes... On the other hand, the taskbar and toolbar are all functioning normally. No other problems seem to be present.

    Thank you.

    Original title: freezing of funds

    Hello Manu,

    Thanks for the guidelines to help me solve my problem. Just to tell you that no, I have no error messages when I tried to access the office programs and Yes, I made a few changes in the pc... in the registry with Glary Utilities. That was my main concern.

    However, I tried the AUDITOR of FILE SYSTEM (CFS) and it fixed some problems.

    I also watched method 2 and did a performance using MICROSOFT FIX patch and ran that the Microsoft SECURITY SCANNER both have not reported any problems.

    Also tried method 1, no problem in safe MODE. I didn't think it was a third party program... so I decided to do a restore to an earlier date... then the problem seems to have disappeared.

    Start the pc also seems to be much faster.

    Thanks for the suggestions... I'll keep them as reference just in case...

  • How can I select the first date (at least) and the corresponding date of two different tables source?

    I have 2 tables, INVOICE and INVOICE_REFNUM similar to below. I'm writing a query that withdrawing the first date (less) for a single record remaining the two tables. Each table records the receipt of invoices, but according to the source of the received invoice some may reside in INVOICE_REFNUM and others the INVOICE table. I also use DECODE on the topic of INVOICE_SOURCE, when the date less is taken from the INVOICE table that contains that field, so if the date is in the field INVOICE_REFNUM DECODE is not necessary. Example:

    INVOICE (table)

    INVOICE_GID INVOICE_SOURCE INSERT_DATE

    ABC. AVRT123 I HAVE 11/03/2012-15:49:32

    ABC. CNWY234 G 12/03/2012 14:07:30

    ABC. UPGF678 M 15/03/2012 20:21:54

    INVOICE_REFNUM (table)

    INVOICE_GID INVOICE_REFNUM_QUAL INVOICE_REFNUM_VALUE INSERT_DATE

    ABC. AVRT123 SOURCE ACS 11/03/2012 14:49:32

    ABC. CNWY234 SOURCE CSA 12/03/2012 13:07:30

    ABC. UPGF678 SOURCE ACS 15/03/2012 21:21:54

    My decode statement is: DECODE ("INVOICE_SOURCE, 'I', 'IDE', 'G', ' Auto-Pay", ', 'Manual')

    If I were to write a query on these two tables, the output will resemble the following:

    INVOICE_GID INVOICE_SOURCE INSERT_DATE

    ABC. AVRT123 ACS 11/03/2012 14:49:32

    ABC. CNWY234 ACS 12/03/2012 13:07:30

    ABC. UPGF678 Manual 15/03/2012 20:21:54

    I worked on it for 2 days, and I was able to pull a date by using the following SQL code, but cannot determine how to extract the corresponding source:

    SELECT THE LEAST (GLOGOWNER. INVOICE_REFNUM. INSERT_DATE, GLOGOWNER. THE INVOICE. INSERT_DATE) AS 'DATE OF THE INVOICE.

    GLOGOWNER. THE INVOICE. INVOICE_GID,

    DECODE (GLOGOWNER. THE INVOICE. INVOICE_SOURCE, 'I', 'IDE', 'G', 'Auto-Pay', ', 'Manual').

    GLOGOWNER. INVOICE_REFNUM. INVOICE_REFNUM_VALUE

    OF GLOGOWNER. INVOICE

    LEFT JOIN GLOGOWNER. INVOICE_REFNUM

    ON GLOGOWNER. THE INVOICE. INVOICE_GID = GLOGOWNER. INVOICE_REFNUM. INVOICE_GID

    WHERE GLOGOWNER. INVOICE_REFNUM. INVOICE_REFNUM_VALUE = "ACS."

    AND GLOGOWNER. INVOICE_REFNUM. INVOICE_REFNUM_QUAL_GID = 'SOURCE '.

    AND GLOGOWNER. THE INVOICE. INVOICE_TYPE = 'I '.

    ORDER OF GLOGOWNER. THE INVOICE. INVOICE_GID

    Any help is greatly appreciated!

    Best regards

    -Adam

    Hello

    Is that what you want?

    SELECT i.invoice_gid

    CASE

    WHEN ir.insert_date<= i.insert_date ="" then ="">

    WHEN i.invoice_souce = 'I' and THEN 'EDI '.

    WHEN i.invoice_souce = 'G' THEN 'debit '.

    WHEN i.invoice_souce = am' THEN 'manual '.

    END AS invoice_source

    , The LEAST (i.insert_date, ir.insert_date) AS insert_date

    I have the Bill OF

    JOIN invoice_refnum ON i.invoice_gid = ir.invoice_gid ir

    WHERE ir.invoice_refnum_value = 'ACS '.

    AND ir.invoice_refnum_qual_gid = 'SOURCE '.

    AND i.invoice_type = 'I '.

    ORDER BY i.invoice_gid

    ;

    There is no reason to do an outer join if you only want the lines with specific values anyway.

    What happens if the 2 tables have exactly the same invoice_date?  The query above takes the invoice_source of invoice_refnum in this case, but that can easily be changed.

    Or the other of the insert_dates can be NULL?

    I hope that answers your question.

    Otherwise, thank you post a small example data (CREATE TABLE and only relevant columns, INSERT statements) for all of the tables involved and also after the results you want from these data (otherwise what you have already posted).

    Explain, using specific examples, how you get these results from these data.

    Always say what version of Oracle you are using (for example, 11.2.0.2.0).

    See the FAQ forum: https://forums.oracle.com/message/9362002#9362002

  • Data connection to the interactive form returns no results

    I have an interactive form of Adobe with a data connection that calls a function module compatible SAP rfc.  The call works fine, but it must return a value in the data connection response.  I know that the function module is feeding the return variable and binding form field to the answer is correct, but it never shows up.  We are on Live Cycle 9.0, with SAP EHP7.  Wsdl and soap links all look good. I tried data as "ordinary" connections and "run", used the two text fields of hierarchy and directly by dragging the data finds the response to the form field.  I played with various permutations to the soap and wsdl url.  The value of the response is necessary so that the user sees the result of the action (triggered by a button on the form).  Don't know what else to try.  As I said, the call to the SAP function module works fine, it's just the answer that I can't go back to the form. Any help to fix this would be greatly appreciated.

    I finally solved the problem myself.  Looks like a bug to me.

    In my interactive form, I have a button associated with the data EXTRACT connection that calls a function module compatible rfc in SAP called Z_LEMS_EXTRACT.  This function module returns a result of string called E_MESSAGE.

    The returned E_MESSAGE is then bound to a form text field.

    The generated XML defines the link as

    Z_LEMS_EXTRACTResponse\. E_MESSAGE

    I had to manually change the xml code for

    Z_LEMS_EXTRACT\. Response.E_MESSAGE

    This was determined by referring to another interactive form that was created in a previous version of Live Cycle Designer and a previous version of SAP, he used "\Response." and worked properly.  So I applied the same coding here and it works.

  • How to calculate the date from sysdate


    I try to get 12/09/2009-12:51:30 by subtracting the current date to sysdate.

    I can get with this year, but I don't know how I can get to the date and the month preceding.

    () Choose add_months (sysdate-36() of double) = 12/09/2010

    Planned result 12/09/2010 13:23:30

    Thank you for the help

    I'm assuming that time is fixed if it is to see the example below.

    SQL > select add_months (to_date (to_char(sysdate,'dd-mon-yyy') |)) (("" 12:51:30 ',' dd-MON-yyy hh: mi: ss AM "), - 36) prior_date
    2 double;

    PRIOR_DATE
    -----------------------
    12 - Oct - 2010 12:51:30

    SQL >

  • Using the application process, I need display CITY_NAME and return CITY_CODE

    Hello

    I have little problem .i have created an application process
    BEGIN
      OWA_UTIL.mime_header ('text/xml', FALSE);
      HTP.p ('Cache-Control: no-cache');
      HTP.p ('Pragma: no-cache');
      OWA_UTIL.http_header_close;
    htp.prn('<data>');
       HTP.prn ('<select>');
       HTP.prn ('<option value="' || 1 || '">' || '- Select City -'|| '</option>');
    FOR c IN (select CITY_CODE ,STATE_CODE   from CITY_MAS where STATE_CODE =:SELECT9)
    LOOP
      HTP.prn ('<option value="' || c.CITY_CODE || '">' || c.CITY_CODE  || '</option>');
       END LOOP;
    
       HTP.prn ('</select>');
    htp.prn('</data>');
    
    END;
    i have two Item 
    
    P1_STATE_NAME Select List 
    
    select STATE_NAME D, STATE_CODE R from   STATE_MAS 
    
    P1_CITY_NAME
    
    select CITY_NAME D, CITY_CODE R from CITY_MAS
    My Table are
    Table for STATE 
    
    CREATE TABLE  "STATE_MAS" 
       (     "STATE_CODE" VARCHAR2(3) NOT NULL ENABLE, 
         "STATE_NAME" VARCHAR2(50) NOT NULL ENABLE 
         
       )
    /
    
    
    ------------
    
    Table For CITY
    
    CREATE TABLE  "CITY_MAS" 
       (     "CITY_CODE" VARCHAR2(3) NOT NULL ENABLE, 
         "CITY_NAME" VARCHAR2(1000) NOT NULL ENABLE, 
         "STATE_CODE" VARCHAR2(3) NOT NULL ENABLE 
         
     )
    /
    When I select the name state select and city name of the list has changed with CITY_CODE AS the SEA, GUJ, MOM. CITY_CODE display in the selection list.

    I want Francisco in select cities list and return the value CITY_CODE

    I want when I select the name of the State of list select State then CITY_NAME should be enter in list to select the city names and CITY_CODE to return in to Table.

    I try this with in the last two days, but I can't.

    Please tell me how I can do this.


    Thank you

    Published by: 805629 on January 12, 2011 06:41

    Published by: 805629 on January 21, 2011 12:01 AM

    This is an old blog post which explains step by step. It is for cascading selection lists and must be exactly what you are looking for
    AJAX cascading select list in APEX

  • Display the date current system and the time in a form

    Hello experts around the world.

    I have this little minor challenge I'm having trouble in the corners.

    I have a form and I want to display the date current system and time so when I save the form his record with the date displayed.

    I tried sysdate, & sysdate and & sysdate. in the default part with static text with memories of State meetings.

    So any help or suggestion would be a great help :)

    Thank you

    Hi kevin

    write the script in the HTML header below.

    It will give at once, you can set this variable in the variable text box element.

    or else check the below link in java script

    http://www.McFedries.com/JavaScript/DateTime.asp

    see you soon,
    Shan

  • My iPhone6 has convinced himself that he has a helmet connected - how can I convince otherwise and return to the normal setting?

    My iPhone6 has convinced himself that he has a helmet connected - how can I convince otherwise and return to the normal setting?  I tried turning it off and back on after awhile, but did not.

    Double check with a magnifying glass and a good lighting that nothing has been slain. Then, try insertion and withdrawal of your headphones a couple of times. If this does not work, it may be while the shooting went wrong. In this case, make an appointment at the Genius Bar at your local Apple store for the assessment.

Maybe you are looking for