Sql function for trimming from center

Hi Experts;
Is there any function which can remove/trim from center like i have a number
01-1552963-01 and i want to remove - from it.
01155296301
note that i dont want to use substr and concat ||
regards,

RB wrote:
AND With REGEXP_REPLACE
SQL>  SELECT REGEXP_REPLACE('01-1552963-01','-','')  Sample from dual;
SAMPLE
01155296301
An empty string is considered null in Oracle so that's the same as:
SQL>  SELECT REGEXP_REPLACE('01-1552963-01','-')  Sample from dual;
SAMPLE
01155296301which, let's face it is pretty pointless when a regular REPLACE function will do the same.
You should only really use the regular expression versions when you have a pattern that needs matching, not just a fixed set of characters.

Similar Messages

  • Built in SQL Function for Sum of Geometric Progression

    Hi all,
    Please let me know if there is any availble built in SQL function for
    SUm of Geometric Progression.
    Thanks in Advance,
    Kaushik B.

    and also relatively simple to write:
    s = a*(1-power(r,n+1))/(1-r)
    assuming you have a row with values of a,r and n (and that's the sum you need)
    Jon

  • XMLType schema detail lost in pl/sql function for a jdeveloper webservice

    If I write a very simple pl/sql procedure to wrap as a web service to return the XML from an XMLtype table column, the jdeveloper (11.1.1.3) web service generation process seems to ignore the detail
    of the registered XMLTypes' schema, and converts the 'output' to an xsd:string in the generated WSDL file, which has knock on effect that generated data controls are 'dumb' in only seeing output as a string, and providing no real data functionality at XML schema level. Since I know web service data controls work fine when provided with the correct level of detail in the WSDL, what am I missing in terms of pursuading jdeveloper to generate wsdl's with full xsd schema info for the return XMLType?
    This is my table:
    ID NOT NULL NUMBER(12)
    SPEC SYS.XMLTYPE(XMLSchema "http:
    //localhost:8080/public/demo
    /xsd/sample2.xsd" Element "b
    ooks") STORAGE BINARY
    PRD_ID NOT NULL NUMBER(10)
    ISSUE NOT NULL NUMBER(6)
    EDIT_NO NOT NULL NUMBER(6)
    PUBLISHED_BY_PEO_ID NUMBER(10)
    PUBLISHED_ON_DT DATE
    EFFECTIVE_FROM_DT NOT NULL DATE
    EFFECTIVE_TO_DT DATE
    =======================================================
    This is the XML Schema:
    <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
    targetNamespace="urn:books"
    xmlns:bks="urn:books">
    <xsd:element name="books" type="bks:BooksForm"/>
    <xsd:complexType name="BooksForm">
    <xsd:sequence>
    <xsd:element name="book"
    type="bks:BookForm"
    minOccurs="0"
    maxOccurs="unbounded"/>
    </xsd:sequence>
    </xsd:complexType>
    <xsd:complexType name="BookForm">
    <xsd:sequence>
    <xsd:element name="author" type="xsd:string"/>
    <xsd:element name="title" type="xsd:string"/>
    <xsd:element name="genre" type="xsd:string"/>
    <xsd:element name="price" type="xsd:float" />
    <xsd:element name="pub_date" type="xsd:date" />
    <xsd:element name="review" type="xsd:string"/>
    </xsd:sequence>
    <xsd:attribute name="id" type="xsd:string"/>
    </xsd:complexType>
    </xsd:schema>
    =================================================
    This is the pl/sql:
    function GetSpecificationById (p_spec_id in NUMBER) return XMLType
    IS
    l_specification sys.XMLType;
    BEGIN
    select specification
    into l_specification
    from specifications
    where id = p_spec_id;
    return l_specification;
    EXCEPTION
    WHEN OTHERS THEN -- handles all other errors
    ROLLBACK;
    END GetSpecificationById;
    ==============================================
    And this is the generated WSDL:
    <?xml version="1.0" encoding="UTF-8" ?>
    <wsdl:definitions
    name="MyWebService1"
    targetNamespace="http://devsafetrytrailcom/MyWebService1.wsdl"
    xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
    xmlns:tns="http://devsafetrytrailcom/MyWebService1.wsdl"
    xmlns:xsd="http://www.w3.org/2001/XMLSchema"
    xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/"
    xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
    xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/"
    >
    <wsdl:types>
    </wsdl:types>
    <wsdl:message name="MyWebService1_getspecificationbyid">
    <wsdl:part name="pSpecId" type="xsd:decimal"/>
    </wsdl:message>
    <wsdl:message name="MyWebService1_getspecificationbyidResponse">
    *<wsdl:part name="result" type="xsd:string"/>*
    </wsdl:message>
    <wsdl:portType name="MyWebService1">
    <wsdl:operation name="getspecificationbyid" parameterOrder="pSpecId">
    <wsdl:input message="tns:MyWebService1_getspecificationbyid"/>
    <wsdl:output message="tns:MyWebService1_getspecificationbyidResponse"/>
    </wsdl:operation>
    </wsdl:portType>
    <wsdl:binding name="MyWebService1" type="tns:MyWebService1">
    <soap:binding style="rpc"
    transport="http://schemas.xmlsoap.org/soap/http"/>
    <wsdl:operation name="getspecificationbyid">
    <soap:operation soapAction="http://devsafetrytrailcom/MyWebService1.wsdl/getspecificationbyid"/>
    <wsdl:input>
    <soap:body use="literal"
    namespace="http://devsafetrytrailcom/MyWebService1.wsdl"
    parts="pSpecId"/>
    </wsdl:input>
    <wsdl:output>
    <soap:body use="literal"
    namespace="http://devsafetrytrailcom/MyWebService1.wsdl"
    parts="result"/>
    </wsdl:output>
    </wsdl:operation>
    </wsdl:binding>
    <wsdl:service name="MyWebService1">
    <wsdl:port name="MyWebService1Port" binding="tns:MyWebService1">
    <soap:address location="http://localhost:7101/SafetyTrail-Model-context-root/MyWebService1Port"/>
    </wsdl:port>
    </wsdl:service>
    </wsdl:definitions>
    Edited by: user592403 on Jul 26, 2010 9:57 AM

    Anyone seen this problem before??

  • How can i make a pl/sql function for BLOB datatype

    hi..anyone here who is very familiar about BLOB datatype. i have a COLUMN_ID, COLUMN_A in a certain TABLE_1. COLUMN_A is blob datatype that contains almost 250,000rows
    SQL>select column_A from table_1 where column_id=1234567
    column_A
    00000001000000010000000606D4E833074B69EC06D4E91F074CO18406D50C58074C031E
    how can i make a user-defined function to compute and convert this blob datatype into decimal length value. this hex value are points in the map.. the function must contain
    1.get the length of a blob then
    2.convert blob to variable hexadecimal characters by parsing it into 8
    3.to_number function or other function used to convert haxadecimal characters to decimal numbers
    4.phythagorean formula to compute length between two points. this is the formula i think LENGTH =
    SQRT(power((coordinate_x-prev_coordinate_x),2)+power((coordinate_y-prev_y),2));
    after this when i type this
    SQL>select user_function(column_A) from table_1 where column_id=1234567
    user_functions(column_A)
    --output length will be in decimal value already
    the function will goes like this
    step1 is to get the blob length
    00000001000000010000000606D4E833074B69EC06D4E91F074CO18406D50C58074C031E
    step2 is parsing of data by eights
    00000001 =>1
    00000001 =>1
    00000006 =>6 (number of coordinates)
    06D4E833 => X1
    074B69EC => Y1
    06D4E91F => X2
    074CO184 => Y2
    06D50C58 => X3
    074C031E => Y3
    step3 to_number function used to convert hex char to decimal
    step4 compute by phytagorean (NOTE ! when computing length the third parsed eight will tell how many coordinates are there..the number of coordinates is ranging from 2 up to E..above example shows 6 coordinates so it means
    LENGTH1 =
    SQRT(power((X2-X1),2)+power((Y2-Y1),2));
    LENGTH2=
    SQRT(power((X3-X2),2)+power((Y3-Y2),2));
    TOTAL LENGTH=LENGTH1 + LENGTH2
    thanks

    its my first time to use that.There's got to be a first tiem for anything. Be brave.
    btw if theres more easy suggestion pls feel free..Well of course the easiest solution would be if the calling program passed in the parameters as separate arguments instead of glomming them together in a string that has to be parsed. This sort of kluj really ought not to have survived into C21.
    Cheers, APC

  • PL/SQL-Function for validation

    I wrote a PL/SQL function in order to validate that the SUM of input-values doesn't exceed 100.
    I used validation rule from APEX for PL/SQL-expression (same like SQL-expression):
    f_page_16_validation(:P16_PSP_PSP)<=100 (Condition: CREATE, SAVE)
    source code for function:
    CREATE OR REPLACE FUNCTION f_page_16_validation
    (pi_p16_psp_psp VARCHAR2)
    RETURN NUMBER
    IS
    vl_sum NUMBER(5) := 0;
    BEGIN
    SELECT NVL(SUM(psp_anteil_projekt),0) INTO vl_sum
    FROM st_psp_projekt_psp
    WHERE UPPER(psp_psp) = pi_p16_psp_psp;
    RETURN vl_sum;
    END f_page_16_validation;
    When I check in SQL*Plus against database: SELECT f_page_16_validation('A_TEST_UHL_PSP%') FROM dual;
    I get the correct value. When I input into APEX-Application the validation rule doesn't fire (CREATE). If my SUM is over 100 and try to change
    one value (in order to come under 100) (SAVE) - the validation rule fires but quite independent of the SUM - it accepts NO VALUE!!
    Apex-Version: 3.1.1.00.09
    Can somebody tell me what's wrong? Is there any other way - SQL,PL/SQL-expression, PL/SQL-function body (bool, error text) didn't work.

    1. If your PL/SQL expression is written as you stated:
    f_page_16_validation(:P16_PSP_PSP)<=100then you will receive an error message if the total is <= 100 and not if it exceeds 100.
    2. Where in your code do you consider the input values? I see that you are selecting from a table, where your already inserted values are but I see no input values. Are you using a form or a tabular form? If I look at the names of your buttons then I wouls say you are using a form.
    3. You are talking about condition. What type of condition you use? I would use a PL/SQL Expression like this:
    :REQUEST IN ('CREATE', 'SAVE')4. I would suggest to use a validation of type PL/SQL Function Returning Error Text since you can put all the code in one.
    Denes Kubicek
    http://deneskubicek.blogspot.com/
    http://www.opal-consulting.de/training
    http://apex.oracle.com/pls/otn/f?p=31517:1
    -------------------------------------------------------------------

  • Sql function for fetching only initail char of string

    Hi All,
    I would like to know is there any sql builtin function which returns initial char(abbrevation) of any string pass to it
    for eg. DEPARTMENT SUB GROUP should return DSG..
    Pls do share with me if any 1 is aware of this or who has already self defined any function for this purpose.
    Thanks in Advance

    And if you have 10g available, here's the regex version:
    with t as (select 'DEPARTMENT SUB GROUP' col1
                 from dual)
    select t.col1, regexp_replace(t.col1, '(\w)\w*\s*', '\1')
      from t;Small correction, just in case we only have 1 letter words.
    C.

  • SQL Function for calculating IP Address

    Hi Experts ,
    I have an IP Range i need to find out the First Host detail for the IP using a SQL scalar function .
    Example : 11.30.10.40
    Subnet Mask is 26
    Output required
    First host: 11.30.10.1
    am confused how i can derive the first host  values from a sql function kindly help .
    Thanks
    Priya

    DECLARE @Mask TINYINT = 26;
    DECLARE @AddressIP VARCHAR(15)= '11.30.10.40';
    DECLARE @AddressValue BIGINT = PARSENAME(@AddressIP,4)*CAST(256*256*256 AS BIGINT)+PARSENAME(@AddressIP,3)*256*256+PARSENAME(@AddressIP,2)*256+PARSENAME(@AddressIP,1);
    WITH
    n0(n) AS (SELECT 0 UNION ALL SELECT 0)
    ,n1(n) AS (SELECT 0 FROM n0 a CROSS JOIN n0)
    ,n2(n) AS (SELECT 0 FROM n1 a CROSS JOIN n1)
    ,n3(n) AS (SELECT 0 FROM n2 a UNION ALL SELECT 0 g FROM n2)
    ,t (n) AS (SELECT ROW_NUMBER() OVER (ORDER BY (SELECT NULL)) FROM n3)
    ,bits(b,v) AS (SELECT n,POWER(CAST(2 AS BIGINT),32-n) FROM t)
    SELECT @AddressIP [Address]
    ,CAST((SUM(v) / 256 / 256 / 256) % 256 AS VARCHAR(3)) + '.' + CAST((SUM(v) / 256 / 256) % 256 AS VARCHAR(3)) + '.' + CAST((SUM(v) / 256) % 256 AS VARCHAR(3)) + '.' + CAST(SUM(v) % 256 AS VARCHAR(3)) [Netmask]
    ,CAST(((SUM(v) ^ 0xFFFFFFFF) / 256 / 256 / 256) % 256 AS VARCHAR(3)) + '.' + CAST(((SUM(v) ^ 0xFFFFFFFF) / 256 / 256) % 256 AS VARCHAR(3)) + '.' + CAST(((SUM(v) ^ 0xFFFFFFFF) / 256) % 256 AS VARCHAR(3)) + '.' + CAST(((SUM(v) ^ 0xFFFFFFFF)) % 256 AS VARCHAR(3)) [Wildcard]
    ,CAST(((@AddressValue & SUM(v)) / 256 / 256 / 256) % 256 AS VARCHAR(3)) + '.' + CAST(((@AddressValue & SUM(v)) / 256 / 256) % 256 AS VARCHAR(3)) + '.' + CAST(((@AddressValue & SUM(v)) / 256) % 256 AS VARCHAR(3)) + '.' + CAST(((@AddressValue & SUM(v))) % 256 AS VARCHAR(3)) + '/' + CAST(MAX(b) AS VARCHAR(2)) [NetworkAddress]
    ,CAST(((((SUM(v) ^ 0xFFFFFFFF)) | @AddressValue) / 256 / 256 / 256) % 256 AS VARCHAR(3)) + '.' + CAST(((((SUM(v) ^ 0xFFFFFFFF)) | @AddressValue) / 256 / 256) % 256 AS VARCHAR(3)) + '.' + CAST(((((SUM(v) ^ 0xFFFFFFFF)) | @AddressValue) / 256) % 256 AS VARCHAR(3)) + '.' + CAST(((((SUM(v) ^ 0xFFFFFFFF)) | @AddressValue)) % 256 AS VARCHAR(3)) [BroadcastAddress]
    ,CAST(((@AddressValue & SUM(v)) / 256 / 256 / 256) % 256 AS VARCHAR(3)) + '.' + CAST(((@AddressValue & SUM(v)) / 256 / 256) % 256 AS VARCHAR(3)) + '.' + CAST(((@AddressValue & SUM(v)) / 256) % 256 AS VARCHAR(3)) + '.' + CAST(((@AddressValue & SUM(v))) % 256 + 1 AS VARCHAR(3)) [FirstHost]
    ,CAST(((((SUM(v) ^ 0xFFFFFFFF)) | @AddressValue) / 256 / 256 / 256) % 256 AS VARCHAR(3)) + '.' + CAST(((((SUM(v) ^ 0xFFFFFFFF)) | @AddressValue) / 256 / 256) % 256 AS VARCHAR(3)) + '.' + CAST(((((SUM(v) ^ 0xFFFFFFFF)) | @AddressValue) / 256) % 256 AS VARCHAR(3)) + '.' + CAST(((((SUM(v) ^ 0xFFFFFFFF)) | @AddressValue)) % 256 - 1 AS VARCHAR(3)) [LastHost]
    ,(((SUM(v) ^ 0xFFFFFFFF)) | @AddressValue) - (@AddressValue & SUM(v)) - 1 [TotalHostCount]
    FROM bits WHERE @Mask BETWEEN 1 AND 32 AND b <= @Mask
    Jon

  • Using pl/sql functions for transformation

    How can I use pl/sql functions in the transformation mapping field for my interface?
    I have a name field where firstname and lastname are concatenated via a space-character and I would like to extract this 'name' field to 2 separate database attributes.
    This means that I need to use a function that uses SUBSTRING and INSTR to be able to get the firstname and lastname separatly out of the name-field.
    The INSTR-function isn't known inside the expression editor in ODI so I'm wondering how I can use my own function?

    Hi Romanna,
    Are you sure? Where did you do your transformation?
    -Source, Staging area or Target
    I try this on Oracle target...
    FIRST_NAME = substr(MYTABLE.FIRST_LASTNAME, 1, instr(MYTABLE.FIRST_LASTNAME, ' ')-1)
    LAST_NAME = substr(MYTABLE.FIRST_LASTNAME,instr(MYTABLE.FIRST_LASTNAME, ' ')+1)

  • SQL Function to trim characters

    Hi!
    Can someone help me with writing SQL Function which receive a string and return it with all the below ASCII characters values removed:
    chr(n)>31 AND chr(n)<48
    OR
    chr(n)>57 AND chr(n)<65
    OR
    chr(n)>90 AND chr(n)<97
    OR
    chr(n)>122 AND chr(n)<128
    Thanks

    Actually, I forgot chr(127) in there. Try this:
    select regexp_replace(yourstring,  '[[:punct:] '||chr(127)||']', '') from dual;Example:
    SQL> select regexp_replace(
       'hello !"#$%&''()*+,-./:;<=>?@[\]^_`{|}~'||chr(127)||'there'
       , '[[:punct:] '||chr(127)||']'
    ) from dual;
    REGEXP_REP
    hellotherecheers,
    Anthony

  • Equivalent Sql function for Forms NAME_IN() built in

    Please let me know, is there any equivalent Sql function equivalent to Forms Name_in() built in. Thanks.

    What would such a function do in pure SQL? Or are you asking if you can refer to Forms variables in SQL that you issue from Forms?
    The answer to the first question I will delay until you define what it is that you want to do. The answer to the second question is that there is no way to do that. The database has no way of knowing how to resolve references to variables defined in client side PLSQL.

  • Function for reading from serial port

    Hi experts,
    We are trying to read data from the serial port with the following function we got from internet.
    The problem is when creating the object with the sentence CREATE OBJECT o_obj '"MSCOMMLib.MSComm.1"'.
    This returns a sy-subrc = 2 and shows the exception NO_CREATE_OBJECT.
    We already copied the file MSCOMM32.OCX in c:\windows\system32 and we successfuly registered it, with regsvr32.exe.
    We tried it with Windows XP and Vista.
    Anybody has any idea?
    Thanks in advance
    FUNCTION ZSERIALCOM.
    ""Interfase local
    *"  IMPORTING
    *"     REFERENCE(MODE) TYPE  I DEFAULT 0
    *"     REFERENCE(COMMPORT) TYPE  I DEFAULT 1
    *"     REFERENCE(SETTINGS) TYPE  C DEFAULT '2400,N,8,1'
    *"     REFERENCE(OUTPUT) TYPE  C OPTIONAL
    *"  EXPORTING
    *"     REFERENCE(INPUT) TYPE  C
    *"  EXCEPTIONS
    *"      NO_CREATE_OBJECT
      TYPE-POOLS: sabc.
      INCLUDE ole2incl.
      PERFORM init.
      PERFORM open_port USING commport settings.
      IF mode = 0.
        PERFORM read_port
        CHANGING input.
      ENDIF.
      IF mode = 1.
        PERFORM write_port
        USING output
        CHANGING input.
      ENDIF.
      PERFORM final.
    ENDFUNCTION.
    DATA: o_obj TYPE ole2_object.
    *& Form Init
    text
    --> p1 text
    <-- p2 text
    FORM init.
    DATA:
    wa_repid LIKE sy-repid.
    wa_repid = sy-repid.
    CALL FUNCTION 'AUTHORITY_CHECK_OLE'
    EXPORTING
    program = wa_repid
    activity = sabc_act_call
    application = 'MSCOMMLib.MSComm.1'
    EXCEPTIONS
    no_authority = 1
    activity_unknown = 2
    OTHERS = 3.
    IF sy-subrc <> 0.
    MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
    WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
    ENDIF.
    CREATE OBJECT o_obj '"MSCOMMLib.MSComm.1"'.
    IF sy-subrc <> 0.
    RAISE no_create_object.
    ENDIF.
    ENDFORM. " Init
    FORM open_port *
    --> COMMPORT *
    --> SETTINGS *
    FORM open_port USING commport settings.
    SET PROPERTY OF o_obj 'CommPort' = commport.
    SET PROPERTY OF o_obj 'Settings' = settings.
    SET PROPERTY OF o_obj 'InputLen' = 0.
    SET PROPERTY OF o_obj 'PortOpen' = 1.
    ENDFORM. "open_port
    FORM read_port *
    --> INPUT *
    FORM read_port
    CHANGING input.
    DATA:
    wa_buffer TYPE i.
    DO 10 TIMES.
    GET PROPERTY OF o_obj 'InBufferCount' = wa_buffer.
    IF wa_buffer > 0.
    GET PROPERTY OF o_obj 'Input' = input.
    EXIT.
    ENDIF.
    ENDDO.
    ENDFORM. " read_port
    FORM write_port *
    --> OUTPUT *
    FORM write_port
    USING output
    CHANGING input.
    DATA:
    wa_buffer TYPE i.
    SET PROPERTY OF o_obj 'Output' = output.
    DO 10 TIMES.
    GET PROPERTY OF o_obj 'InBufferCount' = wa_buffer.
    IF wa_buffer > 0.
    GET PROPERTY OF o_obj 'Input' = input.
    EXIT.
    ENDIF.
    ENDDO.
    ENDFORM.
    *& Form final
    text
    --> p1 text
    <-- p2 text
    FORM final.
    SET PROPERTY OF o_obj 'PortOpen' = 0.
    FREE OBJECT o_obj.
    ENDFORM. " finalbligw

    Hi ,
    I want to read value form weigh bridge through COMM port. I have developed the FM and done the setting as mentioned in the below link
    Read COMM port using ABAP w/o third party software 
    but while executing the FM independently I am able to get the value from the COMM port,but when I call the FM from a program I am not able to get the output value from the FM.I am calling the FM from the report program.please find the code below.
    report test.
    data : lv_input TYPE c.
    CALL FUNCTION 'ZFM_WEIGHINTERFACE'
      EXPORTING
        MODE                         = 0
        COMMPORT               = 1
        SETTINGS                  = '1200,N,8,1'
        OUTPUT                     = ''
      IMPORTING
        INPUT                        = lv_input
      EXCEPTIONS
        NO_CREATE_OBJECT       = 1
        OTHERS                 = 2
    IF SY-SUBRC <> 0.
    * Implement suitable error handling here
    ENDIF.
    if I execute the FM independently the output is getting perfectly.but while calling from a program i am facing the issue..
    any suggestion is appreciated.
    Thanks
    Vivek

  • SQL function for PKIDs in 6.1.1

    Hi,
    I would like to ask if there is a new SQL function to generate the shorter PKIDs in 6.1.1?
    Thanks in advance.

    We do not yet have database functions to generate the new shortened PKIDs. If you want this, you can log an Enhancement Request with support..
    Thanks,
    Ron

  • Using pl/sql function for each day between two dates.

    Hi,
    create TABLE EMP(
    ID_EMP NUMBER,
    DT_FROM DATE,
    DT_TO DATE,
    CREATE_DATE DATE);
    into EMP(ID_EMP, DT_FROM, DT_TO, CREATE_DATE)
    Values(100, TO_DATE('07/01/2008 00:00:00', 'MM/DD/YYYY HH24:MI:SS'), TO_DATE('04/30/2010 00:00:00', 'MM/DD/YYYY HH24:MI:SS'),TO_DATE('05/08/2009 14:11:21', 'MM/DD/YYYY HH24:MI:SS'));
    I have a function called  elig_pay_dates(date p_date), which returns the code for  person payment eligibility for a particular date. For paid dates it's 'P' and for unpaid dates it's 'N'.
    How can I check this function between two dates for each day. Example : 07/01/2008 to 04/30/2010.
    By using this function with select I needs to display the dates when there is a change in status.
    I am expecting data in following manner from above logic(this is example):
    07/01/2008 --- 07/01/2009 ---'P'
    07/02/2009 -- 07/25/2009 ----'N'
    07/26/2009 -- 01/01/2010 ---'P'
    01/02/2010 -- 01/13/2010 --'N'
    01/14/2010 -- 01/18/2010 --'P'
    01/19/2010 -- 04/30/2010 -- 'N'
    I thought of looping for each day date but that seems to be expensive for online application. Is there any way that I can achieve this requirement with sql query ?
    Thanks for your help,

    Certainly not the best way to code the requirement, but it does achieve the result you are looking for in a fairly quick time
    create or replace
    function test_ret_paid_unpaid (p_date in date)
    return varchar2
    is
      v_ret     varchar2(1);
    begin
      if ( (p_date between to_date('07/02/2009', 'MM/DD/YYYY') and to_date('07/25/2009', 'MM/DD/YYYY') ) or
           (p_date between to_date('01/02/2010', 'MM/DD/YYYY') and to_date('01/13/2010', 'MM/DD/YYYY') ) or
           (p_date between to_date('01/19/2010', 'MM/DD/YYYY') and to_date('04/30/2010', 'MM/DD/YYYY') )
        then v_ret := 'N';
      else
        v_ret := 'Y';
      end if;
      return v_ret;
    end;
    Wrote file afiedt.buf
      1  with get_paid_unpaid as
      2  (
      3    select dt_from start_date, dt_to end_date, dt_from + level - 1 curr_date, test_ret_paid_unpaid(dt_from + level - 1) paid_unpaid,
      4           row_number() over (order by dt_from + level - 1) rn_start,
      5           row_number() over (order by dt_from + level - 1 desc) rn_end
      6      from test_emp
      7    connect by level <= dt_to - dt_from + 1
      8  ),
      9  get_stop_date as
    10  (
    11  select start_date init_date, end_date, curr_date, paid_unpaid,
    12         case when paid_unpaid != lag(paid_unpaid) over (order by curr_date) or rn_start = 1 or rn_end = 1
    13          then curr_date
    14          else null
    15         end start_date,
    16         case when paid_unpaid != lead(paid_unpaid) over (order by curr_date) or rn_start = 1 or rn_end = 1
    17          then curr_date
    18          else null
    19         end stop_date
    20    from get_paid_unpaid
    21  )
    22  select period, paid_unpaid
    23    from (
    24  select init_date, curr_date, start_date, end_date, stop_date,
    25         case when paid_unpaid = lead(paid_unpaid) over (order by curr_date)
    26                then nvl(start_date, init_date) || ' - ' || lead(stop_date, 1, end_date) over (order by curr_date)
    27              else null
    28         end period,
    29         paid_unpaid
    30    from get_stop_date
    31   where stop_date is not null or start_date is not null
    32         )
    33*  where period is not null
    12:06:10 SQL> /
    PERIOD                                             PAID_UNPAID
    01-JUL-08 - 01-JUL-09                              Y
    02-JUL-09 - 25-JUL-09                              N
    26-JUL-09 - 01-JAN-10                              Y
    02-JAN-10 - 13-JAN-10                              N
    14-JAN-10 - 18-JAN-10                              Y
    19-JAN-10 - 30-APR-10                              N
    6 rows selected.
    Elapsed: 00:00:00.35

  • Accessing Webdynpro Java iview functionality for print from webdynpro code

    I know.. you would love to post me with n different blogs and forums discussion about how to print from webdynpro java application.
    But lets read before what i am looking for..
    There is standard "Print" function available on webdynpro for java iview.. and layout and all its just fine for us. though we want to trigger this event from a screen button. as going to iview properties is very user friendly.
    I was looking for some iview api which can help me.. We are on NW 7.01 SP6 at the moment. And this is for standard ESS applications.
    Thanks a lot for your inputs.
    Regards,
    Sudhir

    Hi
    You can write Java program for printing. Call the java class from screen (button or Url). Also you can write the content to XMl file.open the xml file in action. so that u will get print preview and print option.

  • SQL function for adding street, city and postal code.

    I would like to know how to add to my code to display the addresses.
    Any ideas?
    SELECT departments.department_name "Department Name", locations.state_province "Mailing Address"
    FROM departments, locations
    WHERE departments.location_id=locations.location_id
    AND locations.country_id='US'
    ORDER BY department_name;
    OUTPUT SO FAR:
    Department Name Mailing Address
    Accounting Washington
    Administration Washington
    Contracting Washington
    Executive Washington
    IT Texas
    Shipping California

    Hi,
    Do you want the four database columns to appear as one output column, perhaps with a space between the columns?
    If so, concatenate the strings into one big string using ||
    SELECT departments.department_name "Department Name"
    , street_address
    || ' ' || city
    || ' ' || locations.state_province
    || ' ' || postal_code AS "Mailing Address"
    FROM departments, locations
    WHERE departments.location_id=locations.location_id
    AND locations.country_id='US'
    ORDER BY department_name;
    Message was edited by:
            Frank Kulash                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

Maybe you are looking for

  • Can't make calls or sms on iphone 3gs after iOs5 upgrade?

    I upgraded to iOS5 on my iphone 3gs and I am having major problems connecting to the 3g network. I can't make or recieve calls or sms, or log on to the internet over the 3g network. wifi works fine, but that doesn't help with the calls or the sms, an

  • Error 1935 when downloading Adobe Reader on Windows 8.

    I am trying to download Adobe Reader on my new Windows 8 computer. I have the app, but I need the program to work on the desktop of the system, so that pdfs and word documents can be open side-to-side. Dell has been unhelpful in solving this problem.

  • New SF300-24P 10/100 POE Switch effecting Sybase App

    I recently moved my office. I am running a small Network on Windows 8.1. The main program for my Business no longer has tech support. The program uses sybase sql anywhere 9.0 to network. When I moved from one location to another the only thing that c

  • Post XI Installation Steps

    Hi all After installation of XI , and deployement of patches, What are the steps to be followed for SLD configuration, regards sonali

  • Filters Stopped working

    What we want to show after filter is applied is the following: 1. That the drawings are complete 2. That the DSL is incomplete  In the "DWGs Comp" column we have this formula : IIf([Name]='Drawings' And [% Complete]=100,Yes,No)  In the "DSL Comp" col