Set_block_property(' ',default_where,' ') built-in

db and dev 10g rel2 , xp
hi all,
if anyone could demonstrate this built-in to me , when using it with number and charachter or date text_fields ,
specially with (= and like) operators .
because i have a problem with using quotes with it . i do not know the roles for using quotes with it .
for in stance , i have the table emp , and two text items , one to execute the query on the block by the deptno column , and the other with date or charachter column like hiredate or ename , i think the two are the same .
if you could give me an example and demonstrate it please .
thanks in advance

If you are using forms items/parameters you can actually use them in the default where like bind variables and not care about quotes at all. Let's say you have a block with one number, one date and one char item (all non-basetable). You'd simply could
set_block_property('basetable_block', default_where, 'where num_col = :blk.num_item or char_col = :blk.char_item or date_col = :blk.date_item');as you can see no quote escaping no matter of the data type.
It get's a little bit harder when you are using PL/SQL variables as you cannot bind them like you can with items or parameters
set_block_property('basetable_block', default_where, 'where num_col = '||num_val||' or char_col = '''||char_val||'''');it get's worse with dates:
set_block_property('basetable_block', default_where, 'where date_col = to_date('''||to_char(date_val,'dd.mm.yyyy')||''',''dd.mm.yyyy'')');To demonstrate how escaping actually works we'll translate the where clauses the way they get sent to the database; assuming num_val has a value of 3, char_val has a value 'ABCD' and date_val has a value of 01.01.2013.
where num_col = '||num_val|| or char_col = '''||char_val||'''would be
where num_col = 3 or char_col = 'ABCD'
where date_col = to_date('''||to_char(date_val,'dd.mm.yyyy')||''',''dd.mm.yyyy'')would be
where date_col = to_date('01.01.2013','dd.mm.yyyy')If in doubt with escaping simply output the string to e.g. a file, and when it contains valid SQL you did everything right with the escaping.
cheers
EDIT: this is actually pen-and-paper writing of code; I didn't compile anything of the above so it might be that some of the ' are missing, but I guess you should get the point.
Edited by: christian erlinger on 27.02.2013 05:25

Similar Messages

  • Set_block_property default_where problem

    Dear proffessionals,
    during setting the set_block_property value for database block i'm facing next problem:
    1. Query select cr_pjid from acc_users where username='ACCBTPS121' give result
    CR_PJID 
    '26','63'2. Query select * from acc_accbtp_nova_view where ed_id=2 and to_char(pj_id) in ('26','63'); return 186 rows.
    3. Query: select * from acc_accbtp_nova_view where ed_id=2 and
                  to_char(pj_id) in (select cr_pjid
                  from acc_users
                  where username='ACCBTPS121'); doesn't return any row... :(
    So, set_block_property('acc_accbtp_nova_view',default_where,'ed_id = '||':global.org_dio_id and to_char(pj_id) in (select to_char(cr_pjid) from acc_users where username=user)'); doesn't work...
    Could anyone help me ?
    Thx in advance,
    Adnan
    Edited by: adnanBIH on Nov 20, 2010 10:25 AM

    and like this?
    DECLARE
      vStr acc_users.cr_pjid%TYPE;
    BEGIN
      SELECT cr_pjid
      INTO vStr
      FROM acc_users
      WHERE username=user;
      SET_BLOCK_PROPERTY('acc_accbtp_nova_view',DEFAULT_WHERE,'ed_id = :global.org_dio_id and to_char(pj_id) in ('||vStr||')');
    END;-Ammad

  • Re Set Set_Block_Property DEFAULT_WHERE value

    I have a Tabular form which have the invoice details with below two Buttons
    BTN_QUERY (WHEN-BUTTON_PRESSED) TRIGGER
    go_block('BLFRT');
    execute_query;BTN_UNRECEIPT (WHEN-BUTTON_PRESSED) TRIGGER
    if :system.mode like 'NORMAL' then
    go_block('BLFRT');
    Set_Block_Property('BLFRT',DEFAULT_WHERE,' BL_REC_FLAG IS NULL');
    execute_query;
    end if;As soon i click BTN_QUERY i get the data in the grid and also when i click BTN_UNRECEIPT also works fine.
    the problem is after clicking BTN_UNRECEIPT if i click BTN_QUERY it shows the filtered records and not all the records. i can understand it's because the value is set with BL_REC_FLAG IS NULL. how to clear this and show all records IN BLFRT when i click BTN_QUERY

    Hi,
    Try to use PRE-QUERY trigger and use
    Set_Block_Property('BLFRT',DEFAULT_WHERE,' BL_REC_FLAG IS NULL');
    on conditional bases
    Regards,
    Uzair Hasan Nizami

  • How can I query on a time field??

    Hi All,
    I have a time field (base table field) in my form. I use a format mask of HH24:MI for that field.
    If i put in "%10:00" in that field and query, the query returns rows correctly. But I canot ask my user to put in a "%" each time he/she queries. I have to do it from the form.....
    How can I do this programatically..I mean how do I write it in pre-query?
    Thanks in advance...
    Sowmya.

    Hi,
    Thanks for your reply...
    Unfortunately I already tried that..
    The problem was to compare only the time portions . And as soon as the user put in say "12:00" in the time field, the system defaulted it to 01-SEP-2002 12:00:00 .And it compared this to the database value which is wrong...
    I solved the problem by creating a non-base table item and then writing code in pre-query using set_block_property etc...and it worked !!
    Thanks for you response once again..
    Sowmya.
    How about using the Set_block_property(Default_where) built in? check the online help.

  • How to simulate F8

    Hi All,
    In the smartbar, there are Enter-Query button and Execute-Query button. When the user presses F7 or Enter-Query button, enter some values in the form, then presses F8 or Execute-Query button, the corresponding records will display.
    However, I don't want to use the smartbar, I want to create my own buttons to perform these functions. I know I can create two buttons with the code 'enter_query' and 'execute_query' respectively, but the 'hand-made' Execute-query button can only retrieves all records, and after pressing the 'hand-made' Enter-query button, the user has to press F8. But the user may not know this, so is there a way that I can create a button that simulates
    the F8 key?
    Thanks in advance

    All you will need to do is go over the items in the block collect the inserted value and use the set_block_property(Default_where) built in to set a where condition for your block and then execute the query.
    I think that using the default behavior that Forms gives you is simpler.

  • Pre-query set_block_property Default Where

    I need some information regarding
    SET_BLOCK_PROPERTY , DEFAULT_WHERE
    How it works
    I am using this code
    SET_BLOCK_PROPERTY('bank_recon',
         DEFAULT_WHERE, 'v_bankcode= ''' || :button.bankcode     || ''' and ' || 'v_chq= ''' || :button.chq_no ||
           '''');   but when I add one another condition not work
    SET_BLOCK_PROPERTY('bank_recon',
         DEFAULT_WHERE, 'v_bankcode= ''' || :button.bankcode     || ''' and ' || 'v_chq= ''' || :button.chq_no ||
                                                                                                                                                 ''' and ' || 'recon is null'||
           '''');   Please guide me and inform me how it is work... how to use its *' '*

    try
    DECLARE
        v_sql VARCHAR2(300);
    BEGIN
        v_sql := 'v_bankcode= ' || '''' || :button.bankcode || '''' || ' and v_chq= '  || :button.chq_no || ' and recon is null';
        SET_BLOCK_PROPERTY('bank_recon', DEFAULT_WHERE, v_sql);
    END;if you have doubt about the syntax, you can check it by showing a message like
    message('sql=' ||  v_sql);PAUSE;

  • Query in item problem

    Hellou everybody.
    I need your help. I am using forms 6i and i have a block with some non DB items. But items are synchronize with DB items for viewing results. I use this items for diplaying results from DB tables. In enter query mode i write condition in this text items and execute query.
    My problem is that i have text item which is VARCHAR2 type and I need to enter the condition for example > 1000. But i don't know how to convert this field to number. When i execute query under char type it not work properly (other result). I tried to change data type to number but i can't because it's not alowed to mixed types.
    select * from table_name where pag_cis > 100 - i need this
    select * from table_name where pag_cis > '100' - i have this
    Can you help me???

    You may use the set_block_property procedure built-in and the 'default_where' property so as to execute the query using the contents of your item (with the name of column , of course).
    Afterwards , you navigate to the db items block (with go_block('blockname')) and execute the query (built-in 'execute_query').
    Hope it helps
    Sim

  • Query in Item Reservations Report

    Hi all,
    Can i know what the 'Remaining Quantity' in the Item Reservations Report mean.Also let me know when the same column will be affected and how.
    ie.When can reserved quantities and remaining quantities vary in the report?
    Regards,
    Bala.

    You may use the set_block_property procedure built-in and the 'default_where' property so as to execute the query using the contents of your item (with the name of column , of course).
    Afterwards , you navigate to the db items block (with go_block('blockname')) and execute the query (built-in 'execute_query').
    Hope it helps
    Sim

  • Multiple master blocks populating the same detail blocks

    Hey guys. Im doing something a little weirder than I usually do but I can't get it to work correctly and im wondering if any of you have accomplished this before.
    I have a call center application which processes applications by either the application or by follow up. The application and follow up are each a block by themselves located on a separate pages on a tab canvas. Both these blocks are master blocks to the detail blocks which would be user_phones, user_addresses, user_bank_accounts, etc. The idea is I can use either page of the tabs and flip through either the follow up, or application master block and have it populate the user tables according to the user_id found on the master blocks. I figured I could use a when-new-block-instance trigger to switch off which block fires the on-populate-details trigger.
    The problem is.... complicated. If I go to the follow up block and execute query, it brings back the right information on the detail block. The strange thing is it seems like when I move the cursor to a different record on the same block, forms is almost setting a SET_BLOCK_PROPERTY DEFAULT_WHERE action. This is un-noticeable until i go to the other master detail block. When I start using the applications block, it seems like all the detail records actually MATCH the user_id that the cursor was on in the follow up block...
    phew! thats a lot of description for such a strange problem..
    Anyways. Anyone encountered this before? Has anyone ever built a two master block form to populate the same detail block? Is it possible? I haven't found a thread in the forum about this subject..
    Any help would be great. Thanks in advance :)

    Having one detail block for two master blocks was never a use case that we considered for Forms. It sounds like you are trying to make a many-to-many relationship work with two master blocks. I suggest you think about having an intermediate block (hidden or not) that drives the detail block and make each master block drive that intermediate block instead of driving the detail block directly.

  • How do I set form automatically in query mode

    Hi !
    I have to pass value of one field as parameter from one form to
    another form and then execute the query on the next form based
    on the passed value of the parameter. (all this should happen as
    soon as I press one button on the first form).
    My problem is that unless I put the second form in the enter
    query mode before accepting the value of the field, whatever
    value I pass on from the first form will not be of any use.
    How do I set the mode of the form to query mode. Since
    system.mode is the read only variable and no value can be
    assigned to it, so how can I handle this situation ?
    Thanks in advance,
    Shobhit
    null

    Hi Shobhit,
    Try ENTER_QUERY command in the PRE-FORM trigger of second form.
    EXECUTE_QUERY in WHEN-NEW-FORM-INSTANCE and set the parameter
    values to the respective fields in PRE-QUERY trigger.
    Lalit
    Shobhit Kumar (guest) wrote:
    : Hi Steve !
    : Thanks for the answer. but I want a bit different
    functionality.
    : I have already tried using execute-query (built in) in the when-
    : new-form-instance and passed the value of the parameter in the
    : field. But all that is happening is that the value is just
    : sitting in the field and query is not getting executed
    : automatically. I am using forms 5.0 and to enter a query we
    need
    : to change the mode of the form in the query mode (by clicking
    : the enter->query button) and then enter the values in the
    fields
    : that would be used to build the query and the as soon as I say
    : execute query it executes the query and displays the results.
    : What I want is that as soon as I press a button in a form,
    value
    : of one field should go to another field in a second form and
    : then the query should get executed automatically in the second
    : form and the results should be displayed in that form.
    : Any suggestions ?
    : Regards,
    : Shobhit
    : Steve (guest) wrote:
    : : You might want to try placing the builtin EXECUTE_QUERY
    : : in the WHEN-NEW-FORM-INSTANCE trigger to auto query the form.
    : You
    : : may also want to use the SET_BLOCK_PROPERTY(DEFAULT_WHERE,
    : : '.......'); to restrict queried records or set :block.item
    : values
    : : in a PRE-QUERY Trigger.
    : : Shobhit Kumar (guest) wrote:
    : : : Hi !
    : : : I have to pass value of one field as parameter from one
    form
    : to
    : : : another form and then execute the query on the next form
    : based
    : : : on the passed value of the parameter. (all this should
    : happen
    : : as
    : : : soon as I press one button on the first form).
    : : : My problem is that unless I put the second form in the
    enter
    : : : query mode before accepting the value of the field,
    whatever
    : : : value I pass on from the first form will not be of any use.
    : : : How do I set the mode of the form to query mode. Since
    : : : system.mode is the read only variable and no value can be
    : : : assigned to it, so how can I handle this situation ?
    : : : Thanks in advance,
    : : : Shobhit
    null

  • Code for execute query

    hello can anyone please give me the code to execute a query.
    i want to input an id and when i press enter, a query must be executed in a
    master form.
    i tried using the trigger when key entered but was not successful.
    any help will b grateful.
    thanks

    This is exactly the way a default block on your table would work.
    Create a default block on the table, run your form, press the enter_query button insert the id and press the execute_query button.
    If you want you can also check the online help about set_block_property(Default_where) and execute_query built-ins.

  • Query based on a non-database item in master/detail block

    Hi,
    I have a master/detail block, and in the master the block in have non database control item which displays the user name. Now i would want to retrive all the master/detail records based on the control item. Is that possible? How can i do it?
    Any help would be appriciated.
    Thanks
    Kavitha

    use the set_block_property (default_where) and the execute_query built-ins. more info in the online help

  • Max customized query length

    Hi all,
    anyone knows if it's possible to extend the maximum length (it seems to be 210 chars) of the data-block mask for customized query? I mean that mask Forms displays when, in enter-query mode, you use '&' to insert particular query conditions.
    Thanks,
    Marco

    I'm not sure.
    But one option is to build this mechanism on your own. Just popup a window to get the where clause and then use set_block_property(default_where) to attach it to the block.

  • Set_block_property('emp',default_where,...) with variables

    db and dev 10g rel2 ,
    i am trying to learn about this built-in with variables and the equal(=) operator , i can not use it with variables , so show me please how to use it with number , charachter and date variables .
    1- working with number variables .
    - i have the block 'scott.emp' , and a button 'search' .
    - my variable 'v' holds the value 7788 , and i want to display the data based on this number of the 'empno' column .
    how to do it with set_block_property ?
    thanks in advance
    Edited by: newbi_egy on Apr 5, 2013 3:11 PM
    Edited by: newbi_egy on Apr 6, 2013 2:55 PM

    newbi_egy wrote:
    this is so correct HamidHelal , but what i want to ask about is ,
    i know that the part after "default_where" of the set_block_property built-in should reside between two single quotes like so
    set_block_property('emp',default_where,' ') ;
    but your letters does not reside between these single quotes ' ' , what resides is just this ('empno=') , and if the whole sentence should reside between single quotes , it should be like so
    ('''empno='||v'') as the two quotes at the beginning of the sentence and at the end are in fact one quote (one at the beginning and one at the end . -- these are which enclude the whole sentence which is ('empno=') .should not it work like so ? -- sure it is not working , but i want to understand why is not it working ? Ok. working statement is
    SET_BLOCK_PROPERTY('emp', DEFAULT_WHERE, 'empno = '|| V);where 'empno = ' is fixed string. variable value of V is concatenate.
    Following statement also work. and meets set_block_property('emp',default_where,' ') ;
    SET_BLOCK_PROPERTY('emp', DEFAULT_WHERE, 'empno =7788 ');What is the difference ?
    Difference is, in the first statement we set the empno value dynamically where second one is fixed.
    Hope it's clear..
    Hamid

  • Set_block_property and Default_where

    Hi All,
    I'm trying to set the default clause at runtime,for that i'm using set_block_properties.
    Here is my cde:
    Set_block_property('RECIPIENT_VIEW',DEFAULT_WHERE,'RECIPIENT_NAME LIKE '||''''||:RECIPIENT_NAME ||'%'||'''');
    I'm NOT getting if i use this in KEY-EXEQRY or PRE-QUERY triggers(I'm getting it, when i use this in button).
    How can solve this problem in KEY-EXEQRY or PRE-QUERY triggers ?
    Please help me.
    Thanks
    P

    Because form default enter-query, execute-query buttons look your input format:
    1) if you type in A in the field, then form constructs the default where by appending additional RECIPIENT_NAME ='A';
    2) If you type in A% in the field, then form constructs it by appending the additional RECIPIENT_NAME LIKE 'A%';
    That's to say, if you SET_BLOCK_PROPERTY('blockname',
    DEFAULT_WHERE,
    'RECIPIENT_NAME LIKE '''||:RECIPIENT_NAME ||'%'||''') in the PRE-QUERY trigger of forms6i, then the block where condition becomes the below format,
    for 1) input:
    RECIPIENT_NAME LIKE 'A%' AND RECIPIENT_NAME ='A'
    for 2) input:
    RECIPIENT_NAME LIKE 'A%' AND RECIPIENT_NAME ='A%'
    Therefore, for input 'A%' it will work for you, for input 'A', it will have no much chance to get the record unless you make record 'A', then it will get you the data.
    Remember, after you type in something, the block where clause changed if you use the default menu enter/execute-query buttons.
    you will see it if you check the :system.last_query.

Maybe you are looking for

  • Photoshop CS has stopped working when loading

    I wonder if someone can help me as I am not technical. I have a copy of Adobe Communication Suite 2 (this is basically CS4 version). I've installed this and every piece of it will load except for Photoshop (the bit I really want and need today!). I g

  • Connecting E-printer to the internet (Solution)

    To all:    I was having trouble connecting my e-printer to the internet.  Went to HP Support and no one had the answer for me.  Yesterday, I finally figure it out.  Maybe this will help many of you.  First, I went to the Wireless Signal, click on tha

  • Dynamic filtering, data level security

    In order to enforce data level security we would like to do the following: 1. Send a user identification parameter through a URL that calls a BAM report. 2. According to this parameter retrieve from a dedicated data object the list of organization un

  • Please help me get my Ipod to automatically sync to ITunes ?

    No mater how many different setting options i play with , when i plug my ipod into itunes i still have to manually hit the sync buton for new music,vids and podcasts to sync to the ipod. clearly i have an incorrect setting but for the life of me cant

  • Leopard Install Disc Won't Mount on PowerMac G4

    I'm having problems installing Leopard and am looking for advice. My internal DVD reader won't mount the installation disc - this has been a long-standing issue with my DVD drive: it can read some DVDs but not others. This is only the second time I'v