SELECT QUERY CHECK & WHERE CLAUSE DIFFERENCE.URGENT PLEASE.

My question is ,
IF SBOOK_WA-CARRID = 'LH' CONDITION IS AGAIN PRESENT IN THE DATABASE TABLE ,,,,WILL THE CHECK CONDITION SEARCH IT AGAIN EVEN AFTER FINDING IT IN THE FIRST OF THE TABLE???OR SIMPLY TERMINATE IN THE FIRST TIME THE CONDITION SATISFIES??IF DOES TERMINATE THEN ERRONEOUS RESULT IS BOUND TO COME SINCE ONE MORE RECORS IS UNSELECTED.
SIMILARLY DOES THE WHERE CLAUSE CONTINUE SEARCHING EVEN AFTER HAVING FOUND THE CONDITION ALREADY ONCE IN THE TABLE??
PLEASE HELP ME IN THIS ASPECT.PLEASE CHECK THE TWO DIFFERENT CODES & ANSWER ACCORDINGLY..
SELECT * FROM SBOOK INTO SBOOK_WA.
  CHECK: SBOOK_WA-CARRID = 'LH' AND
         SBOOK_WA-CONNID = '0400'.
ENDSELECT.
SELECT * FROM SBOOK INTO SBOOK_WA
  WHERE CARRID = 'LH' AND
        CONNID = '0400'.
ENDSELECT.

Hi,
The Check condition will be true, so it will not going to display the records, it will fill the internal table.
In the Where condition it will fill the Internal table as well as it will display also.
Hope now your query is solved
Regards,
Dhruv Shah

Similar Messages

  • Issue in select query with where clause

    Hi guys,
    I'm facing an issue while using select query with the where clause. When I'm selecting all the data from the table it returns the correct result. But when I'm using the where clause to get the specific rows from the table it returns no rows. But the data I'm trying to fetch using the where condition exists in the table.
    Here is my query which causing the issue,
    select * from mytable where myfield = 'myvalue'
    But if I use the following query it returns the result correctly.
    select * from mytable
    Also the myfield value 'myvalue' exists in the table.
    I have tried by running this query in both SQL Developer and SQL Plus. I have tried this query in mssql as well. It works perfectly and returns correct result sets for both the queries I have mentioned above. I'm unable to predict the issue as I'm new to ORACLE. Please help.
    Thanks,
    Ram.

    Hi Ram,
    I experienced an issue similar to this with a varchar2 field. Some of our records had a hidden newline character at the end of them, which was making queries like the one below fail:
    select * from employees
    where email = '[email protected]'The best way I found to detect this was to use
    select 'XX'||email||'XX' from employeesTo make sure that there were no newlines. But that is just a guess. If you could provide some example table data and the outputs of your selects, it would be helpful.
    Jeff

  • Hierarchical query with where clause

    Hi,
    How can I query hierarchically a query with WHERE clause? I have a table with three fields session_id,id and root_id.
    When I try with the following query,
    select id, level from relation
    where session_id = 79977
    connect by prior id = root_id start with id = 5042;
    It gets duplicate values.
    I want the query to show in the hierarchical manner with a filter condition using WHERE clause. Please help me how can I achieve this. If you know any link that describes more about this, please send it.
    Thanks in Advance.
    Regards,
    -Parmy

    Hi Sridhar Murthy an others,
    Thanks a lot for your/the answer. It's working for me. It saved a lot of other work around without the proper knowledge of hierarchical query. Please send me any link that describes these issues in detail and also I hope as I have mentioned in the other message, same cannot be achieved on views or ( on two different tables ???)
    Any way thanks for your reply,
    It's working for me.
    With happiness,
    -Parmy

  • Query using where clause

    I am not able to run a SQL query using where clause.
    the query is as follows:
    I extract the text input by the user in a text field say 'a' and
    store it in string 'y'.
    String y= a.getText();
    //running the query
    Select A from B where B.x=y;
    how do we run a where clause when y is a string variable instead of value?

    Use the following :
    String y = a.getText();
    String query ="select A.CODE from Port A where A.NAME=" + "'" + y + "'" ;
    ResultSet rs= stmt.executeQuery(query);

  • Query Bean Where clause

    In Query Bean (Auto Customization Criteria) , OA FWK generate
    where clause automatically .
    I want to disable this criteria in some cases. Is there any way exists?
    (Disable means remove some condition )
    I want to see runtime query with where clause(In case of Query Bean) . Is there is any way to find out it?
    Thanks, Avaneesh

    You have couple of options to do this,
    1. You can use getCriteria API on the queryBean which will stop the query execution by framework and it's the responsibility of the developer to use the dictionary returned by getCriteria and bind the complete where clause yourself.
    2. You can use getNonViewAttrCriteria API on queryBean. This provides a dictionary of criteria on the column which are not mapped to a viewAttribute, for example if you want a poplist in the search region which has values like "Last one week", "Last 2 weeks", "Last 15 days" and so on and want to bind the criteria your self by interpreting the value selected.
    In this case, framework still binds the where clause for the other criteria's which are mapped to a vo based column in the table and expects the developer to bind the criteria for these non viewattribute mappings in the controller.
    I think your requirement fits in the second approach.

  • Change JDBC select SQL query's where clause at runtime

    Hi,
    I have one JDBC sender channel with Select SQL Query which helps in fetching data from JDE table. We have defined where clause to fetch some particular records i.e. if ABC = NULL then fetch the record.. and then update query is used to turn that flag to "Y" i.e. ABC ="Y" so that next time the channel don't pick the same records again.
    Now the problem is that if we want to fetch some records again whose flag has been set to "Y" we cannot change the select query again and again in the production environment.
    Is there any way to change the select query of the JDBC channel at runtime e.g. Picking up some flat file where the conditions for the particular records to be picked are defined (ID=123) and changing the WHERE clause of select query in the JDBC channel for those records to be picked without using BPM.
    Thank you!
    With regards,
    Simran

    Hi Simran,
    Yes, it is possible with the help of store procedure. In SQL Server there is a IF-Else Conditional block, which you can use inside store procedure. Create a SP with 2 additional parameter something like FlagReadAgain and KeyField. Pass the flag always as True or False. For the Key field pass the record key which you want to read again if you are passing the Flag as True else pass it as 0 or whatever.
    In the procedure check if the value of flag is True -> If yes, Read the entry with key name specified in where part.
    In the else part put the query which you are using for the normal flow.
    IF (FlagReadAgain) = TRUE
    BEGIN
       SELECT EmpName, EmpAddress
       FROM Employee
       WHERE EmpID = 'E001'
    END
    ELSE
       BEGIN
         SELECT EmpName, EmpAddress
         FROM Employee
         WHERE Status = 'N'
       END
    You may also use the approach which Srini mentioned. Create an application to restore any value to intial stage so that it can be picked up by XI when it poll again.
    Choose any approach which you like.
    Regards,
    Jitender Chauhan

  • In which order does the query's where clause condition is checked

    Hi All,
    can anyone tell me in which order does oracle evaluate the where clause condition?
    for ex: select * from users where user_type='Admin' and stauts='Enabled'

    user9981103 wrote:
    The conditions in the WHERE clause are checked in the reverse order of the given order.
    i.e; first it will check stauts='Enabled'* and then user_type='Admin'* for your given queryWhy do you believe that?
    If there is a sufficiently selective b-tree index on USER_TYPE, the optimizer would undoubtedly use that index to process the USER_TYPE = 'Admin' condition and then check the STATUS column.
    If there is a sufficiently selective b-tree index on STATUS, the optimizer would undoubtedly use that index to process the STATUS='Enabled' condition and then check the USER_TYPE column.
    If there is a composite b-tree index on (STATUS, USER_TYPE), the optimizer would use that index to process the two conditions nearly simultaneously, though technically the leading column of the index is evaluated first. Of course, if you reverse the order of columns in the index, you get a different evaluation order
    If there are bitmap indexes on STATUS and USER_TYPE, Oracle can combine the two indexes and evaluate the two conditions simultaneously.
    And that is leaving out tons of query plan options and other optimizer wrinkles.
    Justin

  • Simple Select query with 'where', 'and', 'between' clauses takes time

    Hi,
    I have a select query as below
    SELECT * FROM (SELECT a.*,ROWNUM currentStartRecord From (select ai_inbound.ai_inb_seq tableseq,'AI_INBOUND' tablename,'INBOUND' direction,ai_inbound.appl,ai_inbound.ai_date datetime,ai_inbound.ic_receiver_id pg_id,ai_inbound.ic_sender_id tp_id,ai_inbound.session_no,ai_inbound.ic_ctl_no,ai_inbound.msg_set_id msg_type,ai_inbound.appl_msg_ctl_no reference_no,ai_inbound.fg_version version,ai_inbound.msg_status status,ai_inbound.input_file_name,ai_inbound.output_file_name,ai_inbound.ack_file_name from ai_inbound where ai_inbound.appl = ? and ai_inbound.ai_date between ? and ? )a where ROWNUM <= 49)where currentStartRecord >= 0
    The above query takes longer time through application than expected when the date fields are passed whereas it works fine when no date fields are passed. We are using oracle9.2 version of the database. All the indexed columns and partitioned indexed columns are rebuild.
    Kindly let me know how can i tune up the query to improve the performance.
    Thanks

    Hi,
    I have a select query as below
    SELECT * FROM (SELECT a.*,ROWNUM currentStartRecord From (select ai_inbound.ai_inb_seq tableseq,'AI_INBOUND' tablename,'INBOUND' direction,ai_inbound.appl,ai_inbound.ai_date datetime,ai_inbound.ic_receiver_id pg_id,ai_inbound.ic_sender_id tp_id,ai_inbound.session_no,ai_inbound.ic_ctl_no,ai_inbound.msg_set_id msg_type,ai_inbound.appl_msg_ctl_no reference_no,ai_inbound.fg_version version,ai_inbound.msg_status status,ai_inbound.input_file_name,ai_inbound.output_file_name,ai_inbound.ack_file_name from ai_inbound where ai_inbound.appl = ? and ai_inbound.ai_date between ? and ? )a where ROWNUM <= 49)where currentStartRecord >= 0
    The above query takes longer time through application than expected when the date fields are passed whereas it works fine when no date fields are passed. We are using oracle9.2 version of the database. All the indexed columns and partitioned indexed columns are rebuild.
    Kindly let me know how can i tune up the query to improve the performance.
    Thanks

  • Af:query - change where clause

    Hi,
    In my form I have af:query based on a view.
    also I have a checkbox that indicates to add or remove sql statements from the 'where clause' of the view.
    for example:
    my view query is "select * from employees where employees.kod_emp>0"
    I need that in case the checkbox is checked the view will look like this:
    "select * from employees where employees.kod_emp>0 *and employees.kod_dept = :dept_id*"
    and when the checkbox is unchecked the view will return to the original query.
    how could I implement it using the same af:query component?
    Edited by: 971832 on 02:38 10/12/2012
    Edited by: 971832 on 02:39 10/12/2012

    if i getting you correctly means add setnamedwhereclause based on your condition.
    write customer method in AM
    get your viewobject in Application Module.
    vo.setNamedwhereClause("bindattrubute" , " value" );
    vo.executequery();call this method on valuechangelistner of your check box.

  • How to reverse where clause condition? please

    Hello Good Morning,
    i have below query which is working fine,
    update t
    set skipjet='Yes'
    from  mytable t join mychildtable C on t.ssn=c.ssn
    where
    t.ChannelCd ='OB Calls' AND t.PlanBlance BETWEEN c.MinSalary  AND  c.MaxSalary
    but my problem here is, i have to set skipjet='Y' when the above where clause not met (like opposite way)
    Please advise?
    Thank you in Advance
    Asita

    Dear Milano, 
    I did an example and i got the result that you needed.
    declare @mytable table (ssn int,ChannelCd varchar(50),PlanBlance money,skipjet varchar(3))
    declare @mychildtable table (ssn int,MinSalary money,MaxSalary money)
    insert into @mytable(ssn,ChannelCd,PlanBlance,skipjet) values (1,'OB Calls',800.00,'NO')
    insert into @mytable(ssn,ChannelCd,PlanBlance,skipjet) values (1,'OB Calls2',800.00,'NO')
    insert into @mychildtable(ssn,MinSalary,MaxSalary)values(1,600.00,800.00)
    update t set skipjet='Yes'
    from
    @mytable t
    where
    not exists (
    Select * from
    @mychildtable C
    where
    t.ssn=c.ssn and
    t.ChannelCd ='OB Calls' AND
    t.PlanBlance BETWEEN c.MinSalary AND c.MaxSalary
    Select * from @mytable
    Result:
    ssn         ChannelCd                                      PlanBlance           skipjet
    1           OB Calls                                           800,00                NO
    1           OB Calls2                                         800,00                Yes
    (2 row(s) affected)
    Ricardo Lacerda
    Don't forget to mark helpful posts, and answers. It helps others to find relevant posts to the same question.

  • Values from a Multi-Select in the where clause of a Select statement

    I have a web page that solicits query parameters from the user.
    The selections that the user makes will populate the WHERE clause of a Select statement.
    One of the controls on the page is a multi-select control.
    When this page posts, I would like to execute a Select statement wherein the selected values from this control appear in the .. Column IN ( <list here> ) portion of the WHERE clause.
    This is an extremely common scenario, but I cannot seem to locate a how-to or message thread that addresses this specific case.
    I have an idea that it may involve dynamic SQL or Execute Immediate, but cannot seem to pin down the answer.
    Any help would be greatly appreciated!

    anonymous - As illustrated here: Re: Search on a typed in list of values
    Scott

  • Update table based on a select with a where clause

    I am trying to update a table only for records where i have a status of changed.
    Using the following code the update changes all the records putting in blank data if it is outwith the where clause.
    ideas?
    -- Update changed records
    UPDATE IP_SURVEY_ACTIVITY_REG_NO old
    SET (
    old.SLPN,
    old.SURVEY_DATE,
    old.SEQUENTIAL_REF_NUMBER,
    old.TOTAL_NUM_OF_SAMPLES,
    old.TOTAL_NUM_OF_ASSOC_SAMPLES,
    old.AIR_TESTS,
    old.REMARKS,
    old.SURVEY_DETAILS,
    old.FURTHER_SURVEY_DETAILS,
    old.GENERAL_COMMENTS) =
    (SELECT
    new.SLPN,
    new.SURVEY_DATE,
    new.SEQUENTIAL_REF_NUMBER,
    new.TOTAL_NUM_OF_SAMPLES,
    new.TOTAL_NUM_OF_ASSOC_SAMPLES,
    new.AIR_TESTS,
    new.REMARKS,
    new.SURVEY_DETAILS,
    new.FURTHER_SURVEY_DETAILS,
    new.GENERAL_COMMENTS
    FROM IP_SURVEY_ACTIVITY_REG_NO_INT new
    WHERE new.load_id = v_load_id
    AND new.status = 'CHANGED'
    AND new.sarn = old.sarn);
    cheers bjorn

    The EXISTS claue just needs to be added to your original query as a predicate on the ip_survey_activity_reg_no table. somethign like:
    UPDATE ip_survey_activity_reg_no old
    SET (old.slpn, old.survey_date, old.sequential_ref_number,
         old.total_num_of_samples, old.total_num_of_assoc_samples,
         old.air_tests, old.remarks, old.survey_details,
         old.further_survey_details, old.general_comments) =
                         (SELECT new.slpn, new.survey_date,
                                 new.sequential_ref_number,
                                 new.total_num_of_samples,
                                 new.total_num_of_assoc_samples, new.air_tests,
                                 new.remarks, new.survey_details,
                                 new.further_survey_details,new.general_comments
                          FROM ip_survey_activity_reg_no_int new
                          WHERE new.load_id = v_load_id and
                                new.status = 'CHANGED' and
                                new.sarn = old.sarn)
    WHERE EXISTS (SELECT 1 FROM ip_survey_activity_reg_no_int new
                  WHERE new.load_id = v_load_id and
                        new.status = 'CHANGED' and
                        new.sarn = old.sarn)An updateable join view is similar, except you just join the two tables. Assuming that sarn is the primary key of ip_survey_activity_reg_no_int, or is at least declared as unique in that table, then the update of the join would look something like:
    UPDATE (SELECT old.slpn oslpn, old.survey_date osurvey_date,
                   old.sequential_ref_number osequential_ref_number,
                   old.total_num_of_samples ototal_num_of_samples,
                   old.total_num_of_assoc_samples ototal_num_of_assoc_samples,
                   old.air_tests oair_tests, old.remarks oremarks,
                   old.survey_details osurvey_details,
                   old.further_survey_details ofurther_survey_details,
                   old.general_comments ogeneral_comments,
                   new.slpn nslpn, new.survey_date nsurvey_date,
                   new.sequential_ref_number nsequential_ref_number,
                   new.total_num_of_samples ntotal_num_of_samples,
                   new.total_num_of_assoc_samples ntotal_num_of_assoc_samples,
                   new.air_tests nair_tests, new.remarks nremarks,
                   new.survey_details nsurvey_details,
                   new.further_survey_details nfurther_survey_details,
                   new.general_comments ngeneral_comments
            FROM ip_survey_activity_reg_no old, ip_survey_activity_reg_no_int new
            WHERE new.sarn = old.sarn and
                  new.status = 'CHANGED' and
                  new.load_id = v_load_id)
    SET oslpn = nslpn,
        osurvey_date = nsurvey_date,
        osequential_ref_number = nsequential_ref_number,
        ototal_num_of_samples = ntotal_num_of_samples,
        ototal_num_of_assoc_samples = ntotal_num_of_assoc_samples,
        oair_tests = nair_tests,
        oremarks = nremarks,
        osurvey_details = nsurvey_details,
        ofurther_survey_details = nfurther_survey_details,
        ogeneral_comments = ngeneral_commentsHTH
    John
    Message was edited by:
    John Spencer
    Honest, Eric wasn't there when I posted :-)

  • Sub query in where clause

    I have the following code which keeps throwing an error:
    select distinct game_code, count(player_id)
    from customer_data.cd_nhl_gm_tender_stats t
    where 
    (select distinct player_id
    from customer_data.cd_nhl_gm_tender_stats
    where season_id = 200818)
    group by game_code, player_id
    having count(player_id) > 1Error states that there's a missing expression right before the group by, any thoughts?
    The subquery is basically used to find a unique player_id value, (so there's no duplicates rows in the result set.)
    Sample data;
    customer_data.cd_nhl_gm_tender_stats t
    Game_code player_id
    88484           545454
    88484           545454
    88484           545454There's obviously other columns in the table above, but ultimatly there is mutliple rows for each game.
    I'm just trying to return each game_code where more then one player_id is found.

    Michaels2 i'm not sure your code is doing quite what i need
    select   *
      from   (select   t.*,
                       count (distinct player_id) over (partition by game_code) cnt
                from   cd_nhl_gm_tender_stats t where season_id = 200818)
    where   cnt > 1The subquery in the from clause is just selecting every game_code where season_id 200818 and then you add a where clause where cnt > 1 in the main query(whcih doesn't accomplish what I really wanted). What I need is the count of distinct player_id where season_id = 200818 AND cnt of (distinct player_id) over (partition by game_code) cnt > 2**. The issue i'm having is, that i'm not quite sure how to format the code to get these results.
    To clairfy what i need one more time ( i didn't explain things well in my original post)...
    I want each game_code where a player_id count is greather then two. And as stated earlier the gm_tender_stats table has numerous entries with the same player_id for the same_game code, which is why this makes writing this query a little more difficult.
    Edited by: user652714 on May 11, 2009 7:52 AM

  • The issue with using the multiple columns sub-query in WHERE clause

    Hi All,
    my database version is 10.2.
    the problem i am trying to deal with is that when I use multiple column sub-query in the WHERE clause of the SELECT statement, the actual row number returned from the sub-query is different from the whole statement.
    And what I found is that, whenever there is NULL in any of those columns returned from the SUB-QUERY, the outer query will just return NULL for that whole row.
    Here is an example:
    select empno, ename, job, mgr, hiredate, sal, deptno from EMP
    intersect
    select empno, ename, job,  mgr, hiredate, sal, deptno from t;
    7782     CLARK     MANAGER     7839     09-JUN-81     2450     10
    7839     KING     PRESIDENT  NULL  17-NOV-81     5000     10
    7934     MILLER     CLERK     7782     23-JAN-82     1300     10
    select * from EMP where (EMPNO, ENAME, job, MGR, HIREDATE, SAL, DEPTNO) in (
    select empno, ename, job, mgr, hiredate, sal, deptno from EMP
    intersect
    select empno, ename, job,  mgr, hiredate, sal, deptno from t);
    7782     CLARK     MANAGER     7839     09-JUN-81     2450          10     
    7934     MILLER     CLERK     7782     23-JAN-82     1300          10     If I specifically deal with the NULL situations for the columns which might return NULL, I can get the result right.
    select * from EMP where (EMPNO, ENAME, job, NVL(MGR,-1), HIREDATE, SAL, DEPTNO) in (
    select empno, ename, job, nvl(mgr,-1), hiredate, sal, deptno from EMP
    intersect
    select empno, ename, job,  nvl(mgr,-1), hiredate, sal, deptno from t);
    7782     CLARK     MANAGER     7839     09-JUN-81     2450          10     
    7839     KING     PRESIDENT  null   17-NOV-81     5000          10     
    7934     MILLER     CLERK     7782     23-JAN-82     1300          10     the problem is that, I feel this is a very lame way of handling it.
    So, I wonder or am asking if there is any better or standard way to do it?
    any help would be highly appreciated.
    Thanks

    Hi,
    As you discovered, INTERSECT treats NULL as a value, but IN does not.
    What you did with NVL is one way to handle the situation. If there was a chance that any of the columns could be NULL, then you might prefer something like this:
    select      *
    from      EMP
    where      ( EMPNO      || '~' ||
           ENAME      || '~' ||
           job           || '~' ||
           MGR           || '~' ||
           TO_CHAR (HIREDATE, 'DD-MON-YYYY HH24:MI:SS')
                    || '~' ||
           SAL           || '~' ||
           DEPTNO
         ) in (
              select  EMPNO      || '~' ||
                     ENAME      || '~' ||
                   job     || '~' ||
                   MGR     || '~' ||
                   TO_CHAR (HIREDATE, 'DD-MON-YYYY HH24:MI:SS')               
                        || '~' ||
                   SAL      || '~' ||
                   DEPTNO
              from     emp
             intersect
              select  EMPNO      || '~' ||
                     ENAME      || '~' ||
                   job     || '~' ||
                   MGR     || '~' ||
                   TO_CHAR (HIREDATE, 'DD-MON-YYYY HH24:MI:SS')               
                        || '~' ||
                   SAL      || '~' ||
                   DEPTNO
              from      t
             );This assumes that you can identify some string (I used '~') that never occurs in the strings in these tables.
    This is implicitly converting the NUMBERs. That's usually not a good thing to do. but explicitly converting them would make this even more tedious.
    You should explicitly convert any DATEs to strings, however. Depending on your default format, and your data, you might get away with implicit conversions even for DATEs, but don't bet on it.
    If you had to do this often, you might consider writing a user-defined function:
    delimited_string (empno, ename, job, mgr, hiredate, sal, deptno) would return a string like
    '7839~KING~PRESIDENT~~17-NOV-1981~5000~10'
    This will make the coding easier, but beware: it will make the execution slower.

  • Limit size (in byte) of SELECT-OPTIONS in WHERE clauses

    hi,
    as far as I know there is a limit size (in byte) for SELECT-OPTIONS used in WHERE clauses. Is it true? What is the limit? If the SELECT-OPTIONS is based on lifnr (character type, 10 long) is the following calculation valid?
    sign - 1 byte
    option - 2 bytes
    low - 10 bytes
    high - 10 bytes
    23 bytes all together for one line, is this valid?
    thanks
    ec

    Hi,
    Check this link..
    https://forums.sdn.sap.com/click.jspa?searchID=6896082&messageID=2891787
    Regards,
    Omkar.

Maybe you are looking for