SQL condition not working

Hi,
The following query works as expected while running from Oracle database.
the same query is on a query zone of type F1-DE-QUERY but doesnt work the same way.
i know the problem is in using the replace(PHONE,')','') LIKE .... statement only.
is there any restriction on using the sql functions from query zone.
please help.
SELECT DISTINCT A.PER_ID as person, EMAILID as email, PHONE as phone
FROM
CI_PER P
JOIN CI_ACCT_PER A ON P.PER_ID=A.PER_ID
LEFT OUTER JOIN CI_PER_PHONE PH ON PH.PER_ID = P.PER_ID
WHERE
(replace(PHONE,' ','') LIKE '%' || :F1 || '%' or
replace(PHONE,'(','') LIKE '%' || :F1 || '%' or
replace(PHONE,')','') LIKE '%' || :F1 || '%' or
replace(PHONE,'-','') LIKE '%' || :F1 || '%'
AND
LENGTH(:F1) > 4;
Thanks.

Hi,
This section what for: "... LIKE '%' || :F1 || '%' ..."?
You just need to:
1. for user filter F1 in portal zone define 'likeable=s'
2. change your SQL statement on "... LIKE (:F1) ..."

Similar Messages

  • OR condition not working correctly in SQL

    I am adding the folling condition to a sql statement and
    AND (status_code IS NULL or status_code <> 'T'
    or (status_code IN ('A','B','C','D') and TRIM(order_type) NOT LIKE '%9999')
    or (status_code IN ('A','B','C','D') and order_type IS NOT NULL)
    or (status_code NOT IN ('A','B','C','D')))
    but the or condition work...
    if i change it too
    AND ( (status_code IN ('A','B','C','D') and order_type IS NOT NULL) )
    then this portion of the OR condition work but when I use the OR condition something weird is happening that the condition not working... and i dont see a record that meets that condition...

    Hi,
    It's not the "trim" that implies "not null", but rather the fact that:
    - "not like" operator works only on non-null values and
    - "not like" operator disregards null values.
    Consider this:
    test@ORA92>
    test@ORA92>
    test@ORA92> l
      1  with x as (
      2    select null as y from dual union all
      3    select 'a9999' from dual union all
      4    select 'bxx' from dual
      5  )
      6  select * from x
      7* where y not like '%9999'
    test@ORA92>
    test@ORA92> /
    Y
    bxx
    1 row selected.
    test@ORA92>
    test@ORA92>Here, trim function was not used, but still the first row (that had null for y) was not returned. That's because Oracle disregarded the first row for comparison and out of the next two rows, it returned the third row because it satisfied the condition.
    As for your query, do the following conditions hold true:
    1. if status_code is null      - show the row regardless of order_type
    2. if status_code <> 'T'       - show the row regardless of order_type
    3. if status_code in (a,b,c,d) and order_type is not null and order_type ends with something other than 9999 - show the row
    4. if status_code in (a,b,c,d) and order_type is null                           - do not show the row
    5. if status_code in (a,b,c,d) and order_type is not null and it ends with 9999 - do not show the row
    6. if status_code is anything other than (a,b,c,d)                              - do not show the rowpratz

  • What will you do if any SQL is not working.in oracle 10g...apps 11.5.10.2

    What will you do if any SQL is not working. in oracle 10g....apps 11.5.10.2

    928714 wrote:
    yes sir.If you help me in answering my questions i wll be very thankful to you sir.
    tnx,I haven't a clue.
    As you have been advised in many of your posts, go study the documentation for whichever specific topic you are interested in.
    For me to answer your questions, I would need to go get that documentation.
    Then I would need to read that documentation.
    Then I would need to write a forum post that interprets what I think I learned from that documentation.
    It is so very much faster if YOU go do that instead of posting to a forum and expecting others to do it. You will remember what you study for a lot longer time if you teach yourself.

  • Force encryption on SQL Server not working?

    Hello Everyone,
    I'm running SQL Server 2008 64-bit. I've installed a self-signed cert on the box and set  "Force Encryption"  and restarted SQL server. 
    I setup a client machine to trust the authority of the cert installed on the server. When I connect to that SQL server from SSMS from a client machine and select the "encrypt connection" option in the client Connection properties, SSMS correctly complains
    that the cert on the server does not match the computer name I asked to log into . This is because, although the cert is trusted, the dns name dos not match the CN in the cert <- Perfect, exactly what I am expecting.
    When I connect to the same SQL server from the same client but  UNCHECK "encrypt connection" on the client, I'm able to login. Considering I've checked the "Force Encryption" on the server, the server should have rejected the connection. Why not?
    Ameer Deen

    Hi all,
    We are implementing a Merge Synchronization solution which involves three SQL Servers located on three Azure locations worldwide and one on-premises location. We need to secure communications between all servers. We are evaluating the encryption of all server
    communications through SSL:
    http://technet.microsoft.com/en-us/library/ms191192.aspx
    When we configure one server (let’s call it server A) to accept only encrypted connections (with Force Encryption=Yes) we still can connect from other server (let’s call it server B) that do not have the certificate installed. We would expect the server
    B to fail in the attempt of connect as server A should only accept encrypted communications and those should need the certificated to encrypt/decrypt everything (commands and data).
    We have also review the following forum post that is very similar to this one:
    http://social.msdn.microsoft.com/Forums/sqlserver/en-US/bde679d9-ff83-4fa7-b402-42e336a97106/force-encryption-on-sql-server-not-working
    In all cases the Microsoft answer is:
    “When the
    Force Encryption option for the Database Engine is set to YES, all communications between client and server is encrypted no matter whether the “Encrypt
    connection” option (such as from SSMS) is checked or not. You can check it using the following DMV statement”
    When we run the provided DMV statement to check if encryption is enabled:
    -- To check whether connections are encrypted between server and clients
    SELECT encrypt_option
    FROM sys.dm_exec_connections
    We get “TRUE”. So theoretically encryption is enabled.
    Then:
    Why can we run SQL statements against server A from server B (with SSMS) without any certificate?
    Are we wrong when we expect server A to refuse any client that do not have the right certificate?
    How can server B, without any certificate, decrypt the data encrypted by server A?
    Our intention is to encrypt all server in the same way so all of them will accept only encrypted communications. We are assuming that the Merge Agent will be able to communicate with the Publisher and the Subscriber through this encrypted environment. May
    anyone please confirm ti?
    Thanks for your help.
    Best Regards
    Benjamin Moles

  • Sql is not working after changing from MsAccess into sql server

    Following Sql  is not working after changing from MsAccess into sql server. 
    sum(trn.sales) as sales,
    sum(trn.cost) as cost,
    sales - cost as profit // Here is not working . can we not use sales a column. Please advise
    from trn
    Kind Regards
    pol
    polachan

    It will not work if use two different column from the table or column  from two  different table
    Example
    sum(trn.sales * trn.rate) as salesAmount,
    sum(trn.cost) as cost,
    sum(trn.salesAmount)-sum(trn.cost) as profit ----- Here is not working . can we not use sales a column. Please advise
    from trn
    Regards
    polachan

  • Condition not working

    Hi all the is code i have used
    DECLARE     
         CURRENTRECORD NUMBER;     
    BEGIN
    DECLARE
                   CURRENT_DISCOUNT NUMBER;
                   CURRENT_REASON VARCHAR2(100);
    BEGIN
    CURRENT_DISCOUNT:=:XXSY_DISCOUNT_MANAGER_V.DISCOUNT_RATE;
                   CURRENT_REASON:=:XXSY_DISCOUNT_MANAGER_V.DISCOUNT_REASON;     
                   CURRENTRECORD :=:SYSTEM.CURSOR_RECORD;
                   IF :XXSY_DISCOUNT_MANAGER_V.DISCOUNT = 'Y' THEN
                   FIRST_RECORD;
                   WHILE TRUE LOOP
              :XXSY_DISCOUNT_MANAGER_V.DISCOUNT_RATE:= CURRENT_DISCOUNT;
              :XXSY_DISCOUNT_MANAGER_V.DISCOUNT_REASON:= CURRENT_REASON;
                   IF :System.Last_Record = 'TRUE' THEN     
              :XXSY_DISCOUNT_MANAGER_V.DISCOUNT_RATE:=CURRENT_DISCOUNT;
              :XXSY_DISCOUNT_MANAGER_V.DISCOUNT_REASON:=CURRENT_REASON;
    EXIT;
    ELSE
         NEXT_RECORD;
    END IF;
    END LOOP;
    END IF;                
         END;
    END;
    it is not working properly,for record to record values is changing.for 1st record it is ok ,2nd record itis dispalying 1st record like that..
    plss help me in this condition
    Rgards
    Siva

    DECLARE
    CURRENTRECORD NUMBER;
    CURRENT_DISCOUNT NUMBER;
    CURRENT_REASON VARCHAR2(100);
    BEGIN
    CURRENT_DISCOUNT:=:XXSY_DISCOUNT_MANAGER_V.DISCOUNT_RATE;
    CURRENT_REASON:=:XXSY_DISCOUNT_MANAGER_V.DISCOUNT_REASON;
    CURRENTRECORD :=:SYSTEM.CURSOR_RECORD;
    IF :XXSY_DISCOUNT_MANAGER_V.DISCOUNT = 'Y' THEN
    FIRST_RECORD;
    LOOP
    :XXSY_DISCOUNT_MANAGER_V.DISCOUNT_RATE:= CURRENT_DISCOUNT;
    :XXSY_DISCOUNT_MANAGER_V.DISCOUNT_REASON:= CURRENT_REASON;
    EXIT WHEN :SYSTEM.LAST_RECORD='TRUE';
    NEXT_RECORD;
    END LOOP;
    END IF;
    END;
    Is the condition ":XXSY_DISCOUNT_MANAGER_V.DISCOUNT " true for more than 1 record....??????
    Is there any error....?????
    Are there displayed in your block more than one record...?????
    Transform the above code and execute it in sql plus..... as db procedure..... Are the results as expected....?????
    Greetings,
    Simon

  • Date Condition Not Working ,Value not cming in to item.

    Hi Friends,
    i have create a form for palce order and i have create a MASTER table for fixed item Rate between two date with price code like A,B,C,D .
    In Form i have for Item
    :P1_ORDER_DATE
    :P1_ITEM_CODE
    :P1_PRICE_CATEGORY Select List With Submit
    :P1_ITEM_RATE
    In Item rate i have put in Source ,
    Source Type --SQL Quary
    Source Vale
    select RATE_1 from SAM_ITEM_MAS where ITEM_CODE =:P1_ITEM_CODE and  PRICE_CATEGORY=:P1_PRICE_CATEGORY and :P1_ORDER_DATE
    between FROM_DATE and TO_DATEMy Table
    CREATE TABLE  "SAM_ITEM_MAS"
       (     "ID" NUMBER NOT NULL ENABLE,
         "ITEM_CODE" NUMBER,
         "PRICE_CATEGORY" VARCHAR2(5),
         "FROM_DATE" DATE,
         "TO_DATE" DATE,
         "RATE_1" NUMBER,
         CONSTRAINT "SAM_ITEM_MAS_PK" PRIMARY KEY ("ID") ENABLE
    /that code's not working but if i run this code in to SQL Command Then it's work fine.but not in to ITEM :P1_ITEM_RATE .
    i want when i select P1_PRICE_CATEGORY Like A,B,C,D then Respective Rate from Table SAM_ITEM_MAS should come in to item :P1_ITEM_RATE .
    Oredr date condition is not working.
    Thanks
    Edited by: 805629 on Dec 28, 2010 11:32 PM

    Hi,
    Have you tried casting the item values as dates using TO_DATE():
    select RATE_1
    from SAM_ITEM_MAS
    where ITEM_CODE =:P1_ITEM_CODE
    and  PRICE_CATEGORY=:P1_PRICE_CATEGORY
    and TO_DATE(:P1_ORDER_DATE,'DD/MM/YYYY') between "FROM_DATE" AND "TO_DATE"(change the date format string to match the format of the P1_ORDER_DATE page item)
    You should probably change the name of the field to something other than TO_DATE as this is an Oracle function name - try DATE_FROM and DATE_TO or START_DATE and END_DATE or something like that. Otherwise you may have to use the double-quotes as I have shown above
    Andy

  • Select condition not work, possible mistake

    I have simple select like
    String sStatus=req.getParameter("processStatus")==null?"":req.getParameter("processStatus");
    I can get the value of
    sStatus
    but my else is not working, what is the possible mistake?
    if(sStatus.equals("#"))
    Sql+=" and basicStatus=1 order by family_income asc ";                              
    else
    Sql+=" and basicStatus=1 and ProcessStatus='"+sStatus+ "' order by family_income asc ";                         
    I try sql in db db like and basicStatus=1 and ProcessStatus='"New' order by family_income asc      it work fine, so??
    Thank you

    Hi jverd,
    thank you fot the reply, but before I only nedd to executeQuery my sql once, but, if I use PreparedStatement, then I have to
    executeQuery as many as the conditions I have , any way, right now I change my code to
    String Sql="SELECT * FROM student2 as s, student_financial_info2 as f where s.student_id=f.student_id ";
                    //search for Id, so we don't care about status and how many row in one page
                    if (university_ID !=""){                   
                              Sql+=" and s.student_id=? order by family_income asc ";
                              ps = conn.prepareStatement(Sql);
                              ps.setString(1,university_ID );
                              ps.executeUpdate();
                              connectionPool.returnConnection(conn);
                    //for group search
                    else{
                       if(search.equals("All")){              
                            if(basicStatus.equals("basicStatus"))                     
                                 Sql+=" and ProcessStatus=? and basicStatus=? order by family_income asc ";
                                          Sql+=" limit " + currentRow + ",100"; 
                                          ps = conn.prepareStatement(Sql);
                                             ps.setString(1, FStatus);
                                             ps.setInt(2,1);
                                             ps.executeUpdate();
                                             connectionPool.returnConnection(conn);        
                       //for department search
                        else{
                            if(basicStatus.equals("basicStatus")){
                              Sql+=" and faculty =? and ProcessStatus=? and basicStatus=? order by family_income asc";
                              ps = conn.prepareStatement(Sql);
                              ps.setString(1,  search);
                               ps.setString(2, FStatus);
                               ps.setInt(3,1);
                               ps.executeUpdate();
                                connectionPool.returnConnection(conn);}
                            else{
                              Sql+=" and faculty ='"+search+ "' order by family_income asc";
                              ps = conn.prepareStatement(Sql);
                              ps.setString(1,  search);
                              ps.executeUpdate();                 
                                connectionPool.returnConnection(conn);
                    }// out elseI get error on String Sql="SELECT * FROM student2 as s, student_financial_info2 as f where s.student_id=f.student_id ";
              //search for Id, so we don't care about status and how many row in one page
              if (university_ID !=""){                   
                        Sql+=" and s.student_id=? order by family_income asc ";
                        ps = conn.prepareStatement(Sql);
                        ps.setString(1,university_ID );
                        ps.executeUpdate();
                        connectionPool.returnConnection(conn);
              //for group search
              else{
              if(search.equals("All")){              
                   if(basicStatus.equals("basicStatus"))               
                        Sql+=" and ProcessStatus=? and basicStatus=? order by family_income asc ";
    *                    Sql+=" limit " + currentRow + ",100";*
    *                    ps = conn.prepareStatement(Sql);*
    *                                   ps.setString(1, FStatus);*
    *                                   ps.setInt(2,1);*
    *                                   ps.executeUpdate();*
    *                                   connectionPool.returnConnection(conn);*
              //for department search
              else{
                   if(basicStatus.equals("basicStatus")){
              Sql+=" and faculty =? and ProcessStatus=? and basicStatus=? order by family_income asc";
                   ps = conn.prepareStatement(Sql);
                   ps.setString(1, search);
                        ps.setString(2, FStatus);
                        ps.setInt(3,1);
                        ps.executeUpdate();
                        connectionPool.returnConnection(conn);}
                   else{
                   Sql+=" and faculty ='"+search+ "' order by family_income asc";
                   ps = conn.prepareStatement(Sql);
                   ps.setString(1, search);
                   ps.executeUpdate();           
                        connectionPool.returnConnection(conn);
              }// out else
    I got error on the blod part JDBC error:Parameter index out of range (1 > number of parameters, which is 0).
    java.sql.SQLException: Parameter index out of range (1 > number of parameters, w
    hich is 0). How com the index is start on 0?
    Thank you

  • Insert SQL does not work properly when called using CALL

    I have a stored procedure (TEST_SP) which is used to insert a record in this perticular case. The SQL statement is 2526 characters long. I'm using
    dim Params : Params=chr(1) & "Insert query" & Chr(1) & "=300"
    runsql=&"{call TEST_SP(?,?)}"&Params 
    dim db : db=dbSelect("",0,"","")
    dbExecSQL db,runsqlto execute the stored procedure. I'm facing an issue when the 2000th character on the insert SQL (pUPDSQL) is a single quote, where the SQL is not getting executed (i.e. record is not getting created).
    The same stored procedure and the same SQL when run as below
    runsql=runsql&"DECLARE "
    runsql=runsql&"PUPDSQL VARCHAR2(4000); "
    runsql=runsql&"PRES VARCHAR2(300); "
    runsql=runsql&"BEGIN "
    runsql=runsql&"PUPDSQL := 'INSERT query..."
    runsql=runsql&"PRES:=300; "
    runsql=runsql&"MRT_LKIDFULUP(PUPDSQL => PUPDSQL,PRES => PRES); "
    runsql=runsql&"END; "
    dim db : db=dbSelect("",0,"","")
    dbExecSQL db,runsqlis working fine. Does anyone know if there is a limitaion in ODBC Call function or any explanation to above behaviour? I'm connecting to a Oracle 11g database using Microsoft ODBC for Oracle driver on Window 7
    The stored procedures:
    create or replace procedure TEST_SP(pUPDSQL IN VARCHAR2,pRES OUT VARCHAR2)
    AS
    BEGIN
    DECLARE
      emsg VARCHAR2(100);
    BEGIN
    if pUPDSQL&lt;&gt;'-1' then
      emsg:='Cant exec UPDATE';
      EXECUTE IMMEDIATE pUPDSQL;
        if SQL%RowCount=0 then
        pRES:='ERR:No row updated';
        return;
      end if;
    end if;
    pRES:='OK:';
    EXCEPTION
      WHEN OTHERS THEN
       pRES:='ERR:' || emsg;
    END;
    END;Edited by: BluShadow on 11-Dec-2012 15:47
    added {noformat}{noformat} tags for readability.  Please read {message:id=9360002} and learn to do this yourself in future.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

    ... I'm facing an issue when the 2000th character on the insert SQL (pUPDSQL) is a single quote, ...Perhaps you need two single quotes? like:
    runsql=runsql&"PUPDSQL := 'INSERT query...Values(..,..,,,''This value in two single quotes'',..,...)' "
    ... I'm connecting to a Oracle 11g database using Microsoft ODBC ...Dump windoze ODBC and better use the Oracle client ODBC.
    :p

  • Date condition not working correctly in Desktop

    Hello,
    I have two custom folders in Admin that are joined. One of the folders contains the following query:
    SELECT ORGANIZATION_ID, ASSET_NUMBER, MIN(CURRENT_READING_DATE) FIRST_READ_DATE, MIN(CURRENT_READING) FIRST_READING
    FROM EAM_METER_READINGS_V
    WHERE PREV_DESC IS NULL
    Group By ORGANIZATION_ID, ASSET_NUMBER
    I want my workbook to report the earliest meter reading that exists, based on the date that is specified in the parameters in Desktop. When I create a parameter for the date, the workbook reports the earliest reading in the database; it ignores the date restriction entered in the parameter. This is the parameter:
    First Read Date MIN BETWEEN :First Reading Date and SYSDATE
    If I include the date condition in the SQL of the custom folder the workbook functions exactly as it should. The date condition is in the SQL as the following:
    and current_reading_date between '01-JAN-2007' and SYSDATE
    Since the workbook functions correctly when the condition is coded in the SQL but not when it is based on a parameter, I assume the problem is with the parameter. Any ideas on how I may correct this?
    Thanks,
    Steve

    Thanks for the response Michael. I tried using the MIN function as you suggested, but I still am not getting the expected result. I’m not sure that I was clear in my initial problem description. I will try to provide more detail with this post.
    The reason I have two custom folders is that my original query has a nested Select statement (EAMV) and I couldn’t find a way to pass the parameter from EAMV to Discoverer. Following is the original query. I suppose the first logical questions would be, is there a way to pass the parameter to Discoverer? Would this alleviate the need for the second custom folder?
    SELECT K.ORGANIZATION_CODE "ORG" -- ORGANIZATION
    , K.ORGANIZATION_ID
    ,A.NAME "PM SCHEDULE NAME" -- PREVENTIVE MAINTENANCE SCHEDULE NAME
    --( (B.RUNTIME_INTERVAL/F.USER_DEFINED_RATE) + D.LAST_SERVICE_END_DATE) "PROJECTED READ DATE" -- USES USER_DEFINED_RATE FROM METER DEFINITION
    ,(C.LAST_SERVICE_READING + B.RUNTIME_INTERVAL) "PROJECTED READ UNITS" -- NEXT SERVICE READING DUE UNITS
    ,F.METER_UOM "UOM" -- UNIT OF MEASURE ON METER
    ,F.METER_NAME "METER NAME" -- METER NAME
    ,G.SERIAL_NUMBER "MAINT EQ NO" -- MAINTAINED EQUIPMENT NUMBER
    ,H.C_ATTRIBUTE1 "MAKE" -- MAINTAINED EQUIPMENT NUMBER - MAKE/MANUFACTURER
    ,H.C_ATTRIBUTE2 "MODEL" -- MAINTAINED EQUIPMENT NUMBER - MODEL
    ,H.C_ATTRIBUTE4 "SERIAL NO" -- MAINTAINED EQUIPMENT NUMBER - SERIAL NUMBER
    ,I.SEGMENT1 "ACTIVITY" -- ASSET ACTIVITY
    ,D.LAST_SERVICE_END_DATE "LAST READ DATE" -- DATE OF LAST PM SERVICE READING
    ,C.LAST_SERVICE_READING "LAST READ UNITS" -- UNITS OF LAST PM SERVICE READING
    ,E1.CURRENT_READING_DATE "CURRENT READ DATE" -- DATE OF CURRENT SERVICE READING (FROM METER FORM)
    ,E1.CURRENT_READING                                   "CURRENT READ UNITS" -- UNITS OF CURRENT SERVICE READING (FROM METER FORM)
    ,E1.LIFE_TO_DATE_READING "LIFE TO DATE READING" LIFE TO DATE READING
    --,(E1.CURRENT_READING - C.LAST_SERVICE_READING) "CURRENT/LAST VARIANCE" -- UNITS SINCE LAST PM SERVICE READING
    ,( (C.LAST_SERVICE_READING + B.RUNTIME_INTERVAL) - E1.CURRENT_READING ) "PROJECTED/CURR VARIANCE" -- UNITS REMAINING UNTIL NEXT SCHEDULED READING
    ,J.DESCRIPTION "LOCATION" -- OWNING DEPARTMENT DESCRIPTION OF ASSET NUMBER
    ,J.DEPARTMENT_CODE
    ,E1.DISABLE_FLAG
    ,G.CURRENT_STATUS
    ,B.RUNTIME_INTERVAL
    ,Y.SET_NAME
    ,EAMV.FIRST_READ_DATE READ_DATE
    ,EAMV.FIRST_READING READING
    FROM EAM.EAM_PM_SCHEDULINGS A
    ,EAM.EAM_PM_SCHEDULING_RULES B
    ,EAM.EAM_PM_LAST_SERVICE C
    ,INV.MTL_EAM_ASSET_ACTIVITIES D
    ,EAM.EAM_ASSET_METERS E
    ,EAM.EAM_METER_READINGS E1
    ,EAM.EAM_METERS F
    ,INV.MTL_SERIAL_NUMBERS G
    ,INV.MTL_EAM_ASSET_ATTR_VALUES H
    ,INV.MTL_SYSTEM_ITEMS_B I
    ,BOM.BOM_DEPARTMENTS J
    ,INV.MTL_PARAMETERS K
    ,EAM.EAM_PM_SET_NAMES Y
         ,(SELECT ORGANIZATION_ID, ASSET_NUMBER, MIN(CURRENT_READING_DATE) FIRST_READ_DATE, MIN(LIFE_TO_DATE_READING) FIRST_READING
              FROM EAM_METER_READINGS_V
              WHERE CURRENT_READING_DATE BETWEEN '01-JAN-2007' AND '30-JUN-2007'
              GROUP BY ORGANIZATION_ID, ASSET_NUMBER) EAMV
    WHERE A.PM_SCHEDULE_ID = B.PM_SCHEDULE_ID
    AND A.ACTIVITY_ASSOCIATION_ID = C.ACTIVITY_ASSOCIATION_ID
    AND C.ACTIVITY_ASSOCIATION_ID = D.ACTIVITY_ASSOCIATION_ID
    AND D.SERIAL_NUMBER = E.ASSET_NUMBER
    AND D.ORGANIZATION_ID = E.ORGANIZATION_ID
    AND E.METER_ID = E1.METER_ID
    AND E1.METER_READING_ID =
    (SELECT MAX(METER_READING_ID)
    FROM EAM_METER_READINGS
    WHERE METER_ID = E1.METER_ID
    AND (DISABLE_FLAG = 'N' OR DISABLE_FLAG IS NULL))
    AND E.METER_ID = C.METER_ID
    AND E.METER_ID = B.METER_ID
    AND E.METER_ID = F.METER_ID
    AND D.MAINTENANCE_OBJECT_ID = G.GEN_OBJECT_ID
    AND D.ORGANIZATION_ID = G.CURRENT_ORGANIZATION_ID
    AND G.SERIAL_NUMBER = H.SERIAL_NUMBER
    AND G.CURRENT_ORGANIZATION_ID = H.ORGANIZATION_ID
    AND D.INVENTORY_ITEM_ID = H.INVENTORY_ITEM_ID
    AND H.ATTRIBUTE_CATEGORY = 'EQUIPMENT DETAILS'
    AND D.ASSET_ACTIVITY_ID = I.INVENTORY_ITEM_ID
    AND D.ORGANIZATION_ID = I.ORGANIZATION_ID
    AND G.OWNING_DEPARTMENT_ID = J.DEPARTMENT_ID (+)
    AND I.ORGANIZATION_ID = K.ORGANIZATION_ID
    AND A.SET_NAME_ID = Y.SET_NAME_ID
    AND Y.SET_NAME IN ('MAIN','COMP')
    AND G.CURRENT_ORGANIZATION_ID = EAMV.ORGANIZATION_ID
    AND G.SERIAL_NUMBER = EAMV.ASSET_NUMBER
    AND K.ORGANIZATION_CODE = 'MCC'
    Using this query I want to show the most recent reading (current reading) and then give users the flexibility to enter an earlier date so the earliest reading as of that date will also show. For example, if they enter 1-JAN-2007 as the parameter and there was a reading taken on 2-JAN-07 and 28-JAN-07, the report should show the 2-JAN-2007 reading (in addition to the most recent reading in a separate column). Currently, everything on the report displays correctly, except for the reading based on the parameter.

  • PL/SQL program not working when connect database via SqlNet

    Hi,
    This is a segment of a PL/SQL program before opening a cursor using input descriptor. It is working fine ( to get the value of unOutputCount ) without connect to a database via SqlNet, can anyone tell me why it is not working ( unOutputCount return 0)while connecting to a database via SqlNet and how to make it work without opening a cursor before DESCRIBE OUTPUT ...?
    EXEC SQL ALLOCATE DESCRIPTOR GLOBAL 'input_111'
    WITH MAX 100;
    EXEC SQL ALLOCATE DESCRIPTOR GLOBAL 'output_111'
    WITH MAX 100;
    EXEC SQL PREPARE STMT1 FROM :psSqlStatement;
    EXEC SQL DECLARE CURSOR1 CURSOR FOR STMT1;
    EXEC SQL DESCRIBE INPUT STMT1
    USING DESCRIPTOR GLOBAL 'input_111';
    /* Get count of input parameters in statement */
    EXEC SQL GET DESCRIPTOR GLOBAL 'input_111' :unInputCount = COUNT;
    EXEC SQL DESCRIBE OUTPUT STMT1
    USING DESCRIPTOR GLOBAL 'output_111';
    /* Get count of output parameters in statement */
    EXEC SQL GET DESCRIPTOR GLOBAL 'output_111'
    :unOutputCount = COUNT;

    Hi,
    Welcome to Oracle OTN Forums!
    I changed your code a little. I think this help you
    CREATE OR REPLACE
    PROCEDURE xx_test
    IS
      v_pid VARCHAR2(100);
      v_cn  VARCHAR2(100);
      v_id  VARCHAR2(1000);
      v_val VARCHAR2(1000);
      CURSOR C1
      IS
        (SELECT product_id, 'PRODUCT_ID'  cn
            FROM product1 );
      BEGIN
        FOR V1 IN C1
        LOOP
          FETCH C1 INTO v_pid, v_cn;
          dbms_output.put_line('==== '||v_pid||'==== '||v_cn);
          EXECUTE IMMEDIATE
          'SELECT product_id, DECODE(COUNT (product_id),1,MAX (product_id))||'''||V_CN||''' as val
            FROM product1
           WHERE product_id =:a
           GROUP BY product_id)' INTO v_id, v_val USING v_pid;
          dbms_output.put_line('==== '||v_id||'==== '||v_val);
          EXECUTE IMMEDIATE 'UPDATE product2 SET '||v_cn||' = ' ||''''|| v_val ||''''|| ' WHERE product_id = :b' USING v_pid;
          dbms_output.put_line('++++ '||v_cn||'++++ '||v_val||'++++ '||v_pid);
        END LOOP;
      END xx_test;

  • My first PL/SQL block not working with using Select query within begin

    I am new to PL/SQL , just started with basics of BLOCKS .
    I am having a query here in executing a block .
    When i am doing a insert oprtation in Blocks Begin method everything is working fine , but when ever i tried to do select operation , some error is being thrown .
    First of all This is my Table :
    select from try :*
    KEY      VALUE
    Key     Value
    Key1     Value1
    Key2     Value2
    Key3     Value3
    ======================
    This is the code which is not working : Please see the code and tell me what is the problem .
    DECLARE
    v_KEY    VARCHAR2(20);
    v_VALUE   VARCHAR2(20);
    BEGIN
    select key into v_KEY FROM try where v_value='Value' ;
    dbms_output.put_line(v_KEY);
    END;
    When i run this code , it is saying Data Not Found on this line " select key into v_KEY FROM try where v_value='Value' ;"
    wheer when i run tis individually it worked fine :
    select KEY FROM try where VALUE='Value' ;"
    please share your ideas .as why it isn't running ??
    Edited by: user10503747 on Sep 20, 2010 3:16 AM

    Hi,
    user10503747 wrote:
    I am new to PL/SQL , just started with basics of BLOCKS .
    I am having a query here in executing a block .
    When i am doing a insert oprtation in Blocks Begin method everything is working fine , but when ever i tried to do select operation , some error is being thrown .
    First of all This is my Table :
    select from try :*
    KEY      VALUE
    Key     Value
    Key1     Value1
    Key2     Value2
    Key3     Value3
    ======================
    This is the code which is not working : Please see the code and tell me what is the problem .
    DECLARE
    v_KEY    VARCHAR2(20);
    v_VALUE   VARCHAR2(20);
    BEGIN
    select key into v_KEY FROM try where v_value='Value' ;
    dbms_output.put_line(v_KEY);
    END;
    When i run this code , it is saying Data Not Found on this line " select key into v_KEY FROM try where v_value='Value' ;"
    wheer when i run tis individually it worked fine :
    select KEY FROM try where VALUE='Value' ;"
    please share your ideas .as why it isn't running ??
    Edited by: user10503747 on Sep 20, 2010 3:16 AMInstead of:
    {code}
    select key into v_KEY FROM try where v_value='Value' ;
    {code}
    perhaps you meant something like:
    {code}
    v_value := 'Value1';
    select key into v_KEY FROM try where v_value=Value ; -- No quotes
    {code}
    Until you assign a vlue to a variable, like v_value, it is NULL, so your original statement was equivalent to
    {code}
    select KEY FROM try where NULL='Value' ;
    {code}
    In PL/SQL, a SELECT ... INTO statement must return exactly one row, or else you will get an error (either NO_DATA_FOUND or TOO_MANY_ROWS). This is different from SQL, where a query cn return any number of rows, including 0, without raising an error.

  • IF-condition not working in sap script??????

    hi,
       i am trying to chk one condition in sap script using if statement....but it is not working at all.
      statement i am writing is :-
    /:   IF &IST_ITEM-SAD_PRINT& <>  0
    p7 ,,,,,,,,,,,,,,,,SAD,, 4.00  &IST_ITEM-SAD_PRINT&
    /:   ENDIF
    value for IST_ITEM-SAD_PRINT is coming as it is shown while debuging .
    eventhen control is going inside if statement independent from the value of IST_ITEM-SAD_PRINT
    how to use if statement properly....
    regards
    Deepak

    Hi,
    Declare a dummy variable of type IST_ITEM-SAD_PRINT and then use that variable in sapscript..
    Ex..
    <b>Print program</b>
    DATA: V_DUMMY LIKE IST_ITEM-SAD_PRINT.
    <b>Sap script</b>
    /: IF &IST_ITEM-SAD_PRINT& <> <b>&V_DUMMY&</b>
    p7 ,,,,,,,,,,,,,,,,SAD,, 4.00 &IST_ITEM-SAD_PRINT&
    /: ENDIF
    Thanks,
    Naren

  • Inline transform for Sql Query not working in SAP MII 12.1 Version 12.1.8 B

    Hi All,
    I applied an xslt for an sql query which returns an xml file.
    I used inline transform icon in sql query to load an xsl file which has to return me a string
    Any idea why is not working for me..?
    My Sample XML file:
                                     <?xml version="1.0" encoding="UTF-8"?>
    <?xml-stylesheet type="text/xsl" href="/XMII/CM/BatchDisposition/BatchQueueManagement/StyleSheets/ProductXsl.xsl"?>
    <Rowsets DateCreated="2011-05-05T07:27:45" EndDate="2011-05-05T07:27:45" StartDate="2011-05-05T06:27:45" Version="12.1.8 Build(20)">
         <Rowset>
              <Columns>
                   <Column Description="ProductName" MaxRange="1" MinRange="0" Name="ProductName" SQLDataType="12" SourceColumn="ProductName"/>
              </Columns>
              <Row>
                   <ProductName>Asprin 100mg Tablets 12 x10 strip</ProductName>
              </Row>
              <Row>
                   <ProductName>Asprin 300mg Tablets 12 x10 strip</ProductName>
              </Row>
              <Row><ProductName>Ibprooven 200mg Tablets 12 x 10 strip</ProductName></Row>
              <Row><ProductName>RipTide 50mg Tablets 40 x10 strip</ProductName></Row>
              <Row><ProductName>Seroquel 200mg Tablets 6 x10 strip</ProductName></Row>
              <Row><ProductName>Seroquel 400mg Tablets 12 x10 strip</ProductName></Row>
         </Rowset>
    </Rowsets>
    My Sample XSl File:
                                    <?xml version="1.0" encoding="ISO-8859-1"?>
    <xsl:stylesheet version="1.0"
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:template match="/">
         <xsl:text>["</xsl:text>
         <xsl:for-each select="Rowsets/Rowset/Row">
              <xsl:value-of select="ProductName"/>
              <xsl:if test="position() &lt; last()">
                   <xsl:text>","</xsl:text>
                    </xsl:if>
              <xsl:if test="position()=last()">
                           <xsl:text>"]</xsl:text>
                    </xsl:if>
         </xsl:for-each>
    </xsl:template>
    </xsl:stylesheet>
    Any Suggestions  are Welcome:
    Thanks

    Something like this should work...
    <?xml version="1.0" encoding="UTF-8"?>
    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
         <xsl:template match="/">
              <Rowsets DateCreated="{Rowsets/@DateCreated}" Version="{Rowsets/@Version}" StartDate="{Rowsets/@StartDate}" EndDate="{Rowsets/@EndDate}">
                   <xsl:copy-of select="/Rowsets/FatalError"/>
                   <xsl:copy-of select="/Rowsets/Messages"/>
                   <Rowset>
                   <Columns>
                        <Column Description="Mycol1" MaxRange="1" MinRange="0" Name="Mycol1" SQLDataType="12" SourceColumn="Mycol1" />
                   </Columns>
                   <Row>
                   <Mycol1>
                   <xsl:text>["</xsl:text>
                        <xsl:for-each select="/Rowsets/Rowset/Row">
                             <xsl:value-of select="." />
                             <xsl:choose>
                                  <xsl:when test="position() &lt; last()"><xsl:text>","</xsl:text></xsl:when>
                                  <xsl:otherwise><xsl:text>"]</xsl:text></xsl:otherwise>
                             </xsl:choose>
                        </xsl:for-each>
                   </Mycol1>
                   </Row>
                   </Rowset>
              </Rowsets>
         </xsl:template>
    </xsl:stylesheet>

  • Custom Pricing Conditions not working for a PO in SRM

    Hi Experts,
    We are on SRM 5.0, ECC 6.0 , Extended Classic Scenario.
    We configured the pricing conditions in SRM . We defined the our custom pricing condition types as below
    Condition type      ---  Condition Class       ---  Calculation Type
    Frieght(%)            ---       Prices                ---      Percentage
    Frieght Value       ---        Prices                ---  Fixed Amount
    We also defined the Calculation Schema.
    But when we try to define the pricing conditions in SRM during PO creation\change , the standard pricing condition types work but when we input the above defined custom pricing condition type, the value entered gets cleared. Pricing Overview is not calculating the values of the custom Pricing condition types.
    Please assist as where i have gone wrong. Do I need to run any standard report for pricing or do i have to implement any BADI.
    Thanks,
    Addy.

    Hi Sanjeev,
    I have run SM52 and VMC is active with 4 VM's .
    Please suggest.
    Thanks,
    Addy.
    Edited by: Addy1209 on Nov 18, 2010 4:28 PM

Maybe you are looking for

  • Xperia Z1 Compact D5503 14.3.A.0.757 upgrade experience

    hi all, I just want to share my experience with the latest build version 14.3.A.0.757 which has become available in Austria on Friday, 18th of April 2014. Friday afternoon an OTU I installed the update to Android 4.4.2 which automatically was suggest

  • CONTENT SERVER SETUP ON ORACLE 10G IAS (10.1.3) oracle E-business R12.1.1

    Hi Experts, Quick one - I have been requested to Integrate the CONTENT SERVER SETUP ON ORACLE 10G IAS (10.1.3) with oracle E-business SUit R12.1.1. Please also let me know do we have to apply any patches on the E-business Suit for Integrating Oracle

  • ERROR IN REBATE

    while settlement of rebate getting error "Th sales volume is not current". Please help.

  • Conversion of Julian date to YYYYMMDD

    Hi, The flat file has the date in Julian date format YYYYDDD. How to load it into infoprovider in the format YYYYMMDD? Thanks.

  • How to apply in other schema

    Hello, Is it possible to apply the transactions in another schema than which is captured? E.g. capture HR.EMPLOYEES and then apply the DML/DDL on SCOTT.EMPLOYEES. Thanx in advantage! Leo.