default_where clause

Hello

I have a requirement where if the user types in a part of the string, it must question him recordings using as and %.

Name of base table employees.
If the user types in "Jo" as name, records for which the string Jo must be returned.

I have my QUERY before trigger like this.
r_String :=  NAME_IN ('employees.firstname')
  if r_String is not null then
      
      THEN
       sub_where :=                 
                ||'(firstname LIKE ''' ||'%' || r_string ||'%'||''')';
         
           
        
      END IF; 
When I look at the query running using TOAD,
select emp_id,first_name,last_name from employees 
     where (firstname LIKE '%Jo%') and (firstname = :1);
I do not understand where and why (firstname =: 1) comes. The query returns all rows.

Thank you

Hello

I guess firstname is your DB field and then when you enter enter_query mode and type something in this area and where clause, then it takes as an argument for this field (firstname) Db and puts it in where clause.

Ideal thing to do would be to create an element of database field not and ask the user to enter the name in this field and then question.

something like that
declare r_string varchar2 (100);
Start
r_String: = NAME_IN('DHIRAJ.) ITEM11'); item11 here is an article from the database for dhiraj datablock
If r_String is not null
THEN
Set_Block_Property ('YES', default_WHERE, ('name AS' | ")) ' ||' %' || r_string | » %'||''''||''));
END IF;
end;

Published by: Dhiraj Madan on May 13, 2009 10:08

Tags: Oracle Development

Similar Questions

  • Block based on the stored procedure cannot modify Default_where clause

    Hi all

    I tried to create a block based on the stored procedure that it works very well with the result set for the refcursor. But if I need to add filters on the block using where clause in the palette of goods or

    using the property block set in where clause, it does not error but does not review filters .

    tried everything to you please let me know. This is a restriction whereby we can set filters on the block when we create the block based on the stored procedure.

    Thank you

    Check in Form Builder Help:

    Creating a block of data from a procedure that uses a ref cursor

    ... You can't pass a WHERE or ORDER BY clause clause in a stored procedure.

    But you can send your WHERE condition using the query Source Arguments.

    If the procedure is on the side of the database (not in the forms module), ensure that the procedure is not vulnerable to injection of SQL code.

    Kind regards

    Zlatko

  • Hi everyone how can filter query on the form

    I a request form based on a database of datablock table and I use some items based on the datablock control to run the query, the user can use a portion of this Articles to filter the query, what is the best way to implement this form I have tried using the set_block_property default _where but is not working If the user is using all of the elements to filter the query, which is better use of the cursor or the default_where and how.

    Hello

    You can try to use the LIKE operator instead of =.

    Str_Condition: = ' AS "' |:. . '%'' AND LIKE ''' || :. || '%'''; etc.

    And use it as the DEFAULT_WHERE clause.

    Manu.

  • Oracle error: How do you change forms Datablock data type of query?

    Hey Experts.

    I am a newbie in Oracle Forms.

    I have a problem regarding the block of data in database.

    I need to change the data by NO block due to the overflow of information in our database.

    Question is how/where can I start to change/modify the codes?


    Thanks in advance!

    Bellerose

    Baski101 wrote:

    ...

    I deleted the relationship between the blocks and the module is now running. I want to ask you the questions and following...

    1. What does the relationship your datablock/s? It runs now, but I want to know why.

    2 How/where you start updating of the DEFAULT_WHERE clause? I mean, I have to create another program unit and ignore the 'old'? Change the units of the old program? Where and what I remove/add?

    ...

    Question 1: A relationship only applies to "Base table data blocks."  Relationships allow synchronizations between master and detail of data blocks.  Basically, this means that when you select a record in the block Master, the retail block will automatically display folders related to the selected record of the master.  In earlier versions of Oracle Forms, the developer had to manually perform this synchronization.

    Question 2: Connection to block non-database - you do not use the DEFAULT_WHERE property.  For blocks of the Base Table, it depends on your needs.  For example, if your form has a search function and shows you a canvas "before" that allows the user to enter criteria for the search, and the user then had to click a button to perform the search, you would put your code in triggering When button button.  If your username is simply the form view application [for example: Forms 6i and earlier - F7 (enter query) or F8 (run the query) and Forms 9i or higher - F11 (enter query) or Ctrl + F11 (run the query)] then there is no need to change the DEFAULT_WHERE because the forms accomplishes this task for you.  Another example would be - if you have a block of the base table, but the user has the ability to use the elements in array to another basic search - you can use the motion of a block of the base table to change the selected property DEFAULT_WHERE to use the elements of the other base table to filter your data.

    I hope this helps.

    Craig...

  • Problem with the join relationship condition master / detail

    Hello
    I need to join with master detail such as if there is no trace of the foreign key in detail to the primary master key, the foreign key must be attached to another column based on certain conditions in the master. For example:

    Control columns: pk1, rk1, rk2
    Detail of the columns: fk1, a, b, c

    I created a relationship with detail with the join condition, pk1 = fk1 in master.
    But according to value rk1, I actually join fk1 to rk2 in master and if the condition fails then join the pk1. I can't put this condition in the relationship that the form does not accept complex join conditions.

    I hope that my example has not confused everyone.

    Can someone help me to achieve this goal.

    TIA

    TIA,
    I agree with DM, rather than using the RELATIONSHIP between the blocks that I would create logic to manually set the DEFAULT_WHERE clause on the block of RETAIL with the criteria you need to MASTER block. This can be a little difficult if you want to form work the same way if you had defined a relationship because you will have to create all the triggers event coordination. The most difficult part is to choose the right triggers to coordinate the synchronization when a user accesses a folder of master to another. For just the basics (the block of retail is questioned when the user navigates to the retail block), you could do the following:
    1. create a When-new-folder-Instance trigger on the Master block to capture the relevant details to query the block detail and define the DEFAULT_WHERE.
    2 create a trigger in a times - news - block - Instance on the block of retail to run the query on the block of retail and display the details records.

    For example:

    /* Sample When-New-Record-Instance trigger */
    DECLARE
         v_temp_where          VARCHAR2(500); /* make larger if needed. */
    BEGIN
         IF ( :MASTER_BLOCK.First_Item IS NOT NULL ) THEN
              /* this is needed for when the user navigates to a NEW record in the MASTER Block. */
    
              /* Add your conditional logic here to determine how to build your WHERE clause */
              IF ( RK1 = 'Dependent Values' ) THEN
                   v_temp_where := 'PK1 = FK1';
              ELSE
                   v_temp_where := 'RK2 = FK1';
              END IF;
    
              Set_Block_Property('DETAIL_BLOCK',ONETIME_WHERE,v_temp_where);
              /* If you are using Forms 6i, the ONETIME_WHERE property is not available so you will have to */
              /* use the DEFAULT_WHERE property instead. */
         END IF;
    END;
    
    /* Sample When-New-Block-Instance trigger
    BEGIN
         /* This sample code assumes the user has not navigated to a New Record */
         /* so there will always be a NOT NULL default where assigned to the DETAIL BLOCK.*/
         Clear_Block(ASK_COMMIT); /* just in case the user made changes... */\
         Execute_Query;
    END;
    

    Please understand it is the EXAMPLE of Code and is intended to be a starting point for you - not the complete solution.

    I hope this helps.
    Craig...

    If a response is appropriate or useful, please mark accordingly

  • Tweaking of default query so that the two fields are searched equally

    I have a 'Customer Details' data block that contains the field "mobile1" and "mobile2" for customer's cell phone numbers. When a customer enters into a mobile number or a field, I need to check the two mobile fields to see if this number exist as the primary contact number or secondary to any client of the query.
    I've tried to set a default_where clause, but oracle automatically adds to him whenever a number is entered in the field, making me a little trouble at the head!

    For example, if I say something like, WHERE MOB1 =: BLOCK. MOB1 OR = MOB1: BLOCK. Mob 2 (do not question true, just one example)
    And I took #-# in the field of mobile2,.
    Forms adds to this "AND mob 2 =: 1'"

    which causes the query to return nothing, since there is no entry mob 2 is equal to the registered number, even if there is an entry MOB1 bearing the same number.

    Is there a way to change the AND a RC for the query?

    If not, can anyone suggest how I can get the result, I'm looking for without having to change my block to a block not DB and duplicate me all the default features of Oracle Forms manually?

    Thanks in advance,

    A

    Do something like this in the PRE-QUERY-trigger:

    IF :BLOCK.MOBILE1 IS NOT NULL THEN
         SET_BLOCK_PROPERTY('BLOCK', ONETIME_WHERE, 'MOBILE1 LIKE ''' || :BLOCK.MOBILE1 ||  ''' OR ' ||
                                                    'MOBILE2 LIKE ''' || :BLOCK.MOBILE1 ||  '''');
    
    END IF;
    :BLOCK.MOBILE1:=NULL;
    
  • command 'execute_query '.

    Is it possible to run the command "execute_query" when you use a database block not in your
    form.

    Thank you
    Rajat

    Rajat,
    The short answer is Yes, however, it depends on how you have your data block in place. If the data block is based on a table or a view, the values in the other basic elements table must relate to a column in the table or view. Using the values of the other base table elements, you can change the DEFAULT_WHERE clause data block and then use EXECUTE_QUERY() to query the data block using these basic values another table.

    I hope this helps.
    Craig...

    -If my answer or the answer of another useful answers your question please note the response accordingly. Thank you!

  • Where clause in the "default_where" of get_block_property is not cancelled...

    Hello

    I developed a form with two blocks.

    The first - block of non - database contains the criteria.

    Database of the other - block-displays the records according to the inserted.

    Also, there is a button that executes the query criteria.

    The code of the BUTTON WHEN PRESSED is as follows:

    declare

    v_where varchar2 (3000);

    Start

    v_where: = null;

    go_block ('EKKREMOTHTES_AIT_TSG');

    clear_block (no_validate);

    v_where: = get_block_property ('EKKREMOTHTES_AIT_TSG', default_where);

    If: blk_criteria.site_id is not null then

    v_where: = v_where |' and site_id = "'|: blk_criteria.site_id | ''';

    end if;

    If: blk_criteria.yphr_klimakio is not null then

    v_where: = v_where |' and yphr_klimakio = "'|: blk_criteria.yphr_klimakio | ''';

    end if;

    If: blk_criteria.send_date_from is not null and: blk_criteria.send_date_to is not null then

    v_where: = v_where |' and send_date between to_date('''|| to_char(:blk_criteria.send_date_from,'dd/mm/yyyy')||''',''dd/mm/yyyy'') and

    to_date('''|| to_char(:blk_criteria.send_date_to,'dd/mm/yyyy') | " (', "dd/mm/yyyy)";

    end if;

    If: blk_criteria.eq_group1 is not null then

    v_where: = v_where |' and eq_group1 = "' | : blk_criteria.eq_group1 | " ' ;

    end if;

    If: blk_criteria.eq_type1 is not null then

    v_where: = v_where |' and eq_type1 = "' | : blk_criteria.eq_type1 | " ' ;

    end if;

    If: blk_criteria.eq_group2 is not null then

    v_where: = v_where |' and eq_group2 = "' | : blk_criteria.eq_group2 | " ' ;

    end if;

    If: blk_criteria.eq_type2 is not null then

    v_where: = v_where |' and eq_type2 = "' | : blk_criteria.eq_type2 | " ' ;

    end if;

    blk_def_where ('EKKREMOTHTES_AIT_TSG', v_where);                                    / * a form routine that makes the set_block_property(<block>,default_where) * /.

    do_key ('execute_query');

    end;

    The above code works when the user inserts the criteria for the first time. Later when the user deletes certain criteria - clear criteria in the block of criteria-

    and he pushed the button of the query results are exactly the same...

    After have debugged the problem, clause v_where is not nullied (do not get the value zero) in order to get the new criteria.

    Can you identify the error?

    Note: I use Oracle Forms 10 g Db 11 g v.2

    Thank you very much

    SIM

    SIM,

    The procedure "blk_def_where" sets the block where clause by using the DEFAULT_WHERE or the ONETIME_WHERE constanct?  Gets it to the user that the same results as the DEFAULT_WHERE sets the property WHERE permanently so the second time through, the 'v_where' is NOT null.  Check your BLK_DEF_WHERE procedure and if it does not use the ONETIME_WHERE constanct, change isn't.  The alternative would be to put DEFAULT_WHERE = NULL after the call to the built-in EXECUTE_QUERY.

    Craig...

  • Oracle Forms - "DEFAULT_WHERE" is lost when used an apostrophe

    Hi all

    I faced a problem with Oracle Forms for a long time and I have no idea of what is happening so far.

    I have a block based on a stored table. I used the following statement to set the WHERE clause for this block:

    set_block_property ('MTI', default_where, l_where);

    Variable l_where has the following form:

    l_where: = ' WHERE art_nr IN (')

    || "SELECT the md5 ma_nww_ww_dat art_nr."

    || 'WHERE trunc (sysdate) BETWEEN md5.gueltig_ab AND md5.gueltig_bis'

    || ' AND UPPER (md5.art_bez_altern) AS "' | : gi_intern.txt_match_name | '%''';

    The problem arises when the user tries to search for an article, using the MATCH_NAME an apostrophe (for example, GRANT). In this case, the where conditions are lost and all records are returned as a result.

    Could you help me understand what the problem is?

    Thank you very much!

    Raluca

    I think you should put the link reference inside the clause, instead of its value.

    I mean: If you set the where_clause ' like mycol. "' | : my_item |' % "'

    you to hard-code the value of: my_item at the time of the set_block_property.

    I could do this instead (simplifying):

    l_where: = ' upper (md5.art_bez_altern) like: gi_intern.txt_match_name | » %'' ';

    Thus, the: my_item value will be assessed at the moment execute_query, and I think that forms will address the apostrophe in the variable to better link if hardcode you just what you do in your example.

    It is, forms will treat it in the same way it would if you were query mode enter and entering a filter: with variable binding.

    In fact, I think that this kind of filter you can even enter at the time of the design (with single apostrophes)

    In addition, liaison is supposed to be better for the performance of subsequent queries.

  • problem with default_where

    Hi all
    I create a new form name is (inq_items)
    This form contains a block of two canva and two window
    block 1-> name (blkkey) no block database-> canva (search)--> window1
    block 2-> block of database name (items)-> canva (items)-> window2

    in canva (search), I create a txt element to query
    and I create a button to push that button contains this query
    trigger (when-pressed key)
     
    DECLARE
       WHERE_CLAUSE   VARCHAR2 (3000) := '';
    BEGIN
       WHERE_CLAUSE := '(CODE = :BLKKEY.CODE          OR :BLKKEY.CODE                IS NULL               )AND '
                 ||'(BAR_CODE       = :BLKKEY.BAR_CODE      OR :BLKKEY.BAR_CODE           IS NULL               ) AND '
                 ||'(CAT_NO       = :BLKKEY.CAT_NO          OR :BLKKEY.CAT_NO                 IS NULL                     ) AND '
                 ||'(SUB_CAT_NO  = :BLKKEY.SUB_CAT_NO      OR :BLKKEY.SUB_CAT_NO              IS NULL               ) AND '
                 ||'(SUPPLIER_NO  = :BLKKEY.SUPPLIER_NO      OR :BLKKEY.SUPPLIER_NO              IS NULL               ) AND ';
       SET_BLOCK_PROPERTY ('TBL_WHS_ITEMS', default_where, WHERE_CLAUSE);
       EXECUTE_QUERY;
    END;
    I need to this query runs given to another block (items), how can I do?
    Sorry for my English
    Thank you to

    Andreas is correct - your where clause has a problem at the end.

    We will build cleaner where clause:

    DECLARE
    WH_CL VARCHAR2(3000);
    AND_TXT VARCHAR2(5);
    --
    PROCEDURE CHECK_PART(COL_NAME VARCHAR2) IS
    BEGIN
    IF NAME-IN('BLKKEY.'||COL_NAME) IS NOT NULL THEN
    WH_CL := WH_CL || AND_TXT
    || COL_NAME ||'= :BLKKEY.' || COL_NAME;
    AND_TXT := ' AND ';
    END IF;
    END CHECK_PART;
    --
    BEGIN
    CHECK_PART('CODE');
    CHECK_PART('BAR_CODE');
    CHECK_PART('CAT_NO');
    CHECK_PART('SUB_CAT_NO');
    CHECK_PART('SUPPLIER_NO');
    SET_BLOCK_PROPERTY ('TBL_WHS_ITEMS', default_where, WH_CL);
    EXECUTE_QUERY;
    END;

    If you ask how to make sure at least one of your BLKKEY items is not null, you can add this before the SET_BLOCK_PROPERTY:

    IF WH_CL IS NULL THEN
    MESSAGE(' PLEASE ENTER AT LEAST ONE FIELD');
    RAISE FORM_TRIGGER_FAILURE;
    END IF;

    .. .and why people use tabs like this in their code?

  • Change the clause where in a datablock

    I want to change the clause where in a datablock shaped 10g
    I want that to_date(champdb,'dd/mm/yyyy') =: champforms
    I do
    set_block_property ('filling', DEFAULT_WHERE, 'to_date(dateplomb,'dd/mm/yyyy') = decode(:dateplombage,null,DATEPLOMB,'||:dateplombage||')');
    set_block_property('plombage',DEFAULT_WHERE , 'trunc(dateplomb) = decode(:dateplombage, null , trunc(dateplomb),:dateplombage)');
    
  • Could I get a free replacement for the phone that was diagnosed with the liquid damage clause?

    Hello

    It's Vincent of the India.

    My iPhone 5 exploded randomly while I was listening to music, about 2 weeks back. Don't turn on since.

    The inspection service center claimed to have found traces of liquids on "residents" of the device and thus were classified in accordance with the clause of liquid. I was asked to pay more than the price of the phone for placement.

    I understand that there is no free replacement phone or the motherboard, my question is how safe are that it is not a fault of Interior?

    The phone is 4 months warranty, purchased online. No physical damage. I have no reason to lie when I say that I don't 'accidentally' drop it in the water. Why can't they consider a real case? In addition, what might have caused the problem?

    Some experts of the forum online YouTube wrote this saying, "close the seat or the higher in the order." He has not just you being stuck with a defective product. Exactly how to do this, if I could?

    Everything what I'm trying to understand is why should it unlucky customers such as I have pay the price for something that I'm sure that's not a fault on my side? Should not be a system in place for situations like this?

    Other iPhone - official Apple Support repairs

    How much will cost to fix an iPhone 6 with water damage?

    more

    cost of water damaged iphone

  • SQL clause 'or '.

    Hello

    I am creating a search function vi, which allows the user to search for some columns in my database with the input control 1. Is it possible to do if some of the columns have different data as string types & digital?

    I have this here vi which I use to interrogate some of the column of the same type of data in the database. It seems that there is something wrong with my 'or' clause. When the input is b / l, the part of the data displayed is correct since the firstname column won't work & the clause "and" name also will not work, resulting in all data displayed. However, if I remove the or clause for my lastname, firstname column column will work but my data for the device will not work. When the input is 1, all occupants in my database will be displayed & they will all have the same unit even if they live in a different unit. However, if I delete my request first name, leaving only the unit, it works perfectly.

    I believe that the problem happens if I use the or clause of these terms before the last clause "or" & after the last 'or' clause in my query will not work. The Address.AddID AND = PersonDetails.AddID AND PersonDetails.Status = 'active' is ignored if it is not the last clause 'or '.

    IM using data select vi to recover my data, because it is something strange happens if I use the sql execute query vi. below is my sql query & attached is my base data & vi.

    WHERE Address.Unit = 'b' or PersonDetails.FirstName LIKE '% b %' or PersonDetails.LastName LIKE '% b %' AND Address.AddID = PersonDetails.AddID AND PersonDetails.Status = 'active '.

    Thanks for reading & hope someone knows why this happens.

    Kind regards

    Wayne

    I can't open your files (got an earlier version), but I suppose you use an .mdb you have access? Do the work in question here? I have several times to build an access issue and switched to the sql mode to copy in LabView.

    Maybe a couple of brackets to fix the problem. It should not be necessary, but it might help to use WHERE ([or CLAUSES]) AND ([CLAUSES AND])

    /Y

  • where clause

    Hi Master,

    I have a small doubt regarding where clause of a select query. I have a select query with 3 tables. I joined like that.

    Select * from

    ABC one

    XYZ x

    PQR p

    where a.column1 = b.column1

    and a. column 2 = value

    and b.coumn1 = c.column1

    and c. column2 = value

    and b. Column3 certain condition

    How oracle work where condition? average which condition will run first... is there a systematic order? Please advise... !!

    Concerning

    AR

    Hi, Ar,

    874273 wrote:

    Hi Master,

    I have a small doubt regarding where clause of a select query. I have a select query with 3 tables. I joined like that.

    Select * from

    ABC one

    XYZ x

    PQR p

    where a.column1 = b.column1

    and a. column 2 = value

    and b.coumn1 = c.column1

    and c. column2 = value

    and b. Column3 certain condition

    How oracle work where condition? average which condition will run first... is there a systematic order? Please advise... !!

    Concerning

    AR

    There is no predefined order.  The optimizer uses any order that it deems will get faster results.  You can check the execution plan to see how she chose in a particular case.

    SQL is a non-procedural language.  When you write code in a procedural language, tell you How you want to do something.  When you write code in SQL, you say what you want to do.

  • with the clause against table inline

    Dear Experts,

    With clause or inline table are identical from the point of view of performance.

    What query is better?

    query with clause

    with table_getbuckets as
    (
    SELECT * FROM TABLE(pack_activitymonitoring.f_getmatbuckets (start_settle_date,end_settle_date))
    )
    SELECT
          nvl(baludhar.pct,0) AS pctudhar
    FROM t_option opt
    LEFT OUTER JOIN table_getbuckets balinv ON
                opt.a_id = balinv.collateral_a_id AND
                opt.s_id = balinv.s_id
    WHERE opt.for_principal=1
    
    

    query without a clause

    SELECT
          nvl(baludhar.pct,0) AS pctudhar
    FROM t_option opt
    LEFT OUTER JOIN (
                     TABLE(pack_activitymonitoring.f_getmatbuckets
                                                        (start_settle_date,end_settle_date))
      ) balinv ON
                opt.a_id = balinv.collateral_a_id AND
                opt.s_id = balinv.s_id
    WHERE opt.for_principal=1
    
    

    In this case, since you are using only the view inline once, I expect to exercise the same.

    For purposes of readability, I prefer the one that uses the WITH clause.

Maybe you are looking for