Date without single quotes in SQL Where clause turns to 00000000. Why?

The below program works in 4.6c but does not in ECC 6.0, the issue is the date actually turns to 00000000, debug shows the internal table as having the correct value that was inserted but st05 trace shows that the variable is holding the value 00000000, this works fine when the date is put inside single quotes but the actual program where I have this issue does not warrant adding single quotes. Has someone come across this situation. Any help is appreciated!
data v_vbeln like vbak-vbeln.
data: begin of where_tab occurs 0,
      s_date(20) type c,
      end of where_tab.
where_tab-s_date = 'audat = 19971106'.
append where_tab.
select vbeln into v_vbeln from vbak where (where_tab).
  write:/ v_vbeln.
endselect.

HI,
data v_vbeln like vbak-vbeln.
******data: begin of where_tab occurs 0,
******s_date(20) type c,
******end of where_tab.
******where_tab-s_date = 'audat = 19971106'.
******append where_tab.
***** The above statements are not needed for the select query.
******select vbeln into v_vbeln from vbak where (where_tab).
Your select query can be re-written as
select vbeln into v_vbeln from vbak where audat eq '19971106'.
write:/ v_vbeln.
endselect.
and if your requirement is to check for multiple dates then,
append them to a select-options and rewrite the select query as
select vbeln into v_vbeln from vbak where audat IN S_DATE. " S_DATE is your select-options
Regards
Sharath

Similar Messages

  • Dynamic SQL and Data with Single Quotes in it.

    Hi There,
    I have a problem in that I am using dynamic SQL and it happens that one of the columns does contain single quotes (') in it as part of the data. This causes the resultant dynamic SQL to get confused as the single quote that is part of the data is taken to mean end of sting, when in fact its part of the data. This leaves out a dangling single quote that was meant to enclose the string. Here is my dynamic SQL and the result of the parsed SQL that I have captured:
    ****Dynamic SQL*****
    l_sql:='select NOTE_TEMPLATE_ID '||
    'FROM TMP_NOTE_TEMPLATE_VALUES '||
    'where TRIM(LEGACY_NOTE_CODE)='''||trim(fp_note_code)||''' '||
    'and TRIM(DISPLAY_VALUE)='''||trim(fp_note_text)||''' ';
    execute immediate l_sql INTO l_note_template_id;
    Because the column DISPLAY_VALUE contains data with single quotes, the resultant SQL is:
    ******PARSED SQL************
    select NOTE_TEMPLATE_ID
    FROM TMP_NOTE_TEMPLATE_VALUES
    where TRIM(LEGACY_NOTE_CODE)='INQ' and TRIM(DISPLAY_VALUE)='Cont'd'
    And the problem lies with the single quote between teh characters t and d in the data field for DISPLAY_ITEM. How can I handle this?
    Many thanks,

    I have been reliably informed that if one doesn't enclose char/varchar2 data items in quotes, the right indices may not be usedI am into oracle for past 4 years and for the first time i am hearing this.
    Your reliable source is just wrong. Bind variables are variables that store your value and which are used in SQL. They are the proper way to use values in your SQL. By default all variables in PL/SQL is bind variable.
    When you can do some thing in just straight SQL just do it. Dynamic SQL does not make any sense to me here.
    Thanks,
    Karthick.

  • JSP, Data Web Bean, BC4J: Setting the where clause of a View Object at run time

    Hi,
    I am trying to develop a data web bean in which the where clause of a View Object will be set at run time and the results of the query then displayed.
    My BC4J components are located in one project while the coding for the data web bean is in another project. I used the following code bu t it does not work. Could you please let me know what I am doing wrong?
    public void populateOSTable(int P_EmpId)
    String m_whereString = "EmpView.EMP_ID = " + P_EmpId;
    String m_OrderBy = "EmpView.EMP_NAME";
    oracle.jbo.ApplicationModule appModule = null;
    ViewObject vo = appModule.findApplicationModule("EMPBC.EMPAppModule").findViewObject("EMPBC.EMPView");
    vo.setWhereClause(m_whereString);
    vo.setOrderByClause(m_OrderBy);
    vo.executeQuery();
    vo.next();
    String empName numAttrs = vo.getAttribute(EmpName);
    System.out.println(empName);
    Thanks.

    <BLOCKQUOTE><font size="1" face="Verdana, Arial">quote:</font><HR>Originally posted by JDev Team (Laura):
    Here is how I have usually done mine:
    1. In the JSP, use a RowsetNavigator bean to set the where clause and execute the query.
    2. Use a custom web bean to process the results of the query (print to HTML).
    for example:
    <jsp:useBean class="oracle.jbo.html.databeans.RowsetNavigator" id="rsn" scope="request" >
    <%
    // get the parameter from the find form
    String p = request.getParameter("p");
    String s = request.getParameter("s");
    // store the information for reference later
    session.putValue("p", p);
    session.putValue("s", s);
    // initialize the app module and view object
    rsn.initialize(application,session, request,response,out,"wt_bc_WT_bcModule.wtjoinView");
    // set the where clause string
    String theclause = "presname = '" + p + "' AND slideno=" + s;
    // set the where clause for the VO
    rsn.getRowSet().getViewObject().setWhereClause(theclause);
    rsn.getRowSet().getViewObject().executeQuery();
    rsn.getRowSet().first();
    %>
    </jsp:useBean>
    <jsp:useBean class="wt_bc.walkthruBean" id="wtb" scope="request" >
    <%
    // initialize the app module and VO
    wtb.initialize(application,session, request,response,out,"wt_bc_WT_bcModule.wtjoinView");
    wtb.render();
    %>
    In this case, the render method of my custom web bean mostly gets some session variables, and prints various content depending on the session variable values.
    Hope this helps.
    </jsp:useBean><HR></BLOCKQUOTE>
    Laura can you give the code of your walkthru bean? i wna't to initialize a viewobject, set the where clause and give that viewobject back to initialize my navigatorbar.
    Nathalie
    null

  • SQL Where clause when comparing dates and times in ASP

    Hello,
    I am trying to pull data from my database which is dependant on both the date and time in HH24 format. So, my where clause looks something like this:
    select * from thisTable where activity_time >= myCurrentDate
    (myCurrentDate is a variable that is built which gives it the following format DD-MON-YYYY HH24:MI:SS)
    So, the actual passed string to my call is:
    select * from thisTable where ACTIVITY_TIME >= '02-DEC-2008 18:22:00' order by ACTIVITY_TIME asc
    However, when calling this, I get the famous "ORA-01830: date format picture ends before converting entire input string"
    Can anyone please help me?!?!?!?
    Thanks in advance

    Enrique answered your immediate question, but I'd like to point up a broader issue, and that is that you should <b><u>always</u></b> use the TO_DATE and TO_CHAR functions at the sql statement level when working with date datatypes. That way you are never dependent on some default over which you have no control. I call that is 'defensive coding'.

  • How to use a single quote string in where condition

    Hi,
    I have one problem in building a query.
    SELECT agx_drug_indication.record_id, agx_drug_indication.fk_ad_rec_id,
    agx_drug_indication.drugindicationmeddraver, agx_drug.record_id,
    agx_drug.fk_apat_rec_id,
    REPLACE (agx_drug.medicinalproduct, '''', '''') AS "MEDICINALPRODUCT",
    pack_imp_objects.fn_get_arisg_code
    (147,
    agx_drug_indication.drugindicationmeddraver
    ) AS "DRUGINDICATIONMEDDRAVER",
    agx_drug.drugindication,
    NVL (agx_drug.drugcharacterization, 1) AS "DRUGCHARACTERIZATION",
    agx_safety_report.record_id, agx_safety_report.case_identifier_no,
    agx_safety_report.fk_apat_rec_id,
    pack_imp_objects.fn_meddra_llt_matching
    (agx_drug_indication.drugindication,
    agx_drug_indication.drugindication,
    agx_drug_indication.drugindicationmeddraver,
    1
    ) AS "LLT_CODE",
    pack_imp_objects.fn_meddra_soccode_matching
    (agx_drug_indication.drugindication,
    agx_drug_indication.drugindicationmeddraver
    ) AS "PRIMARY_SOC_CODE",
    pack_imp_objects.fn_meddra_soccode_matching
    (agx_drug_indication.drugindication,
    agx_drug_indication.drugindicationmeddraver
    ) AS "CASE_SOC_CODE",
    pack_imp_objects.fn_meddra_pt_matching
    (agx_drug_indication.drugindication,
    agx_drug_indication.drugindication,
    agx_drug_indication.drugindicationmeddraver
    ) AS "PT_CODE",
    pack_imp_objects.fn_get_aer_id (11) AS "AER_ID"
    FROM agx_drug_indication,
    agx_drug,
    agx_safety_report
    WHERE agx_drug_indication.fk_ad_rec_id = agx_drug.record_id
    AND agx_drug.fk_apat_rec_id = agx_safety_report.fk_apat_rec_id
    AND agx_safety_report.case_identifier_no IS NOT NULL
    AND agx_drug_indication.drugindication IS NOT NULL
    AND agx_drug.medicinalproduct =
    REPLACE ('*-qVAGX_DRUG.MEDICINALPRODUCT*', '''', '''')
    In the above query last line '-qVAGX_DRUG.MEDICINALPRODUCT' is a dynamic variable which may or may not contain the single quotes.
    Ex: ABC's or just ABC.
    The query has to support both single quote and without quote in it.
    I wanted everything to be done in the sinlq query on not a PL/SQL Block.
    Please help me ASAP

    kumar0828 wrote:
    <font color="#FF0000"> ... </font>
    REPLACE (agx_drug.medicinalproduct, '''', '''') AS "MEDICINALPRODUCT",
    <font color="#FF0000"> ... </font> <pre>
    REPLACE (agx_drug.medicinalproduct, '<font style="background-color: #E7FA6B">''</font>', '<font style="background-color: #E7FA6B">''</font>')
    </pre>
    With the above statement you are replacing single quote with another single quote
    (which is nonsense).
    <font color="#FF0000"> ... </font>
    AND agx_drug.medicinalproduct = REPLACE ('*-qVAGX_DRUG.MEDICINALPRODUCT*', '''', '''')
    In the above query last line '-qVAGX_DRUG.MEDICINALPRODUCT' is a dynamic variable which may or may not contain the single quotes.This is not a dynamic variable but a string value:
    <pre>
    AND agx_drug.medicinalproduct =
    REPLACE (<font style="background-color: #FF3D55">'*</font>-qVAGX_DRUG.MEDICINALPRODUCT<font style="background-color: #FF3D55">*'</font>, '<font style="background-color: #E7FA6B">''</font>', '<font style="background-color: #E7FA6B">''</font>')
    </pre>
    *-qVAGX_DRUG.MEDICINALPRODUCT* <pre>
    AND agx_drug.medicinalproduct =
    REPLACE (<font style="background-color: #FF3D55">q'*</font>-qVAGX_DRUG.MEDICINALPRODUCT<font style="background-color: #FF3D55">*'</font>, '<font style="background-color: #E7FA6B">''</font>', '<font style="background-color: #E7FA6B">''</font>')
    </pre>
    -qVAGX_DRUG.MEDICINALPRODUCT q'[a]' => a
    q'[a']' => a'
    q'[a'']' => a''
    q'*a*' => a
    q'*a'*' => a'
    q'*a''*' => a''
    A variable also cannot contain a dot (.):
    <pre>VAGX_DRUG<font style="background-color: #FF3D55">.</font>MEDICINALPRODUCT</pre>
    Ex: ABC's or just ABC.
    The query has to support both single quote and without quote in it.
    I wanted everything to be done in the sinlq query on not a PL/SQL Block.
    Please help me ASAPTry this:
    <pre>
    AND agx_drug.medicinalproduct = MY_VARIABLE
    </pre>

  • Exclude duplicate values on SQL where clause statement

    Hi!
    Are some posibilities to exclude duplicate values do not using sql aggregate functions in main select statement?
    Priview SQL statement
    SELECT * FROM
    select id,hin_id,name,code,valid_date_from,valid_date_to
    from diaries
    QRSLT
    WHERE (hin_id = (SELECT NVL(historic_id,id)FROM tutions where id=/*???*/ 59615))
    AND NVL(valid_date_to,to_date('22.12.2999','dd.mm.yyyy')) <= (SELECT NVL(valid_date_to,to_date('22.12.2999','dd.mm.yyyy'))FROM tutions where id= /*???*/ 59615)
    AND trunc(valid_date_from) >=(SELECT trunc(valid_date_from)FROM tutions where id= /*???*/ 59615)
    The result
    ID                  HIN_ID    NAME      CODE    VALID_DATE FROM                 VALID_DATE_TO    
    50512
    59564
    RE TU
    01
    07.06.2013 16:32:15
    07.06.2013 16:33:28
    50513
    59564
    TT2 
    02
    07.06.2013 16:33:23
    07.06.2013 16:33:28
    50515
    59564
    TT2 
    02
    07.06.2013 16:33:28
    07.06.2013 16:34:42
    50516
    59564
    ROD 
    03
    07.06.2013 16:34:37
    07.06.2013 16:34:42
    VALID_DATE_TO & AND VALID_DATE_FROM tutions
    07.06.2013 16:34:42
    15.07.2013 10:33:23
    In this case i got duplicate of entry TT2 id 50513  In main select statement cant use agregate functions are even posible to exclude this value from result modifying only the QLRST WHERE clause (TRUNC need to be here)
    THANKS FOR ANY TIP !
    ID.

    Hi, Ok this is working in this case
    SELECT * FROM
    select id,hin_id,name,code,valid_date_from,valid_date_to
    from diaries ahs
    QRSLT
    WHERE (hin_id = (SELECT NVL(historic_id,id)FROM aip_healthcare_tutions where id=/*???*/ 59615))
    AND NVL(valid_date_to,to_date('22.12.2999','dd.mm.yyyy')) <= (SELECT NVL(valid_date_to,to_date('22.12.2999','dd.mm.yyyy'))FROM tutions where id= /*???*/ 59615)
    AND trunc(valid_date_from) >=(SELECT trunc(valid_date_from)FROM tutions where id= /*???*/ 59615)
    AND NOT  EXISTS
    (SELECT null FROM diaries ahs WHERE  ahs.valid_date_from < QRSLT.valid_date_from
        AND QRSLT.hin_id=ahs.hin_id
        AND QRSLT.code=ahs.code);
    Result
    50512
    59564
    RE TU
    01
    07.06.2013 16:32:15
    07.06.2013 16:33:28
    50513
    59564
    TT2 
    02
    07.06.2013 16:33:23
    07.06.2013 16:33:28
    50516
    59564
    ROD 
    03
    07.06.2013 16:34:37
    07.06.2013 16:34:42
    But if the Data in tutions row  are theese(valid_date_to-null)  then NO ROWS are returning and its logical because in full result list Valid_date_from column are logical incorect
    valid_date_from                                 valid_date_to
    15.07.2013 10:33:23
    NULL
    ID                  HIN_ID    NAME      CODE    VALID_DATE FROM                 VALID_DATE_TO 
    50510
    59564
    RE TU
    01
    07.06.2013 16:33:28
    50511
    59564
    TT2 
    02
    07.06.2013 16:34:41
    50514
    59564
    ROD 
    03
    07.06.2013 16:34:41
    50520
    59564
    Params
    04
    03.07.2013 21:01:30
    50512
    59564
    RE TU
    01
    07.06.2013 16:32:15
    07.06.2013 16:33:28
    50513
    59564
    TT2 
    02
    07.06.2013 16:33:23
    07.06.2013 16:33:28
    50515
    59564
    TT2 
    02
    07.06.2013 16:33:28
    07.06.2013 16:34:42
    50516
    59564
    ROD 
    03
    07.06.2013 16:34:37
    07.06.2013 16:34:42
    Are that posible modifying where statement  if the valid_date_to in tutions are null then theese records where in diary valid_date_to is null is correct to, but need to stay previos logic
    D                  HIN_ID    NAME      CODE    VALID_DATE FROM                 VALID_DATE_TO 
    50510
    59564
    RE TU
    01
    07.06.2013 16:33:28
    null
    50511
    59564
    TT2 
    02
    07.06.2013 16:34:41
    null
    50514
    59564
    ROD 
    03
    07.06.2013 16:34:41
    null
    50520
    59564
    Params
    04
    03.07.2013 21:01:30
    null
    Thanks !
    ID.

  • Data model: single quote in default parameter value

    Hello,
    when I assign a default value to a parameter in my Data model, which includes a single quote (i.e. "It's a default value"), then the single quote is escaped with a backslash (i.e. "It\'s a default value") when I open the report associated with the data model. How can I get rid of the escape character when opening a report?
    Regards,
    Jure

    Hi Yogini,
    Thanks for your reply.
    When the customer name is selected, discoverer reports automatically enclose the customer names in single quotes. like 'ABC LTD', 'ABC's INC',
    I know how to change this single quote format. Also we don't want user to change the parameter selection criteria once selected.
    Also related to double quotes isn't it doubles are treated as column names in the SQL query and can not be used for any other purpose.
    Apologies, I haven't tried this but I think it will not work. Have you tried this with discoverer viewer.
    As mentioned intrusting things is when a customer name with single quote is selected in discoverer Plus it automatically formats the filter criteria to look like ['ABC LTD', 'ABC''s INC'] but this thing doesn't happen in viewer.
    I think this is a bug in discoverer viewer and think there must be some patch available to correct this problem.
    Sorry, don't have a solution yet but will certainly update the thread once I get the solution.
    Also please keep looking for a solution and let me know as well.
    Thanks a lot in advance.
    Best Regards,
    Manish

  • Embedded Single Quote in SQL Column truncates Java String

    I have a jsp web page that queries a database to see what day a user is registered for and then produces an URL for the user to click on. My problem is that the URL being processed stops when an embedded single quote is encountered.
    Here is the database side:
    Database side:
    Create Table registration
    (reg_id int not null,
    name varchar2(45) not null,
    day_nb int not null);
    Insert into registration
    (reg_id, name, day_nb)
    values (1043,'Johnny''s Diner', 1);
    Select name, day_nb from registration
    where reg_id = 1043;
    name, day_nb
    Johnny's Diner 1
    Snippet of relevant java code: (JSP page)
    <%
    int day_nb = rs.getInt("day_nb");
    String particpant_name = rs.getString("name");
    System.out.println("registration.jsp: particpant_name = " + particpant_name);
    %>
    <td width="84%">
         <a
         href='<%=response.encodeURL("registrationHandler.jsp?"particpant_name="+ particpant_name + "&day_nb="+ day_nb)%>'><%=particpant_name%>
                                  </a>
                             </td>
    {code}
    The following is printed to System.Out:
    registration.jsp: particpant_name = Johnny's Diner
    The code produces the following URL
    http://www.mycompany.com/registrationHandler.jsp?particpant_name=Johnny
    The response.encodeURL is stopping on the single quote contained in "Johnny's Diner"
    The URL I want is:
    http://www.mycompany.com/registrationHandler.jsp?particpant_name=Johnny's Diner&day_nb=1
    How do I account for the embedded single quote so the code works properly? Thanks In Advance!                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

    You really need to read up on [SQL Injection|http://en.wikipedia.org/wiki/SQL_injection] and [XSS/Cross-Site Scripting|http://de.wikipedia.org/wiki/Cross-Site_Scripting]. Both present massive security problems and your code seems prone to easily producing both.
    For SQL Injection attacks the correct solution is to always use PreparedStatements with only hard-coded String (i.e. never use String concatenation to build SQL statements).
    For XSS attacks the solution is a bit harder, but basically you need to learn never to trust user input (that includes user input that you've previously stored in the database!) and always escape what the user sent when you print it back out.

  • How to update row when data contains single quote  ?

    Hi,
    Please see this query:
    update query_tab set  title='It's common knowledg' where
    id='1121';I have this update query coming from .NET, but abviously this is error since single quote in the text (title column) given by user gives wrong meaning to sql parser. So, how to solve this problem ?
    Edited by: bootstrap on Dec 25, 2010 9:53 AM

    Hi,
    To include a single-quote in a string literal, use two of them in a row:
    update      query_tab
    set       title     = 'It''s common knowledge'
    where      id     = '1121';The method above works in any version of Oracle.
    Starting in Oracle 10, you can also use Q-notation, like this:
    update      query_tab
    set       title     = Q'[It's common knowledge]'
    where      id     = '1121';For details, look up "Text Literals" in the SQL Language manual:
    http://download.oracle.com/docs/cd/B28359_01/server.111/b28286/sql_elements003.htm#sthref337

  • How can I get a date without the hour from sql server 2000 ?

    hellou!
    I have a JTable, and one of it's columns has to show a date. This date i have to show is specified as datetime on the Sql Server 2000 database where I have to take the data.
    the query of the dataset attached to the JTable is something like "select * from Table".
    The problem is that the JTable column that displays the date shows the date and the hour, for example:
    7/10/04 0:00:00
    and I need to show the date without the hour, only the 7/10/04. Can anyone tell me how to do that?
    thank you very much! : )

    The easiest way to format a date is with java.text.SimpleDateFormat. When creating it you pass a format string which can be used to parse or format date objects.
    SimpleDateFormat formater = new SimpleDateFormat( "MM/dd/yyyy" );
    // Get date objects directly from sql
    Date foundDate = result.getDate( 1 );  //where result is the ResultSet and 1 is the date column
    String formatedDate = formater.format( foundDate );Now the JTable's table model can be adjusted to store a formated String instead of a Date. If for some reason it is required to store the value as a Date overload the table model to return the formated string when getValueAt is called.

  • Apex 4.0 Image Buttons to update SQL Where clause of Report?

    I made a table called Letters with 1 column in it called Letter and the data in it is simply A,B,C, to H. I made an apex form around this table and then created two image buttons A and B that display above the reporting area b/c i want to be able to click on the A image button and have it update the Where clause for the Letters table to be "Where Letter = A" (so once you click the A button, only the A will appear), same for the B button. I have attached a link to an album of images to show what i'm trying to do to better explain it. I just can't figure out what or how to make it so that the image button can update the where clause. I should note that i am relatively new to Apex and i tried using a dynamic action to do it but can't get this to work.
    Link to images of what i have so far-> http://imgur.com/a/guxkd/oracle_apex_40_use_image_buttons
    Any suggestions?
    Edited by: Brobot on Feb 8, 2011 9:58 PM

    Since you are using some kind of button(with images or otherwise) , add some attributes to identify them together aswell as uniquely.
    For instance if you add a name and an a common classname to each button
    For example, in button attributes for A this could be
    name="A" class="where_clause_button"You can use these attributes to trigger a Dynamic action which can refresh the report.
    Since you want the report to be filtered based on the button(ie using the "name" attribute of the corresponding button) , you need to set that value in some hidden item, say P100_FILTER_LETTER. and add a where clase to your Report Region' SQL Query
    WHERE <column name> = :P100_FILTER_LETTERNow create a Dynamic Action as
    Event :Click
    Triggering Element : jQuery selector
    Selector : *.where_clause_button*
    <li>True action 1 : Execute Javascript code
    filter_item_name = 'P100_FILTER_LETTER'
    this_button_name = $(this.triggeringElement).attr('name');
    //Set session state of Hidden Item before refresh
    var ajaxRequest=new htmldb_Get(null,$v('pFlowId'),'null',$v('pFlowStepId'));
    ajaxRequest.add( filter_item_name ,this_button_name );
    var ajaxResult=ajaxRequest.get();<li> True Action 2: Refresh
    Affected Element: Region
    Name : Choose Report Region Name
    Hope it helps

  • Prompted value corrupts SQL WHERE clause - bug?

    Using 10.1.3.4...
    I implemented a simple pivot based request that navigates to a second request when the user drill down on one of the fields. This field is set to "value is prompted" in my second request. (I chose navigate method above drill (dimensions) for a few reasons not really important to this posting, mainly to do with format of requests at different levels)
    All good and the drill down works well, parameters are passed correctly, except then I noticed that totals in my second request doesn't accurately tie back to my first request. After some research I found a very odd reason for this, my WHERE clause is getting corrupted - which almost looks like a bug in OBIEE and were wondering if anybody else has seen this behaviour from OBIEE and know a work around (before I try the Oracle support channels)
    From Answers the request SQL is (I'll highlight the lines getting messed up):
    SET VARIABLE DISABLE_CACHE_HIT = 1;
    SELECT
    BUSINESS_UNIT.Segment saw_0, BUSINESS_UNIT."Business Unit" saw_1, OPPORTUNITY.CLOSEPROBABILITY saw_2, OPPORTUNITY.CLOSEPROBABILITY saw_3, YEAR(OPPORTUNITY.ESTIMATEDCLOSE) saw_4, OPPORTUNITY_ADDON.TCV_IN_USD/1000000 saw_5, OPPORTUNITY_ADDON.WEIGHTED_TCV_IN_USD/1000000 saw_6, CASE OPPORTUNITY.CLOSEPROBABILITY WHEN 100 THEN OPPORTUNITY_ADDON.TCV_IN_USD/1000000 ELSE 0 END saw_7 FROM "Sales"
    WHERE (OPPORTUNITY.STAGE NOT IN ('Lost', 'On Hold')) AND (YEAR(OPPORTUNITY.ESTIMATEDCLOSE) &gt;= YEAR(CURRENT_DATE)) AND
    ((({color:#ff0000}OPPORTUNITY.CLOSEPROBABILITY &gt; 25) AND (TIMESTAMPDIFF(SQL_TSI_MONTH, CURRENT_DATE,OPPORTUNITY.ESTIMATEDCLOSE) &lt;= 4)) OR ((OPPORTUNITY.CLOSEPROBABILITY &gt;= 10) AND (TIMESTAMPDIFF(SQL_TSI_MONTH, CURRENT_DATE,OPPORTUNITY.ESTIMATEDCLOSE) &gt; 4{color})))
    ORDER BY saw_0, saw_1, saw_2, saw_3, saw_4, saw_5, saw_6, saw_7
    Which results in the following SQL request (from NQQuery.log)... The prompted value (BUSINESS_UNIT.Segment) is added correctly to the WHERE clause, but see how the remainder get's changed:
    SQL Request:
    SET VARIABLE QUERY_SRC_CD='Report',SAW_DASHBOARD='/shared/01 - Financials/_portal/4. Pipeline',SAW_DASHBOARD_PG='Pipeline',SAW_SRC_PATH='/shared/01 - Financials/4. Pipeline/Pipeline - Current - T2',DISABLE_CACHE_HIT = 1;
    SELECT
    BUSINESS_UNIT.Segment saw_0, BUSINESS_UNIT."Business Unit" saw_1, OPPORTUNITY.CLOSEPROBABILITY saw_2, OPPORTUNITY.CLOSEPROBABILITY saw_3, YEAR(OPPORTUNITY.ESTIMATEDCLOSE) saw_4, OPPORTUNITY_ADDON.TCV_IN_USD/1000000 saw_5, OPPORTUNITY_ADDON.WEIGHTED_TCV_IN_USD/1000000 saw_6, CASE OPPORTUNITY.CLOSEPROBABILITY WHEN 100 THEN OPPORTUNITY_ADDON.TCV_IN_USD/1000000 ELSE 0 END saw_7 FROM "Sales"
    WHERE (BUSINESS_UNIT.Segment = 'Enterprise') AND (OPPORTUNITY.STAGE NOT IN ('Lost', 'On Hold')) AND (YEAR(OPPORTUNITY.ESTIMATEDCLOSE) &gt;= YEAR(CURRENT_DATE)) AND
    ((({color:#ff0000}OPPORTUNITY.CLOSEPROBABILITY &gt;= 10) AND (TIMESTAMPDIFF(SQL_TSI_MONTH, CURRENT_DATE,OPPORTUNITY.ESTIMATEDCLOSE) &gt; 4)) OR ((OPPORTUNITY.CLOSEPROBABILITY &gt;= 10) AND (TIMESTAMPDIFF(SQL_TSI_MONTH, CURRENT_DATE,OPPORTUNITY.ESTIMATEDCLOSE) &gt; 4{color})))
    ORDER BY saw_0, saw_1, saw_2, saw_3, saw_4, saw_5, saw_6, saw_7
    Which definitely explains why my totals do not add up when drilling down. Interestingly, if I run my second request without the prompt from Answers, the SQL request works like a charm:
    SET VARIABLE QUERY_SRC_CD='Report',SAW_SRC_PATH='/shared/01 - Financials/4. Pipeline/Pipeline - Current - T2',DISABLE_CACHE_HIT = 1;
    SELECT BUSINESS_UNIT.Segment saw_0, BUSINESS_UNIT."Business Unit" saw_1, OPPORTUNITY.CLOSEPROBABILITY saw_2, OPPORTUNITY.CLOSEPROBABILITY saw_3, YEAR(OPPORTUNITY.ESTIMATEDCLOSE) saw_4, OPPORTUNITY_ADDON.TCV_IN_USD/1000000 saw_5, OPPORTUNITY_ADDON.WEIGHTED_TCV_IN_USD/1000000 saw_6, CASE OPPORTUNITY.CLOSEPROBABILITY WHEN 100 THEN OPPORTUNITY_ADDON.TCV_IN_USD/1000000 ELSE 0 END saw_7 FROM "Sales"
    WHERE (OPPORTUNITY.STAGE NOT IN ('Lost', 'On Hold')) AND (YEAR(OPPORTUNITY.ESTIMATEDCLOSE) &gt;= YEAR(CURRENT_DATE)) AND
    ((({color:#ff0000}OPPORTUNITY.CLOSEPROBABILITY &gt; 25) AND (TIMESTAMPDIFF(SQL_TSI_MONTH, CURRENT_DATE,OPPORTUNITY.ESTIMATEDCLOSE) &lt;= 4)) OR ((OPPORTUNITY.CLOSEPROBABILITY &gt;= 10) AND (TIMESTAMPDIFF(SQL_TSI_MONTH, CURRENT_DATE,OPPORTUNITY.ESTIMATEDCLOSE) &gt; 4{color})))
    ORDER BY saw_0, saw_1, saw_2, saw_3, saw_4, saw_5, saw_6, saw_7
    Anybody had the same problem before?

    Here's the excerpt (it's relative to crashing, but I think it should also address the bug):
    # PRESENTATION SERVER CRASH AFTER UPGRADING TO 10.1.3.4 (Doc ID 756541.1)
    crash when they run the reports containing Pivot Table. This has been a known issue with version ... subsequently upgraded to version
    Doc Type:ALERTModified:2/10/2009

  • How to use an UNIX shell variable in sql where clause

    Hi ,
    In my shell script first I get the Date and time from the system into the shell variable.At the end of the shell script I need to run a sql script in which I want to use the variable value in the where clause . Is there any way we can use a shell variable value in SQl script ?. Any help is greatly appriciated .
    Thanks in advance,
    Sampath

    Try the following
    In Unix
    SQLPLUS <username>/<password> @MyScript.sql <UNIX_Variable>
    In SQL*Plus
    Reference the variable as &1
    select *
    from MyTable
    where MyDate = to_date('&1','<date_format>');

  • Data Services Designer Query tranform dynamic where clause or another way

    I have an XML source that has 5 fields.  These fields are used to query 4 different SQL table data sources and do an AND inthe where clause of a query transform.  Works well if all 5 fields in the xml have data.  If one (or more) are blank, then it runs the where checking for blank matches and gives no results.  What I want to do is if a field is blank, do not use it in the where clause.  Could this be an outer join setup?  Issue is that if there is a PhoneNumber input, then to be considered a result, there must be a PhoneNumber match on potential result records...

    I have an XML source that has 5 fields.  These fields are used to query 4 different SQL table data sources and do an AND inthe where clause of a query transform.  Works well if all 5 fields in the xml have data.  If one (or more) are blank, then it runs the where checking for blank matches and gives no results.  What I want to do is if a field is blank, do not use it in the where clause.  Could this be an outer join setup?  Issue is that if there is a PhoneNumber input, then to be considered a result, there must be a PhoneNumber match on potential result records...

  • Single quote in dynamic where condition

    BAPI_STUDENT_IDENTIFIC_ADD has a field called IDENTIFICATIONNUMBER.  This field is later used in a dynamic where condition and causes a short dump when it contains a single quote.  I will change the program that calls the BAPI to check for single quotes, but is there anything else I need to check for to ensure a correct where condition?
    Thanks,
    Dan

    Hi Dan,
    The best way to ensure correctness of syntax of a dynamic where condition is:
    Run the program in debugging mode, Get the Query that is generated dynamically and write it to some other ABAP program and perform syntax check.
    This will help you to remove all the syntax errors.
    Regards,
    Darshil

Maybe you are looking for