Query with boolean values

Hi all,
is it possible to create query which check boolean attributes? If yes, how?
Thanks,
Michele

Hi Michele,
If you have an attribute (e.g. "Active") of type boolean, then it should be something like:
QueryExp exp = Query.eq(Query.attr("Active"),Query.value(true));Hope this helps,
-- daniel
JMX, SNMP, Java, etc...
http://blogs.sun.com/jmxetc

Similar Messages

  • How could I replace hard coded value in my sql query with constant value?

    Hi all,
    Could anyone help me how to replace hardcoded value in my sql query with constant value that might be pre defined .
    PROCEDURE class_by_day_get_bin_data
         in_report_parameter_id   IN   NUMBER,
         in_site_id               IN   NUMBER,
         in_start_date_time       IN   TIMESTAMP,
         in_end_date_time         IN   TIMESTAMP,
         in_report_level_min      IN   NUMBER,
         in_report_level_max      IN   NUMBER
    IS
      bin_period_length   NUMBER(6,0); 
    BEGIN
      SELECT MAX(period_length)
         INTO bin_period_length
        FROM bin_data
         JOIN site_to_data_source_lane_v
           ON bin_data.data_source_id = site_to_data_source_lane_v.data_source_id
         JOIN bin_types
           ON bin_types.bin_type = bin_data.bin_type 
       WHERE site_to_data_source_lane_v.site_id = in_site_id
         AND bin_data.start_date_time     >= in_start_date_time - numtodsinterval(1, 'DAY')
         AND bin_data.start_date_time     <  in_end_date_time   + numtodsinterval(1, 'DAY')
         AND bin_data.bin_type            =  2
         AND bin_data.period_length       <= 60;
      --Clear the edr_class_by_day_bin_data temporary table and populate it with the data for the requested
      --report.
      DELETE FROM edr_class_by_day_bin_data;
       SELECT site_to_data_source_lane_v.site_id,
             site_to_data_source_lane_v.site_lane_id,
             site_to_data_source_lane_v.site_direction_id,
             site_to_data_source_lane_v.site_direction_name,
             bin_data_set.start_date_time,
             bin_data_set.end_date_time,
             bin_data_value.bin_id,
             bin_data_value.bin_value
        FROM bin_data
        JOIN bin_data_set
          ON bin_data.bin_serial = bin_data_set.bin_serial
        JOIN bin_data_value
          ON bin_data_set.bin_data_set_serial = bin_data_value.bin_data_set_serial
        JOIN site_to_data_source_lane_v
             ON bin_data.data_source_id = site_to_data_source_lane_v.data_source_id
            AND bin_data_set.lane = site_to_data_source_lane_v.data_source_lane_id
        JOIN (
               SELECT CAST(report_parameter_value AS NUMBER) lane_id
                 FROM report_parameters
                WHERE report_parameters.report_parameter_id    = in_report_parameter_id
                  AND report_parameters.report_parameter_group = 'LANE'
                  AND report_parameters.report_parameter_name  = 'LANE'
             ) report_lanes
          ON site_to_data_source_lane_v.site_lane_id = report_lanes.lane_id
        JOIN (
               SELECT CAST(report_parameter_value AS NUMBER) class_id
                 FROM report_parameters
                WHERE report_parameters.report_parameter_id    = in_report_parameter_id
                  AND report_parameters.report_parameter_group = 'CLASS'
                  AND report_parameters.report_parameter_name  = 'CLASS'
             ) report_classes
          ON bin_data_value.bin_id = report_classes.class_id
        JOIN edr_rpt_tmp_inclusion_table
          ON TRUNC(bin_data_set.start_date_time) = TRUNC(edr_rpt_tmp_inclusion_table.date_time)
       WHERE site_to_data_source_lane_v.site_id = in_site_id
         AND bin_data.start_date_time     >= in_start_date_time - numtodsinterval(1, 'DAY')
         AND bin_data.start_date_time     <  in_end_date_time   + numtodsinterval(1, 'DAY')
         AND bin_data_set.start_date_time >= in_start_date_time
         AND bin_data_set.start_date_time <  in_end_date_time
         AND bin_data.bin_type            =  2
         AND bin_data.period_length       =  bin_period_length;
    END class_by_day_get_bin_data;In the above code I'm using the hard coded value 2 for bin type
    bin_data.bin_type            =  2But I dont want any hard coded number or string in the query.
    How could I replace it?
    I defined conatant value like below inside my package body where the actual procedure comes.But I'm not sure whether I have to declare it inside package body or inside the procedure.
    bin_type     CONSTANT NUMBER := 2;But it does't look for this value. So I'm not able to get desired value for the report .
    Thanks.
    Edited by: user10641405 on May 29, 2009 1:38 PM

    Declare the constant inside the procedure.
    PROCEDURE class_by_day_get_bin_data(in_report_parameter_id IN NUMBER,
                                        in_site_id             IN NUMBER,
                                        in_start_date_time     IN TIMESTAMP,
                                        in_end_date_time       IN TIMESTAMP,
                                        in_report_level_min    IN NUMBER,
                                        in_report_level_max    IN NUMBER) IS
      bin_period_length NUMBER(6, 0);
      v_bin_type     CONSTANT NUMBER := 2;
    BEGIN
      SELECT MAX(period_length)
        INTO bin_period_length
        FROM bin_data
        JOIN site_to_data_source_lane_v ON bin_data.data_source_id =
                                           site_to_data_source_lane_v.data_source_id
        JOIN bin_types ON bin_types.bin_type = bin_data.bin_type
       WHERE site_to_data_source_lane_v.site_id = in_site_id
         AND bin_data.start_date_time >=
             in_start_date_time - numtodsinterval(1, 'DAY')
         AND bin_data.start_date_time <
             in_end_date_time + numtodsinterval(1, 'DAY')
         AND bin_data.bin_type = v_bin_type
         AND bin_data.period_length <= 60;
      --Clear the edr_class_by_day_bin_data temporary table and populate it with the data for the requested
      --report.
      DELETE FROM edr_class_by_day_bin_data;
      INSERT INTO edr_class_by_day_bin_data
        (site_id,
         site_lane_id,
         site_direction_id,
         site_direction_name,
         bin_start_date_time,
         bin_end_date_time,
         bin_id,
         bin_value)
        SELECT site_to_data_source_lane_v.site_id,
               site_to_data_source_lane_v.site_lane_id,
               site_to_data_source_lane_v.site_direction_id,
               site_to_data_source_lane_v.site_direction_name,
               bin_data_set.start_date_time,
               bin_data_set.end_date_time,
               bin_data_value.bin_id,
               bin_data_value.bin_value
          FROM bin_data
          JOIN bin_data_set ON bin_data.bin_serial = bin_data_set.bin_serial
          JOIN bin_data_value ON bin_data_set.bin_data_set_serial =
                                 bin_data_value.bin_data_set_serial
          JOIN site_to_data_source_lane_v ON bin_data.data_source_id =
                                             site_to_data_source_lane_v.data_source_id
                                         AND bin_data_set.lane =
                                             site_to_data_source_lane_v.data_source_lane_id
          JOIN (SELECT CAST(report_parameter_value AS NUMBER) lane_id
                  FROM report_parameters
                 WHERE report_parameters.report_parameter_id =
                       in_report_parameter_id
                   AND report_parameters.report_parameter_group = 'LANE'
                   AND report_parameters.report_parameter_name = 'LANE') report_lanes ON site_to_data_source_lane_v.site_lane_id =
                                                                                         report_lanes.lane_id
          JOIN (SELECT CAST(report_parameter_value AS NUMBER) class_id
                  FROM report_parameters
                 WHERE report_parameters.report_parameter_id =
                       in_report_parameter_id
                   AND report_parameters.report_parameter_group = 'CLASS'
                   AND report_parameters.report_parameter_name = 'CLASS') report_classes ON bin_data_value.bin_id =
                                                                                            report_classes.class_id
          JOIN edr_rpt_tmp_inclusion_table ON TRUNC(bin_data_set.start_date_time) =
                                              TRUNC(edr_rpt_tmp_inclusion_table.date_time)
         WHERE site_to_data_source_lane_v.site_id = in_site_id
           AND bin_data.start_date_time >=
               in_start_date_time - numtodsinterval(1, 'DAY')
           AND bin_data.start_date_time <
               in_end_date_time + numtodsinterval(1, 'DAY')
           AND bin_data_set.start_date_time >= in_start_date_time
           AND bin_data_set.start_date_time < in_end_date_time
           AND bin_data.bin_type = v_bin_type
           AND bin_data.period_length = bin_period_length;
    END class_by_day_get_bin_data;

  • How to force readObejct query with PK value to go to DB?

    The default behaviour for read-object queries with a PK value is to use the cache and not go to the database. How can we change this behaviour?
    We have cases that a row was deleted by some other process not through toplink, but the corresponding object still in the cache and if you use the readObject query with PK value, the object will be returned as result.
    Thanks in advance,

    There are several mechanisms to disable caching in TopLink. Note that disabling caching will affect your performance.
    In 9.0.4 you can use:
    - You can configure you cache type to use a WeakIdentityMap to ensure that only referenced objects are cached.
    - On descriptor you can call disableCacheHits() and alwaysRefreshCache() in code or click these options on the Caching/Identity tab in the Mapping Workbench.
    - Or to explicitly remove a deleted object from the cache uses session.removeFromIdentityMap(), but you must ensure there are no other objects referencing it.
    In 10.1.3 you can also use:
    - On descriptor you can call setIsIsolated(true) in code, or select isolated in the Caching tab in the Mapping Workbench.
    - Alternatively you can set a CacheInvalidationPolicy on your descriptor to ensure objects are not cached for longer than a specified time, or invalidated daily.
    - Or to explicitly invalidate a deleted object use, session.getIdentityMapAccessor().invalidateObject()

  • JXPath with boolean value

    Hi,
    I want to know if JXPath support boolean value or not, and how to do.Because if i try to get the value of a bollean attribute with the getValue(..) method, it does'nt work..
    Thanks

    Hi,
    This forum is dedicated to JMX.
    You're asking a question about JXPath, which is not even closely related to the technology this forum is about.
    Maybe someone reading your post will have an answer for you, but it would be sheer luck.
    Maybe this link will have the answer you're looking for:
    http://today.java.net/pub/a/today/2006/08/03/java-object-querying-using-jxpath.html
    If not you could try to google search for JXPath, or try to find a better suited forum here:
    http://forum.java.sun.com/index.jspa?tab=java
    Hope this helps,
    -- daniel
    http://blogs.sun.com/jmxetc

  • Cell with boolean value not rendering properly in Swing (custom renderer)

    Hello All,
    I have a problem rendenring boolean values when using a custom cell renderer inside a JTable; I managed to reproduce the issue with a dummy application. The application code follows:
    import java.awt.BorderLayout;
    import java.awt.Dimension;
    import java.lang.reflect.InvocationTargetException;
    import java.util.ArrayList;
    import java.util.Date;
    import java.util.List;
    import java.util.logging.Logger;
    import javax.swing.JFrame;
    import javax.swing.JScrollPane;
    import javax.swing.JTable;
    import javax.swing.SwingUtilities;
    * Simple GUI that uses custom cell rendering
    * @author josevnz
    public final class SimpleGui extends JFrame {
         private static final long serialVersionUID = 1L;
         private Logger log = Logger.getLogger(SimpleGui.class.getName());
         private JTable simpleTable;
         public SimpleGui() {
              super("Simple GUI");
              setPreferredSize(new Dimension(500, 500));
              setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
              setLayout(new BorderLayout());
         public void constructGui() {
              simpleTable = new JTable(new SimpleTableModel());
              simpleTable.getColumnModel().getColumn(2).setCellRenderer(new HasItCellRenderer());
              SpecialCellRenderer specRen = new SpecialCellRenderer(log);
              simpleTable.setDefaultRenderer(Double.class, specRen);
              simpleTable.setDefaultRenderer(String.class, specRen);
              simpleTable.setDefaultRenderer(Date.class, specRen);
              //simpleTable.setDefaultRenderer(Boolean.class, specRen);
              add(new JScrollPane(simpleTable), BorderLayout.CENTER);          
              pack();
              setVisible(true);
         private void populate() {
              List <List<Object>>people = new ArrayList<List<Object>>();
              List <Object>people1 = new ArrayList<Object>();
              people1.add(0, "Jose");
              people1.add(1, 500.333333567);
              people1.add(2, Boolean.TRUE);
              people1.add(3, new Date());
              people.add(people1);
              List <Object>people2 = new ArrayList<Object>();
              people2.add(0, "Yes, you!");
              people2.add(1, 100.522222);
              people2.add(2, Boolean.FALSE);
              people2.add(3, new Date());
              people.add(people2);
              List <Object>people3 = new ArrayList<Object>();
              people3.add(0, "Who, me?");
              people3.add(1, 0.00001);
              people3.add(2, Boolean.TRUE);
              people3.add(3, new Date());
              people.add(people3);
              List <Object>people4 = new ArrayList<Object>();
              people4.add(0, "Peter Parker");
              people4.add(1, 11.567444444);
              people4.add(2, Boolean.FALSE);
              people4.add(3, new Date());
              people.add(people4);
              ((SimpleTableModel) simpleTable.getModel()).addAll(people);
          * @param args
          * @throws InvocationTargetException
          * @throws InterruptedException
         public static void main(String[] args) throws InterruptedException, InvocationTargetException {
              final SimpleGui instance = new SimpleGui();
              SwingUtilities.invokeAndWait(new Runnable() {
                   @Override
                   public void run() {
                        instance.constructGui();
              instance.populate();
    }I decided to write a more specific renderer just for that column:
    import java.awt.Color;
    import java.awt.Component;
    import javax.swing.JTable;
    import javax.swing.UIManager;
    import javax.swing.table.DefaultTableCellRenderer;
    * Cell renderer used only by the DividendElement table
    * @author josevnz
    final class HasItCellRenderer extends DefaultTableCellRenderer {
         protected static final long serialVersionUID = 2596173912618784286L;
         private Color hasIt = new Color(255, 225, 0);
         public HasItCellRenderer() {
              super();
              setOpaque(true);
         @Override
         public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
              Component comp = super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
              int desCol = table.convertColumnIndexToView(1);
              if (! isSelected && value instanceof Boolean && column == desCol) {
                   if (((Boolean) value).booleanValue()) {
                        comp.setForeground(hasIt);     
                   } else {
                        comp.setForeground(UIManager.getColor("table.foreground"));
              return comp;
          * Override for performance reasons
         @Override
         public void firePropertyChange(String propertyName, boolean oldValue, boolean newValue) {
              // EMPTY
         @Override
         protected void firePropertyChange(String propertyName, Object oldValue, Object newValue) {
              // EMPTY
         @Override
         public void revalidate() {
              // EMPTY
         @Override
         public void validate() {
              // EMPTY
    } // end classBut the rendering comes all wrong (a String saying true or false, not the expected checkbox from the default renderer) and also there is a weird flickring effect as this particular boolean column is editable (per table model, not show here)...
    I can post the table model and the other renderer if needed (didn't want to put too much code on the question, at least initiallty).
    Should I render a checkbox myself for this cell in the custom renderer? I'm puzzled as I expected the default renderer part of the code to do this for me instead.
    Thanks!
    Edited by: josevnz on Apr 14, 2009 12:35 PM
    Edited by: josevnz on Apr 14, 2009 12:37 PM

    camickr
    Thats because the default render is a JLabel and it just displays the text from the toString() method of the Object in the table model.What I meant to say is that I expected the JCheckbox not a String representation of the boolean value.
    Thats because a different renderer is used depending on the Class of data in the column. Look at the source code for the JTable class to see what the "default >renderer for the Boolean class" is. Then you can extend that or if its a private class then you will need to copy all the code and customize it.At the end I looked at the code and replicated the functionality I needed. I thought than maybe there was a way to avoid replicating the same logic all over again in order to implement this functionality. Good advice, though.
    see you learned nothing from your last posting. This is NOT a SSCCE. 90% of the code you posted is completely irrelevant for the described problem. There is abosutelly no need to post the custom TableModel, because there is no need to use a custom TableModel for this problem. The TableModel has nothing to do with how a column is rendererd.The custom table model returns the type of the column (giving a hint to the renderer on what to expect, right?) and for the one that had a problem it says than the class is Boolean. That's why I mentioned it:
    public Class getColumnClass(int columnIndex) {
        // Code omited....
    You also posted data for 4 columns worth of data. Again, irrelevant. Your question is about a single column containing Boolean data, so forget about the other columns.
    When creating a SSCCE you don't start with your existing code and "remove" code. You start with a brand new class and only add in what is important. That way hopefully if you made a mistake the first time you don't repeat it the second time.That's what I did, is not the real application. I copy & pasted code in a haste from this dummy program on this forum, not the best approach as it gave the wrong impression.
    Learn how to write a proper SSCCE if you want help in the future. Point taken, but there is NO need for you to be rude. Your help is appreciated.
    Regards,
    Jose.

  • Infoset query with cero values

    Hi
    I have an infoset query that reads the information from an infoset. The infoset query is able to read the values, because it shows me values, but everything is cero, although I have values different from 0.
    But if it didn`t find values it would tell me a different message as "No application data found" or something like this.
    Then the problem is, my infoset read values, but everything that shows me is cero, and that´s not true.
    Thanks and regards
    SEM SEM

    Hi,
    What do you mean with the join condition ?
    I have an infoset query with only one ODS inside. I didn´t want to build a query directly to the ODS as I did´t want to mark the flag available for reporting in the ODS, as it already had very importat data and I didn´t want to damage the ODS  data. That´s why I have built and infoset query with one ODS inside, and in this case I don´t understand the join condition....
    Regards
    SEM SEM
    Does anybody know something ????
    Regards
    SEM SEM
    Message was edited by:
            SEM SEM

  • Re: Express Query on boolean values

    Hi Simon,
    When the model is run, however, I am able to enter values in the
    other fields and query on them, but I am unable to change the value
    of the checkbox that Express generates for the boolean attribute. If
    the query is run, the data returned is for both true and false values
    of this field.
    Why am I unable to query on this field?The literal answer to your question is: Because Express does not
    support doing queries on Boolean fields.
    The reason is that it is difficult to know how to interpret a
    ToggleField when it comes to search criteria. If "off" means
    find records where this value is FALSE and "on" means find records
    where this value is TRUE, how does one specify to find all records
    regardless of the field value? With DataFields, leaving the field
    blank specifies just this.
    If you want to override this behavior, you'll need to know the
    following:
    Express uses a special widget state to allow users to enter search
    criteria operators (<, >, and so forth) in fields that otherwise
    would not accept these operators (DataFields displaying integers
    or dates). This widget state is called FS_QUERY. What you are
    seeing is that when ToggleFields are in the FS_QUERY state, they
    do not allow the user to change their value.
    The SetWidgetState method is what sets the widget state to FS_QUERY
    when the window enters search mode. So to one step you must take
    to override this behavior is to write a custom SetWidgetState method
    that sets the widget state to FS_UPDATE if the passed widget is a
    toggle field and the passed widget is a ToggleField.
    But this will only allow you to change the state of the ToggleField
    while in Search mode. The next problem is that the window will ignore
    the value of the ToggleField regardless of what it is!
    This time the method of interest is SetSearchConstraint. It looks at
    the widget to get the search constraint. It will only look at DataField
    and ListField widgets, however, and ignore all others. You need to
    create a custom version that looks at the ToggleField and interprets
    the value (look in the Customizing Express applications doc for more
    info on modifying the search criteria).
    Also, the checkbox is highlighted in yellow during the entry of
    search criteria, even though I have set its colour in the window
    workshop customization.
    Where is this colour being set?This is being set in the ExpressWindows.ArrayDesc.SelectRow method.
    This is more difficult to override, as Express is not set up for
    users to override this class with a custom superclass.
    However, you can try setting the ToggleField color in
    DisplayCurrentRecord
    and SetResultSetFromData with code like the following:
    super.DisplayCurrentRecord();
    ArrayWidget.GetField( 1, "MyBooleanFieldName", FALSE ).FillColor =
    C_RED;
    and
    super.SetResultSetFromData();
    ArrayWidget.GetField( 1, "MyBooleanFieldName", FALSE ).FillColor =
    C_RED;
    I haven't tried this, however, and I'm not certain it will work, but
    it's worth a shot. ArrayWidget, in this case, is an attribute of type
    ExpressWindows.ArrayDesc that is defined on
    ExpressWindows.ExpressArrayWindow.
    GetField is defined on this class. Take a peek at it to get a better
    understanding of what it does.
    Good luck!
    Kerry

    Hi Pankaj,
    thank you for the detailed description. I tried to reproduce the issue but in my system I get the results that you are expecting.
    01.04.2010     10.04.2010     91.560,00
    11.04.2010          106.820,00
    Which release, support package level for EA-APPL is implemented in your system?
    Regards, Franz

  • CAML Query with Javascript value

    Hey everyone,
    I am building an Sharepoint 2013 app (SharePoint-Hosted) and using a CAML Query to get the current Item.
    The Current Item ID is 1 and i stored it in AccountID, but i want that variable inserted in the CAML Query so i get the proper information.
    var AccountID = 1
    camlQuery.set_viewXml('<View><Query><Where><Eq><FieldRef Name=ID LookupId="TRUE"/><Value Type="Text">1</Value></Eq></Where></Query></View>');
    But instead of putting the '1' value in the CAML Query, i want the variable AccountID in it... but how?
    Already tried this, but that didn't work:
    camlQuery.set_viewXml('<View><Query><Where><Eq><FieldRef Name=ID LookupId="TRUE"/><Value Type="Text">' + AccountID + '</Value></Eq></Where></Query></View>');
    Can someone help me with this?
    In forward, many thanks!

    Right, you have to use single quotes in a string literal inside double quotes. Just making sure it didn't have NO quotes, as your initial post showed.
    Is the ID field actually a lookup field? Or is it just the built-in ID field of the list? If it isn't a field of TYPE Lookup, try this:
    camlQuery.set_viewXml("<View><Query><Where><Eq><FieldRef Name='ID' /><Value Type='Number'>" + AccountID + "</Value></Eq></Where></Query></View>");
    Danny Jessee
    MCPD - SharePoint Developer 2010
    MCTS - SharePoint 2010, Configuring
    dannyjessee.com/blog

  • PHP+MySQL query with empty value

    Hi!
    Software is DW8 with Apache 2.0.48, MySQL ver. 4.0.15a, PHP
    4.2.3.
    We had problem when a submitted value for 'regionID' in the
    submit page
    was left blank and the following error message appears in the
    result page:
    "You have an error in your SQL syntax. Check the manual that
    corresponds
    to your MySQL server version for the right syntax to use near
    'LIMIT 0,
    3' at line 1"
    The problem was solved by adding at the top of the page:
    <?php
    if (isset($_POST['regionID']) &&
    empty($_POST['regionID'])) {
    $_POST['regionID'] = '0';
    ?>
    How to change the above code to retrieve ALL records when an
    empty \
    blank value is submitted for 'regionID'?
    TIA
    Nanu

    bbgirl wrote:
    > Something I picked up at a PHP/MySQL seminar...
    $_REQUEST works in place of
    > either $_GET or $_POST. It basically means use either
    get or post. But it is
    > less precise because it can pick up either variable and
    has to think about the
    > request...
    I'm afraid you've picked up rather poor information.
    $_REQUEST relies on
    register_globals being turned on. Since register_globals is
    considered a
    major security risk, the default setting has been off since
    April 2002.
    Many hosting companies have turned register_globals on, in
    spite of the
    security problems, because so many poorly written scripts
    rely on it.
    The PHP development team has decided to resolve this security
    issue once
    and for all by removing register_globals from PHP 6.
    Forget $_REQUEST. Use $_POST and $_GET always. It's safer,
    and it's
    futureproof.
    David Powers
    Author, "Foundation PHP for Dreamweaver 8" (friends of ED)
    Author, "Foundation PHP 5 for Flash" (friends of ED)
    http://foundationphp.com/

  • Query with scalar valued function with date filter

    Hello experts
    i have a problem by filtering my results with the date
    i have written the following code
    SELECT
    T1.ItemCode
    , T1.Dscription
    ,DBO.F_CALCULATION_QUANTITY(T1.ITEMCODE)
    FROM OINV T0 
    INNER JOIN INV1 T1 ON T0.DocEntry = T1.DocEntry
    INNER JOIN OITM T2 ON T1.ItemCode = T2.ItemCode
    INNER JOIN OSLP T3 ON T0.SLPCODE=T3.SLPCODE
    WHERE
    (T0.DOCDATE BETWEEN '2010-11-01' AND '2010-11-30')
    and (t2.cardcode ='80022')
    and (T0.CANCELED= 'N')
    group by  t1.itemcode, T1.Dscription, t2.suppcatnum
    set ANSI_NULLS ON
    set QUOTED_IDENTIFIER ON
    go
    ALTER  FUNCTION [dbo].[F_CALCULATION_QUANTITY]
    (@ITEMCODE AS NVARCHAR(10))
    RETURNS
    NUMERIC(19,2)
    AS
    BEGIN
    DECLARE
    @RESULT1 AS NUMERIC(19,2),
    @RESULT2 AS NUMERIC(19,2),
    @RESULT AS NUMERIC(19,2)
    SELECT @RESULT1=SUM(A.QUANTITY)
    FROM INV1 A
    JOIN OINV B ON A.DOCENTRY=B.DOCENTRY
    WHERE A.ITEMCODE=@ITEMCODE
    AND B.DOCDATE BETWEEN  '2010-11-01 00:00:00.000' AND '2010-11-30 00:00:00.000'
    SELECT @RESULT2=SUM(A.QUANTITY)
    FROM RIN1 A
    JOIN ORIN B ON A.DOCENTRY=B.DOCENTRY
    WHERE A.ITEMCODE=@ITEMCODE
    AND B.DOCDATE BETWEEN '2010-11-01 00:00:00.000' AND '2010-11-30 00:00:00.000'
    SELECT @RESULT=ISNULL(@RESULT1,0)-ISNULL(@RESULT2,0)
    --SELECT @RESULT=@RESULT1- @RESULT2
    RETURN @RESULT
    END
    the problem i have is that i want to filter my results accoring to the date provided by the user. i want it to be dynamic query.
    by now, what i do is to edit the docdate in the function in order to get the desired results. this is not what i want.
    could you please help me on this way in order to let the user to input the date?if i add the [%] in the query, it does not bring me the right results

    i have already edited the function to
    set ANSI_NULLS ON
    set QUOTED_IDENTIFIER ON
    go
    ALTER  FUNCTION [dbo].[F_CALCULATION_QUANTITY]
    (@ITEMCODE AS NVARCHAR(10),
    @STARTDATE1 as DATETIME,
    @ENDDATE1 AS DATETIME
    RETURNS
    NUMERIC(19,2)
    AS
    BEGIN
    DECLARE
    @RESULT1 AS NUMERIC(19,2),
    @RESULT2 AS NUMERIC(19,2),
    @RESULT AS NUMERIC(19,2)
    SELECT @RESULT1=SUM(A.QUANTITY)
    FROM INV1 A
    JOIN OINV B ON A.DOCENTRY=B.DOCENTRY
    WHERE A.ITEMCODE=@ITEMCODE
    AND B.DOCDATE BETWEEN (@STARTDATE1) AND (@ENDDATE1)
    SELECT @RESULT2=SUM(A.QUANTITY)
    FROM RIN1 A
    JOIN ORIN B ON A.DOCENTRY=B.DOCENTRY
    WHERE A.ITEMCODE=@ITEMCODE
    AND B.DOCDATE BETWEEN (@STARTDATE1) AND (@ENDDATE1)
    SELECT @RESULT=ISNULL(@RESULT1,0)-ISNULL(@RESULT2,0)
    RETURN @RESULT
    END
    could you please how to edit the query as well?
    i have added the following code and it comes up with the right itemcode but the quantity does not work
    DECLARE
    @ITEMCODE AS NVARCHAR(10),
    @STARTDATE1 as DATETIME,
    @ENDDATE1 AS DATETIME
    SET @STARTDATE1=(SELECT MAX(T0.DOCDATE) FROM oinv t0 WHERE T0.DOCDATE='2010-11-01')
    set @ENDDATE1=(SELECT MAX(T0.DOCDATE) FROM oinv t0 WHERE T0.DOCDATE='2010-11-30')
    SELECT
    T1.ItemCode
    , T1.Dscription
    ,DBO.F_CALCULATION_QUANTITY(@ITEMCODE,@STARTDATE1,@ENDDATE1)
    FROM OINV T0 
    INNER JOIN INV1 T1 ON T0.DocEntry = T1.DocEntry
    INNER JOIN OITM T2 ON T1.ItemCode = T2.ItemCode
    INNER JOIN OSLP T3 ON T0.SLPCODE=T3.SLPCODE
    WHERE
    (T0.DOCDATE BETWEEN @STARTDATE1 AND @ENDDATE1)
    and  (t2.cardcode ='80022')
    and (T0.CANCELED= 'N')
    group by  t1.itemcode, T1.Dscription, t2.suppcatnum
    the result is this
    70200     alert1     0.00
    70210     alert2     0.00
    70220     alert3     0.00
    70230     alert4     0.00
    as you can see the quantity is 0 and it shouldnt be
    Edited by: Fasolis Vasilios on Oct 31, 2011 10:49 AM

  • Select Query with minimum values

    Table name: employess_inout
    Column name: employee_code number(data type)
    IN_Time date(data type)
    Out_time date(data type)
    i want to select only in_time coloumn data with min intime as in one date A employee have more then 2 times in_time entry
    example
    employee_code in_time out_time
    1 18-mar-12 08:15:21 18-mar-12 13:02:01
    1 18-mar-12 14:07:46 18-mar-12 18:01:32
    1 19-mar-12 09:15:11 19-mar-12 12:58:54
    1 19-mar-12 14:10:01 19-mar-12 16:21:57
    1 19-mar-12 16:53:37 19-mar-12 18:15:33
    In above example I only want to select in_time column values which is minimum as 18-mar-12(08:15:21) like wise in date 19-mar-12 minimum value is 09:15:11.
    Please write the script.
    thanks in advance

    Dear Frank Kulash
    the Script is
    Select ei.emp_code,p.ename, d.department_name, ds.designation_name,
    to_char(ei.intime, 'dd') "IN_Date",
    to_char (ei.intime,'hh24:mi') "IN_Time" /*here i used "min" but not solved*/
    FROM einout ei, personnel p,departments d, designations ds
    where ei.emp_code = '470'
    and intime between to_date ('01/03/2012 08:10', 'dd/mm/YYYY hh24:mi')
    and to_date ('21/03/2012 10:00','dd/mm/YYYY hh24:mi')
    and ei.emp_code = p.emp_code
    AND p.dept_code = d.dept_code
    and p.desig_code = ds.desig_code
    group by ei.emp_code,p.ename, d.department_name, ei.intime,ds.designation_name --, ei.outtime
    order by ei.intime, ei.emp_code asc;
    Out Put
    EMP_CODE ENAME DEPARTMENT_NAME DESIGNATION_NAME IN_Date IN_Time
    470 GHULAM YASSEN INFORMATION TECHNOLOGY OFFICER 01 09:15
    *470      GHULAM YASSEN             INFORMATION TECHNOLOGY         OFFICER                   02          08:58*
    *470      GHULAM YASSEN             INFORMATION TECHNOLOGY         OFFICER                   02          14:04*
    *470      GHULAM YASSEN             INFORMATION TECHNOLOGY         OFFICER                   02          15:11*
    470 GHULAM YASSEN INFORMATION TECHNOLOGY OFFICER 03 09:06
    470 GHULAM YASSEN INFORMATION TECHNOLOGY OFFICER 05 17:07
    470 GHULAM YASSEN INFORMATION TECHNOLOGY OFFICER 06 09:47
    470 GHULAM YASSEN INFORMATION TECHNOLOGY OFFICER 07 09:36
    *470 GHULAM YASSEN INFORMATION TECHNOLOGY OFFICER 07 19:39* 470 GHULAM YASSEN INFORMATION TECHNOLOGY OFFICER 08 12:16
    470 GHULAM YASSEN INFORMATION TECHNOLOGY OFFICER 09 09:26
    *470 GHULAM YASSEN INFORMATION TECHNOLOGY OFFICER 09 14:08*
    I want to take out put
    like that
    EMP_CODE ENAME DEPARTMENT_NAME DESIGNATION_NAME IN_Date IN_Time
    470 GHULAM YASSEN INFORMATION TECHNOLOGY OFFICER 01 09:15
    470 GHULAM YASSEN INFORMATION TECHNOLOGY OFFICER 02 08:58
    470 GHULAM YASSEN INFORMATION TECHNOLOGY OFFICER 03 09:06
    470 GHULAM YASSEN INFORMATION TECHNOLOGY OFFICER 05 17:07
    470 GHULAM YASSEN INFORMATION TECHNOLOGY OFFICER 06 09:47
    470 GHULAM YASSEN INFORMATION TECHNOLOGY OFFICER 07 09:36
    I only need min time (value) once of A date.
    [Bold rows are no need in output]
    please tell how it will be possible

  • Query with distinct values

    Hi, I have this query in my 9ir2 database:
      SELECT xmit.u_ii_id, xprol.ii_id
      FROM xprol, ( SELECT DISTINCT u_ii_id, ii_id
                    FROM t
                    WHERE NVL(key_t,'X') <> 'P') xmit
      WHERE xprol.ii_id = xmit.ii_id
      AND xmit.u_ii_id <> xprol.ii_id  ;
    u_ii_id                                  ii_id
    6220                                       5765
    6220                                       5765
    6220                                       5765
    6220                                       5765
    6220                                       5765
    6220                                       5765
    6220                                       5765
    6220                                       5765
    6220                                       5765
    6220                                       5765
    6220                                       5765
    6220                                       5765
    6220                                       5765
    6220                                       5765
    6220                                       5765
    6220                                       5765
    6220                                       5765
    6220                                       5765
    6220                                       5765
    6220                                       5765
    6220                                       5765
    6220                                       5765
    6220                                       5765
    6220                                       5765
    6220                                       5765
    6220                                       5765
    6220                                       5765
    6220                                       5765
    6220                                       5765
    6220                                       5765
    6220                                       5765
    6220                                       5765
    6220                                       5765
    6220                                       5765
    6220                                       5765
    6220                                       5765
    6220                                       5765
    6220                                       5765
    6220                                       5765
    6220                                       5765
    6220                                       5765
    6220                                       5765
    6220                                       5765
    6220                                       5765
    6220                                       5765
    6220                                       5765
    6220                                       5765
    6220                                       5765
    6220                                       5765
    6220                                       5765
    6220                                       5765
    6220                                       5765
    6220                                       5765
    6220                                       5765
    6220                                       5765
    6220                                       5765
    6220                                       5765
    6220                                       5765
    6220                                       5765
    6220                                       5765
    6220                                       5765
    6220                                       5765
    6220                                       5765
    6220                                       5765
    6220                                       5765
    6220                                       5765
    6220                                       5765
    6220                                       5765
    6220                                       5765
    6220                                       5765
    6220                                       5765
    6220                                       5765
    6220                                       5765
    6220                                       5765
    6220                                       5765
    6220                                       5765
    6220                                       5765
    6220                                       5765
    6220                                       5765
    6220                                       5765
    6220                                       5765
    6220                                       5765
    6220                                       5765
    6220                                       5765
    6220                                       5765
    6220                                       5765
    6220                                       5765
    6220                                       5765
    6220                                       5765
    6220                                       5765
    6220                                       5765
    6220                                       5765
    6220                                       5765
    6220                                       5765
    6220                                       5765
    6220                                       5765
    6220                                       5765
    6220                                       5765
    6220                                       5765
    6220                                       5765
    6220                                       5765
    6220                                       5765
    6220                                       5765
    6220                                       5765
    6220                                       5765
    6220                                       5765
    6220                                       5765
    7898                                    3409
    7898                                    3409
    7898                                    3409
    7898                                    3409
    7898                                    3409
    7898                                    3409
    7898                                    3409
    7898                                    3409
    .The query returns 12.294.938 million of rows.
    I need to know de best way to filter this values... maybe using Analytic Functions?
    The result of the query must be...
    u_ii_id                                  ii_id
    6220                                       5765
    7898                                    3409Thanks!

    ROW_NUMBER () OVER (PARTITION BY xmit.u_ii_id
    ORDER BY xmit.u_ii_id,
    xprol.ii_id) AS rn
    xprol, (SELECT DISTINCT u_ii_id, ii_id
    FROM t
    HERE NVL (key_t, 'X') <> 'P') xmit
    WHERE xprol.ii_id = xmit.ii_id AND xmit.u_ii_id <>
    xprol.ii_id AND rn = 1
    /code]this will not work it will give , that needs to be in subquery
    ORA-00904: "RN": invalid identifier
    below is just an example
    SQL> select empno,e.deptno ,row_number() over(partition by deptno order by deptno) rn
      2  from emp e, (select deptno from dept1
      3    where deptno=10) d
      4    where e.deptno=d.deptno
      5    and rn=1;
      and rn=1
    ERROR at line 5:
    ORA-00904: "RN": invalid identifier
    /pre]                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

  • SetProperty giving error with boolean values

    I created a boolean property in the property sets. When I try to change the
    value using setProperty, I keep getting the following error.
    \_full_disclaimer.java:134: cannot resolve symbol
    symbol : method setValue (boolean)
    location: class com.beasys.commerce.user.jsp.tags.SetPropertyTag
    umsetProperty0.setValue(trueValue);
    ile://[ /portals/repository/full_disclaimer.jsp; Line: 19]
    ^
    1 error
    JSP Code snippit:
    <%
    // Check for submit parameter
    String strSubmit = request.getParameter("submit"); if (strSubmit==null)
    strSubmit="";
    if (strSubmit.equalsIgnoreCase("Accept")) {
    boolean trueValue = true;
    %>
    <um:setProperty propertyName="legaldisclaimer"
    propertySet="<%=portalName%>" value="<%=trueValue%>" />
    <jsp:forward page="<%=createURL(request, "portal.jsp", null)%>"/>
    <%
    %>
    Any ideas why this is happening, and more importantly, what do I need to do
    so I get the desired results????
    Thanks,
    Ken Lee
    [email protected]

    Ken,
    Use a Boolean Object instance.
    Sincerely,
    Daniel Selman
    "Kenneth Lee" <[email protected]> wrote in message
    news:[email protected]..
    I created a boolean property in the property sets. When I try to changethe
    value using setProperty, I keep getting the following error.
    \_full_disclaimer.java:134: cannot resolve symbol
    symbol : method setValue (boolean)
    location: class com.beasys.commerce.user.jsp.tags.SetPropertyTag
    umsetProperty0.setValue(trueValue);
    ile://[ /portals/repository/full_disclaimer.jsp; Line: 19]
    ^
    1 error
    JSP Code snippit:
    <%
    // Check for submit parameter
    String strSubmit = request.getParameter("submit"); if (strSubmit==null)
    strSubmit="";
    if (strSubmit.equalsIgnoreCase("Accept")) {
    boolean trueValue = true;
    %>
    <um:setProperty propertyName="legaldisclaimer"
    propertySet="<%=portalName%>" value="<%=trueValue%>" />
    <jsp:forward page="<%=createURL(request, "portal.jsp", null)%>"/>
    <%
    %>
    Any ideas why this is happening, and more importantly, what do I need todo
    so I get the desired results????
    Thanks,
    Ken Lee
    [email protected]

  • Append Query with multi values

    I am attempting to append information into a new database. The old project information has some fields that are multi-value. Apparently an append query cannot handle this. Is there a way I can over come this?

    Hi
    >>Apparently an append query cannot handle this
    Have you got some error? What's the problem you have encountered? Could you please show the sql you are using or share a sample to reproduce this ?
    If you're adding a value to your multi-valued field, you can us an append query like this,
    Insert into table (FieldName.value) values (value)
    Best Regards
    Lan
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click
    HERE to participate the survey.

  • How to re-run query with bind values

    Hello,
    I have a sql statement which I obtained from statspack report. After looking at explan plan, I created an idex. Now I want to re-run the query and exame the explan plan again and see if newly created index helped. But how to re-run the query when it contains bind variables? Thank you.

    Have to define and exec them first (if you know the values; null otherwise, so if you can get values, you will have a better idea of what takes place).

Maybe you are looking for