Bind variables (how replace the placeholders with the same value?)

Hello, I have a code like this:
  procedure getAllTasks(o_cursor                      in out PKG_APPLICATION.rc,
                        in_filter_project_id          in T_FCT_TASK.project_id%type default -1,
                        in_filter_scope_id            in T_FCT_TASK.scope_id%type default -1,
                        in_filter_user_creator_id     in T_FCT_TASK.user_creator_id%type default -1,
                        in_filter_priority_id         in T_HST_TASK.priority_id%type default -1,
                        in_filter_status_id           in T_HST_TASK.status_id%type default -1,
                        in_filter_user_responsible_id in T_HST_TASK.user_responsible_id%type default -1,
                        in_pagination_first           in integer,
                        in_pagination_last            in integer) is
    v_query varchar2(4000) := v_query_allTasks || v_query_whereFilter;
  begin
    PKG_APPLICATION.setPagination(v_query);
  
    PKG_LOG.debug('query: ' || v_query, PCK);
  
    open o_cursor for v_query
      using in_filter_project_id, in_filter_scope_id, in_filter_user_creator_id, in_filter_priority_id, in_filter_status_id, in_filter_user_responsible_id, in_pagination_last, in_pagination_first;
  end;
The variable v_query contains:
SELECT * FROM (SELECT A.*, ROWNUM AS RNUM
                  FROM (
    SELECT task_id, project_id, project_name, scope_id, scope_name, user_creator_id, user_creator_login, title, description,
           priority_id, priority_name, status_id, status_name, user_responsible_id, user_responsible_login, due_date,
           last_modified_by_id, last_modified_by_login, last_modified
      FROM V_FCT_TASK
    WHERE project_id          = decode(:1, -1, project_id, :1)
      and scope_id            = decode(:2, -1, scope_id, :2)   
      and user_creator_id     = decode(:3, -1, user_creator_id, :3)   
      and priority_id         = decode(:4, -1, priority_id, :4)   
      and status_id           = decode(:5, -1, status_id, :5)   
      and user_responsible_id = decode(:6, -1, user_responsible_id, :6)   
  ) A
                  WHERE ROWNUM <= :LAST)
            WHERE :FIRST <= RNUM
Note that placeholders: 1: 2,...: 5 appears 2 times in the query.

Is there a more elegant way to say that *: 1 * must be replaced by in_filter_project_id, *: 2 * by in_filter_scope_id without having twice in the USING clause these variables? If this is not the case, why the placeholders have name, if you can only refer to their position (order)?

Thanks for all replies.

Hi Adam,.

text taken from http://download.oracle.com/docs/cd/B10501_01/appdev.920/a96624/11_dynam.htm

Duplicate use of Placeholders

Placeholders in a dynamic SQL statement associated with the arguments of bind in the USING clause of position, and not by name. Thus, if the same placeholder appears two times or more in the SQL statement, each appearance must correspond to a bind argument in the USING clause. For example, if the dynamic string

sql_stmt := 'INSERT INTO payroll VALUES (:x, :x, :y, :x)';

you could code the corresponding USING clause as follows:

EXECUTE IMMEDIATE sql_stmt USING a, a, b, a;

However, only the unique placeholders in a dynamic PL/SQL block are associated with bind arguments in the USING clause of position. Thus, if the same placeholder appears two times or more in a PL/SQL block, all appearances correspond to a single argument to bind in the USING clause. In the example below, the first unique placeholder (x) is associated with the first bind argument (one). Similarly, the second unique space reserved (y) is associated with the second argument to bind (b).

DECLARE
   a NUMBER := 4;
   b NUMBER := 7;
BEGIN
   plsql_block := 'BEGIN calc_stats(:x, :x, :y, :x); END;'
   EXECUTE IMMEDIATE plsql_block USING a, b;
   ...
END;

Hope this helps
Christian Balz

Tags: Database

Similar Questions

  • How can I replace the same clips with the same interval of time (same settings)?

    Dear Adobe Premiere CS5 Forum,

    I have the following problem, and I would look forward to receiving solutions:

    As I couldn't cut my video with clips in avi codecs (it is very difficult to cut in avi codecs, except that you have a very fast computer), I converted my raw clips in lower codecs. Then I cut my video in low quality codecs. My video is now ready to export.

    But before I want to export my video, I need to replace all the clips in avi codes so that my video is in good quality.

    Now the problem:

    How can I replace the clips (poor quality video codec codec avi), in order to have the same clips in a different codec always the same interval of time. I want the replaced clip immediately have the same interval of time.

    For example: a raw whole clip takes 2 minutes. But just a part / interval of the clip (from 01:00 minute 01:10 minutes) is shown in the video. Now I want to replace this clip with the same clip in avi codec. But it must be the same interval (from 01:00 minute 01:10 minutes).

    I tried to replace a clip. But they each have a different time interval (the lower quality clip is from 01:00 to 01:10 minutes and if I would like to replace the same clip in avi codec is the time interval between 0:00 to 0:10 minutes).

    How can I replace the clip with the same interval of time?

    Thanks in advance

    Leonardo

    Hold down the Alt + Shift; It is Shift that maintains the reference timecode. In addition, this will work only if your proxy clips contains timecode. If they all start to 00:00:00:00, this will not work for you.

  • How can I get a CMYK or Gray scale halftone and replace it with a spot color with the same value of midtones?

    Is it possible that I can select an object or objects that have a value of mixed CMYK or Grayscale, and then select a Spot color and it will keep the same value of midtones as before?

    For example, I have an object that is C: 0 M: 0 Y: 0 k: 20 and I select Reflex Blue. What is happening is it change my object to 100% Reflex Blue. Is there a way to change to automaitically Reflex Blue 20%?

    Another example, I have 3 objects, one is 20 k: the second is 40 k: and the third is KC: 85. I want to select all the objects in three at the same time, select Yellow PANTONE and get them to change yellow PANTONE 20, 40 yellow PANTONE and PANTONE yellow 85.

    Is there a way to do it or I will always have to manually edit each element?

    Thanks for the help.

    Select the elements to recolor

    Edit > edit colors > redefine > follow my screenshots

    I love clicking this button under the entitlement, one place for everything that you color reduction settings.

    Use tinted scale. Exact will give you 100% of the color. The exact word is confusing here, this means that the color of the destination (100% of everything that the color you choose), not a version tinged scale.

    Unfortunately I do not know how to get the exact values of blacks to convert the exact values of spot color. Scale of hues will you get you get you close enough for what you need. In my example that a black 89% converts a 84% of the place, so no exact but alteast I have a range of shades, and sometimes the results are better than accurate, depends on your art.

    Here are my before and after.

  • Bind Variables and using the keyword

    In my dynamic SQL, I use the same variable in several places in my query. Is there a way to avoid rewriting the same value multiple times in the list of arguments to bind? It is something like that - only pseudo code.
    DECLARE
    tSQL VARCHAR2(99)
    pVal INT := 2;
    
    BEGIN
    tSQL := 
               'SELECT * ' ||
               '  FROM dual ' ||
               ' WHERE col1 =: iVal ' ||
               '   AND col2 IN (SELECT col2 ' ||
               '                  FROM dual  ' ||
               '                 WHERE col1 =: iVal) ' ||
               ' UNION ' ||
               ' SELECT * ' ||
               '   FROM dual ' ||
               '  WHERE col1 =: iVal';
    
    EXECUTE IMMEDIATE tSQL 
    USING pVal, pVal, pVal;  -- Is there a way to avoid having to rewrite the same bind variable argument three times since the value is the same?
    
    END;
    Is there a way to avoid having to rewrite the same argument three times bind variable as the value is the same?

    Etbin wrote:
    http://docs.Oracle.com/CD/E11882_01/AppDev.112/e25519/dynamic.htm#BHCHIHEJ says:
    Placeholders are associated with bind variable in the USING clause of position, and not by name.

    Concerning

    Etbin

    The exception to this rule is if the SQL statement is an anonymous block or a call statement. In this case, the repetition of the names of the placeholder is significant.

    http://docs.Oracle.com/CD/E11882_01/AppDev.112/e25519/dynamic.htm#CHDFHEAG

    For example, the following will fail with ORA-01008: not all variables

    declare
     v_cnt number;
    begin
      execute immediate 'select count(*) from dual where 1 = :B1 and 2 > :B1'
      into v_cnt using 1;
      dbms_output.put_line(v_cnt);
    end;
    

    However, the following will succeed because the SQL code is in fact an anonymous block:

    begin
      execute immediate 'declare
                           v_cnt number;
                         begin
                           select count(*)
                           into v_cnt
                           from dual
                           where 1 = :B1 and 2 > :B1;
                           dbms_output.put_line(v_cnt);
                         end;'
      using 1;
    end;
    

    Pretty cool stuff.

  • Replace the string value of table

    with cte as)

    Select val '123', 'abwec' double val1

    Union of all the

    Select "456" val, "mowerw" double val1

    Union of all the

    Select val '709', 'wkwere' double val1

    Union of all the

    Select val '078', 'awerwewerwreq' double val1

    )

    Select * from cte;

    -incoming string

    "asdasd123ewrwer@87w8eopiu456werwer@asdwer709@ewrwerewrwqqwezxder078 @..."

    need to replace like 'abwec' 123 and 456 as "mowerw" and 709 as wkwere and 078 as 'awerwewerwreq '.

    How to replace the string value of the string

    I'm going to the table which will have mapping information I need to see the incoming string and replace the appropriate value of the val to val1

    something like

    Of

    "asdasd123456werwer@asdwer709@ewrwerewrwqqwezxder078ewrwer@87w8eopiu @..."

    TO

    "asdasdabwecewrwer@87w8eopiumowerwwerwer@asdwerwkwere@ewrwerewrwqqwezxderawerwewerwreq@..."

    By using the TYPE clause.

    with cte as

    (

    Select val '123', 'abwec' double val1

    Union of all the

    Select "456" val, "mowerw" double val1

    Union of all the

    Select val '709', 'wkwere' double val1

    Union of all the

    Select val '078', 'awerwewerwreq' double val1

    ),

    input_tbl

    as

    (

    Select "asdasd123ewrwer@87w8eopiu456werwer@asdwer709@ewrwerewrwqqwezxder078 @..." input_str

    of the double

    )

    Select max (input_str) Dungeon (first order by desc NWR dense_rank) input_str

    de)

    Select rno, input_str

    de)

    Select rownum NWR

    val

    val1

    input_str

    count (*) over() cnt

    from cte

    Cross

    Join input_tbl

    )

    model

    dimension (NWR)

    measures (val, val1, cnt, CAST (input_str AS VARCHAR2 (4000)) input_str)

    (

    input_str [any] = replace (nvl (input_str [cv () - 1], input_str [cv ()]), val [cv ()], val1 [cv ()])

    )

    )

  • Photos with the same values of position...

    I have a picture with the edited/customized position values (scale, rotation, inclination, perspective, disort, warp)... I have some photos that will be on the different layers and I want that they have the same values as the first (it's stupid to do the same thing with 10 photos...) I tried to duplicate the layers and replacement is contained, but values are lost, so the photos appear in the normal position...

    So how can guys, I do this?

    For this to work properly, all images must be of the same size and resolution.

    1. Integrate the file of the first image.
    2. Layer > Smart object > convert to smart object
    3. Edit > free transform and establish the size, position and orientation... .OK
    4. Cmd + J to create a layer of dupe
    5. Layer > Smart Object > replace content
    6. Choose the following image > replace

    Repeat steps 4-6

  • How do the box values ring to have figures after the decimal point

    How do the box values ring to have figures after the decimal point

    Thanks in advance

    Control properties editor:

    Change the representation in the floating point data Type tab type, DBL will do.

    Then go to the Page of display Format and increment 'Numbers' to something greater than 1

    That toggles the column of values on the tab change the items to % .6f, or 6 digits of precision. Uncheck sequential following, values and you're there.

    If you think that's too restrictive, go back the display Format, then select if rating and you can type anything (but, the editor has a hissing fit, so you must load chains and property [] with a property node values programmatically)

    I've been struggling to get OR improve this editor of properties of the years!

  • I am a member creative cloud. I want to install the same applications from my laptop to my new desktop computer. I need to purchase another license? otherwise how do the same thing for my new desktop computer

    I am a member creative cloud. I want to install the same applications from my laptop to my new desktop computer. I need to purchase another license? otherwise how do the same thing for my new desktop computer

    I have it! Thank you

  • An update on an index column with the same value generates an index to the top

    An update on an index column with the same value generates an update of the index?


    Thank you

    In addition to my previous answer, see also

    http://orainternals.WordPress.com/2010/11/04/does-an-update-statement-modify-the-row-if-the-update-modifies-the-column-to-same-value/

    Riyaj Shamsudeen has this to say:
    "+ We have an index on this column v1 and we update this column indexed too." Oracle was updating the indexed column? N ° if the values match the level of the indexed column, then the code of RDBMS isn't up-to-date index, a feature for optimization again. Only the row of table is updated, and the index is not updated. + "

    Hemant K Collette

  • rows with the same value

    Hello
    I have this request:
    Select b.db_name, a.handle from bp a, dbinc b where a.db_key = b.db_key;

    By request I see the lines where the handle columns have the same values?
    Thank you.

    Hello

    First thing is that your question is very abstract, we can not know which data table you is central to the present moment.

    Select b.db_name, a.handle from bp a, dbinc b where a.db_key = b.db_key;
    By request I see the lines where the handle columns have the same values?

    What you mean you 'same' values with what data need to be compared to 'the same '.
    Fact it is same or some values.

    -Pavan Kumar N

  • : Nom_element and V ('ITEM_NAME') do not return the same value

    Hi all

    I'm developing a shared application process that is called by an AJAX request.

    For the pl/sql code, stored procedure validation e development support I moved the logic inside a database.
    So I have this situation:

    Application process

    ...
    : MYITEM: = wwv_flow.g_x01; -received setting of ajax call I want to put
    ...
    MY_FUNCTION();

    MyFunc

    ...
    v('MYITEM') - here I use value MyItem
    ...

    The problem is that when I call v ('MYITEM') the value I get is the previous and not one that I put with: MYITEM: = wwv_flow.g_x01;
    I have the same problem if I set the V ('MYITEM') inside the apex application process.

    I saw that it worked right if I use the following to set the value of the element in the application process:

    APEX_UTIL. SET_SESSION_STATE('P0_LST_DATA',:P0_LST_DATA);

    Is this a bug?
    I was expecting to get the value of the item: MONELEMENT and v ('MYITEM') are equivalent...

    Thank you
    Davide

    Davide,

    If you encode the block like that, you should get the results you expect:

    : P100_VAR1: = '1'. : P100_VAR1;
    : P100_TEST: =: P100_VAR1;

    The reason why this block does not give you what you expect:

    : P100_VAR1: = '1'. : P100_VAR1;
    : P100_TEST: = v ('P100_VAR1');

    ... is that v ('P100_VAR1') returns the current value of the item in the table of PL/SQL State session as it existed before the execution of the block. The assignment to the variable binding: P100_VAR1 has registered only a value in storage variable to bind the dynamic execution at this time and has not yet spread to session state, which is located at the end of the execution of the block. It's a little weird, we know.

    Andy,

    I figured that the: xxxx points have been settled during the loading of the page with what the source is...

    They contain the session state value and can be read or written in notation variable bind.

    However, they are updated only in the session when you send page...

    They are updated in session state when the particular block is completed and a commit is issued at this time there.

    In order to update a piece of code PL/SQL session state, you must use... apex_util.set_session_state.

    You must be careful to call it when scoring also bind variable to set the session state may cause one to deny the other. Using one method or the other should work very well.

    Scott

  • All channels to HAVE it have the same value - NI PCI-6221 and NI PCI-6229

    Hello

    I use the aiex1.cpp example for a multi-channel read with the devices mseries 6221 and 6229.

    This example works for a lane, but other chains have the same value (difference of +-0.001 Volt).

    For example: I put 5 Volt on the first string, and then the other channel are 5 Volt too.

    What should I consider in the configuration?

    Heiko Hello!

    your description looks like the effect you are having 'ghosts '.

    For more information about ghost images and how to get rid of, check out these links:

    http://digital.NI.com/public.nsf/allkb/73CB0FB296814E2286256FFD00028DDF?OpenDocument

    and

    http://digital.NI.com/public.nsf/allkb/C6C7DE575301A379862572DD00480A01?OpenDocument

    Best regards

    Moritz M.

  • inputText and ouputText does not display the same value

    Hello

    JDev 11.1.2.4

    On my page, I have an inputText and outputText bound to the same link of the attribute. The bind value is defined in a value change listener, and then the two components are updated. Say I put in 2009 for the PeriodFrom, the inputText remains empty, but the outputText shows the 2009. How is possible that the two items related to the same link does not show the same value.

    < af:inputText value = "#{bindings." PeriodFrom.inputValue}"required =" #{bindings. " PeriodFrom.hints.mandatory}.

    columns = "#{bindings." PeriodFrom.hints.displayWidth}"shortDesc =" #{bindings. " PeriodFrom.hints.tooltip}"id ="id1 ".

    autoSubmit = "true" simple = "true" >

    < f: validator binding = "#{bindings." PeriodFrom.validator} "/ >"

    < / af:inputText >

    < af:outputText value = "#{bindings." PeriodFrom.inputValue}"id ="ot3"clientComponent ="true"/ >

    Furthermore, I tried to get the RichInputText component and call a getValue on it, and the value returned is 2009. I'm completely lost.

    Thank you

    I made the fragment of page from scratch. I discovered why the update does not work. This is because the selectOneChoice is inside an af:subform. If I remove the subform, the update works correctly.

    shortDesc = "#{bindings." StdcntyCode.hints.tooltip}"id ="soc2"simple ="true"autoSubmit = 'true '.

    valueChangeListener = "#{pageFlowScope.identificationSessionEditBean.countryValueChangeListener}" > "

    columns = "#{bindings." PeriodFrom.hints.displayWidth}"shortDesc =" #{bindings. " PeriodFrom.hints.tooltip}"id ="id1 ".

    autoSubmit = "true" simple = "true" >

    columns = "#{bindings." PeriodTo.hints.displayWidth}"shortDesc =" #{bindings. " PeriodTo.hints.tooltip}"id ="id2 ".

    autoSubmit = "true" simple = "true" >

  • Need to show the same values in all jspx pages

    Hello.

    I use jdeveloper 11.1.1.5

    I had created a jspx pages such as dept.jspx and emp.jspx

    I've been using this in my jspx page
     <af:outputText value="#{bindings.return.inputValue}"
                               binding="#{pageFlowScope.backing_dept.ot1}"
                               id="ot1"/>
    The bindings.return.inputValue will return the value of the code below
        public String checkLoginCredentials1(String p_user,String p_pwd)
        {
        System.out.println(p_user + " " + p_pwd);
         ApplUsersVOImpl  vo = (ApplUsersVOImpl)this.getApplUsers1();
         /*set the bind variable value*/
        vo.setNamedWhereClauseParam("p_user",p_user.toUpperCase());
        vo.setNamedWhereClauseParam("p_pwd",p_pwd.toUpperCase());
        vo.executeQuery();
        int rowCount=vo.getEstimatedRangePageCount();
        System.out.println("rowCount="+rowCount);
        if(rowCount==0) 
        { 
           throw new JboException("Password doesn't match");
         }
           return "Welcome"+ "  " + p_user.toUpperCase();
        } 
    My scenario is that I need to display the same value in emp.jspx

    I had created a task flow frm dept.jspx to emp.jspx and emp.jspx to dept.jspx

    I tried the same XML file in my emp.jspx
    <af:outputText value="#{bindings.return.inputValue}"
                               binding="#{pageFlowScope.backing_emp.ot1}"
                               id="ot1"/>
    But while I m browsing frm emp.jspx to dept.jspx there are doesnot.,.

    This means that for the faces-config. XML (the standard JSF configuration file), there is no scope spanning application except for the scope of the session. This does not mean that you should not use extended session if you use faces - config.Xml.

    However, you have been advised to use the workflow and no faces - config.Xml.

  • Satellite P300-156 - and the button Return give the same values

    Hello

    I have a satellite P300-156, and it has a numeric keypad.
    I have problems because the Enter key and the Return key give the same values. I believe that it is incorrect.
    Can anyone help.

    Key on the numeric keypad should give an input it does.
    the Enter key on the main keyboard should give a carriage return value, but it gives an input value.

    Usually this does not cause a problem, but with software like photo shop that makes the distinction between a carriage return and a hard fall it does not work.

    Can someone help me please

    Thank you

    Hello

    To my eyes the entry and return keys are the same keys that provides the same functionality.
    I really put t know why you believe that there is something not right

    By the way; Check if you are using the latest version of the BIOS!

Maybe you are looking for