Use Row Selector in PL/SQL Function

Hi all!
I want to use the ROW SELECTOR from a Tabular Form in a PL/SQL Function or Anonymous Block.
In Detail I want to find out which Rows got checked and then do specific operations to them.
Thanks in Advance.
Regards
Kai Eilert

Hi,
I have a similar requirement. Need to add a Row selector in a report based on SQL query(PL/SQL function body returning SQL query). How do I do this?
TIA

Similar Messages

  • Insert data using row selector

    Hi :
    In my applicaion i need to insert only the selected data ie row
    the query i am using is
    select
    html_db_item.text(1,pobj.name,20,25) "object Name",
    html_db_item.text(1,null,20,25) "Incomming Hours ",
    html_db_item.text(1,null,20,25) "Design Hours "
    from projects pro.
    project_objects pobj
    where pro.id = pobj.pro_id and
    pro.id = :p10_projects
    here p10_projects is the project where for each project there would be 10 to 100 objects ie pobj.name
    here i need to insert these object names and hours into anothere table where i need a row selector to select only selected objects and insert please suggest me
    so as i select the rows only that need to be inserted
    Thanks
    Sudhir

    Randy :
    please try this query
    SELECT
    HTMLDB_ITEM.DISPLAY_AND_SAVE(2,NULL) "Project Objects",
    HTMLDB_ITEM.DATE_POPUP(3,rownum,null,'dd-mon-yyyy',12,15) "date"
    FROM
    DUAL
    UNION
    SELECT
    HTMLDB_ITEM.DISPLAY_AND_SAVE(2,SYSDATE) "Project Objects",
    HTMLDB_ITEM.DATE_POPUP(3,rownum,null,'dd-mon-yyyy',12,15) "date"
    FROM
    DUAL
    first change the query to sql updatable form and then add row selector to this report and try to select the 2nd row date picker ull find the problem wht i am facing
    i need row selector becouse to select the date indivisually and insert them
    please give me some soloution
    thanks
    sudhir

  • Using variable coulmn name in sql function

    Hi there,
    I am not an expert with PL/SQL and I can not figure out how to use variable column names in my function.
    My function is:
    CREATE OR REPLACE FUNCTION RESET_TRIGGERS(aTrigger VARCHAR2) RETURN NUMBER IS
    TEMP_ID NUMBER;
    TEMP_USER_ID NUMBER;
    BEGIN
    SELECT 'LIMS.'||'$aTrigger'||'.NEXTVAL' INTO TEMP_ID FROM DUAL;
    SELECT 'LIMS.'||'$aTrigger'||'_USER.NEXTVAL' INTO TEMP_USER_ID FROM DUAL;
    IF TEMP_ID > TEMP_USER_ID THEN
    LOOP
    SELECT LIMS.SQ_U_FINALRESULT_USER.NEXTVAL INTO TEMP_USER_ID FROM DUAL;
    EXIT WHEN TEMP_USER_ID = TEMP_ID;
    END LOOP;
    ELSE
    WHILE TEMP_ID < TEMP_USER_ID LOOP
    SELECT LIMS.SQ_U_FINALRESULT.NEXTVAL INTO TEMP_ID FROM DUAL;
    END LOOP;
    END IF;
    COMMIT;
    RETURN (TEMP_ID);
    END;
    What I want is that I pass a seqencename with aTrigger and that two triggers will be equal if not.
    eg ifaTrigger = 'SQ_U_FINALRESULT'
    than I want the triggers LIMS.SQ_U_FINALRESULT and LIMS.SQ_U_FINALRESULT_USER to be set equal.
    The above function will not work, but what will?????
    I hope you can help me out!
    Cheers

    A very strange function indeed.
    But here is what I think he meant to do:
    SQL> create procedure reset_sequences
      2  ( p_sequence_name in  varchar2
      3  , p_nextval          out number
      4  )
      5  is
      6    l_nextval1 number;
      7    l_nextval2 number
      8    ;
      9    procedure reset_sequence_value
    10    ( p_sequence_name in varchar2
    11    , p_current_value in number
    12    , p_new_value     in number
    13    )
    14    is
    15      l_dummy number;
    16    begin
    17      execute immediate 'alter sequence ' || p_sequence_name || ' increment by ' || to_char(p_new_value-p_current_value);
    18      execute immediate 'select ' || p_sequence_name || '.nextval from dual' into l_dummy;
    19      execute immediate 'alter sequence ' || p_sequence_name || ' increment by 1';
    20    end reset_sequence_value
    21    ;
    22  begin
    23    execute immediate
    24      'select ' || p_sequence_name || '.nextval,' || p_sequence_name || '_user.nextval from dual'
    25    into l_nextval1, l_nextval2
    26    ;
    27    if l_nextval1 < l_nextval2
    28    then
    29      reset_sequence_value(p_sequence_name,l_nextval1,l_nextval2);
    30    end if
    31    ;
    32    if l_nextval1 > l_nextval2
    33    then
    34      reset_sequence_value(p_sequence_name || '_user',l_nextval2,l_nextval1);
    35    end if
    36    ;
    37    p_nextval := greatest(l_nextval1,l_nextval2)
    38    ;
    39  end reset_sequences;
    40  /
    Procedure is aangemaakt.
    SQL> show err
    Er zijn geen fouten.
    SQL> create sequence testseq start with 5 increment by 1
      2  /
    Reeks is aangemaakt.
    SQL> create sequence testseq_user start with 2 increment by 1
      2  /
    Reeks is aangemaakt.
    SQL> declare
      2    l_new_value number;
      3  begin
      4    reset_sequences('testseq',l_new_value);
      5    dbms_output.put_line(l_new_value);
      6  end;
      7  /
    5
    PL/SQL-procedure is geslaagd.
    SQL> select testseq.currval from dual
      2  /
                                   CURRVAL
                                         5
    1 rij is geselecteerd.
    SQL> select testseq_user.currval from dual
      2  /
                                   CURRVAL
                                         5
    1 rij is geselecteerd.Regards,
    Rob.

  • Using Package to produce pl/sql function body returning sql query Report

    I have existing code that we want to use in building reports in APEX. We are needing to modify it slightly to handle some new requirements, but would like to use them in reports based upon SQL query (pl/sql function body returning sql query) functionality.
    Any suggestions as how to call these in an APEX report region?
    Thank you,
    Tony Miller
    UTMB/EHN

    Hi Tony-
    I am also v new to Apex and you may have answered a question I was in search of. I, however, now have a couple more. First a bit of background-- Like in your situation, my college has a lot of existing code (400 +) that we need to get into Apex. The majority of this canned code contains one/both: 1) many lines, sometimes containing multiple select statements 2) imbedded create table & view statements (temp user owned). Up until reading your post, I was unable to figure out an easy way of getting this existing code into the product. Thanks. Now the questions, do you know how I would go about dealing with the create tables/views. I've read some posts on this forum which suggest temporary tables being unstable in this environment. Also, do you know if there's a size limitation when passing sql code via a function?
    As you may/may not be able to tell, I'm a bit lost right now... so any info you can provide would be appreciated. Thanks.
    Don

  • Update Multiple Rows using Row Selector

    Hi,
    I want to update multiple rows using a tabular form with row selector, and an item in another region of the page, using an update expression and a button.
    The syntax would be like this:
    update MY_TABLE set UPDATABLE_COLUMN = :P10_NEW_VALUE where {row selector = true}
    What is the syntax for the WHERE clause, anyone knows? In the manual there is no information at all for doing this.
    PD. I added the row selector after creating the form, so I don't have any wizard-created MRU processes in the page.
    HTMLDB version is 1.6
    Thanks.

    Hi,
    I want to update multiple rows using a tabular form with row selector, and an item in another region of the page, using an update expression and a button.
    The syntax would be like this:
    update MY_TABLE set UPDATABLE_COLUMN = :P10_NEW_VALUE where {row selector = true}
    What is the syntax for the WHERE clause, anyone knows? In the manual there is no information at all for doing this.
    PD. I added the row selector after creating the form, so I don't have any wizard-created MRU processes in the page.
    HTMLDB version is 1.6
    Thanks.

  • Using Row Selector

    I have an updatable report in which I have added a row selector. I can not find the information anywhere where I can reference which columns have been selected. What I would like to do is the user selects certain rows and then click a button. Then update a field on each of the selected rows.
    I feel this is probably a simple act, I just cannot find documentation on how.
    Thank you.

    Ben,
    Denes' example here should get you started:
    http://apex.oracle.com/pls/otn/f?p=31517:95
    Regards,
    Dan
    Blog: http://DanielMcGhan.us/
    Work: http://SkillBuilders.com/

  • More tha one report with row selector in the same page,

    I want to have 2 reports in my page, the two reports must have a row selector.
    1/ In the first report, some pl/sql is executed when the user click in a row, so I am using :
    for i in 1..wwv_flow.g_f01.count loop
    my pl/sql using wwv_flow.g_f01(i)
    end loop;
    2/ In the second report, the user will check rows in order to delete them.
    HTMLDB automaticaly gives f01 to the column "row selector" for any report in the page : how can I manage this please ?
    Thanks for any help!
    Jina.

    See
    http://htmldb.oracle.com/pls/otn/f?p=24317:54
    The region query is
    select
    htmldb_item.checkbox(1,empno,'onClick="highlight_row(this,#ROWNUM#);"') chk,
    ename, job, sal, comm
    from emp
    The Javascript function highlight_row() is "stolen" from the page HTML DB generates when it puts the builtin row selector. Put the function in the region header. The function is
    <script type="text/javascript">
    function highlight_row(checkBoxElemement,currentRowNum) {
        if(checkBoxElemement.checked==true) {
            for( var j = 0; j < checkBoxElemement.parentNode.parentNode.childNodes.length; j++ ) {
                if (checkBoxElemement.parentNode.parentNode.childNodes[j].tagName=='TD') {
                    if(rowActive=='Y') {
                        rowStyle[currentRowNum] = rowStyleHover[currentRowNum];
                    } else {
                        rowStyle[currentRowNum] = checkBoxElemement.parentNode.parentNode.childNodes[j].style.backgroundColor;                     
                    checkBoxElemement.parentNode.parentNode.childNodes[j].style.backgroundColor = '#ededd6';
            rowStyleHover[currentRowNum] =  '#ededd6';
        } else {
            for( var j = 0; j < checkBoxElemement.parentNode.parentNode.childNodes.length; j++ ) {
                if (checkBoxElemement.parentNode.parentNode.childNodes[j].tagName=='TD') {                     
                    checkBoxElemement.parentNode.parentNode.childNodes[j].style.backgroundColor =  rowStyle[currentRowNum];
                    rowStyleHover[currentRowNum] =  rowStyle[currentRowNum];
                    document.wwv_flow.x02.checked=false;
    </script>I have no idea how that Javascript works, it seems to be doing some DOM black magic, but it works! :)
    Hope this helps

  • Issue with running PL/SQL function returning Sql query

    hi, I am trying to create a report region by using the option of PL/SQL function returning sql query.
    I notice that it's very slow for the report region page to show up. In my PL/SQL function body, there are only 3 steps, first update all the 10 rows of varchar2 fields to null,then insert values to those fields, then select all from the table to show report results. It takes more than 5 minitues for the page to load up, how ever, if i run those steps in SQL*Plus, it only takes a couple of seconds to finish. Any suggestions?
    Thanks,
    gina

    Sergio, the codes are as followed,
    Declare
    q varchar2(32767); -- query
    Begin
    q := 'select "ID",'||
    '"ENTRY NAME","TOTAL","#CM","%CM","#CA",'||
    '"%CA", from Info_table';
    update info_table
    set "TOTAL" = '',
    "#CM" = '',
    "%CM" = '',
    "#CA" ='',
    "%CA"=''
    where "ID"<=10;
    // set all data in column Total to null,there is only 10 rows in the table
    update info_Table set Total = vTotal,
    "#CM" = vCM
    (those variables hold user key-in Text filed value)
    where ID = 1;
    return q;
    End;

  • Disable Row Selector

    Alright, so I have a tabular form (no editable fields) used to delete records using [row selector] and a delete (Apply MRD).
    What I would like to do is have the [row selector] hidden/disabled based on a column value.
    Is this possible? If so, how do I go about doing this? thanks Trey

    Hi Trey,
    The Tabular Form is somewhat notorious for being a tricky to customise! There are some enterprising developers out there who have designed "widgets" to let you customise the Tabular Form - have a search around on the forums for "tabular form customise" and other similar search strings.
    Alternatively you could look at re-doing the form using APEX collections - these let you build your own tabular form with a PL/SQL generated query, and then you can do what you like with it. Again, have a search for "collections" on this forum and you should find some helpful info.
    Cheers,
    Colin

  • PL/SQL function body returning SQL query - ORA-06502: PL/SQL: numeric or value error

    I'm attempting to dynamically generate a rather large SQL query via the "PL/SQL function body returning SQL query" report region option.  The SQL query generated will possibly be over 32K.  When I execute my page, I sometimes receive the "ORA-06502: PL/SQL: numeric or value error" which points to a larger than 32K query that was generated.  I've seen other posts in the forum related to this dynamic SQL size limitation issue, but they are older (pre-2010) and point to the 32K limit of the DNS (EXECUTE IMMEDIATE) and DBMS_SQL.  I found this post (dynamic sql enhancements in 11g) which discusses 11g no longer having the 32K size limitation for generating dynamic SQL.  Our environment is on 11gR2 and using ApEx 4.2.1.  I do not know which dynamic SQL method -- DNS or DBMS_SQL -- ApEx 4.2.1 is using.  Can someone clarify for me which dynamic SQL method ApEx uses to implement the "PL/SQL function body returning SQL query" option?
    As a test, I created a page on apex.oracle.com with a report region with the following source:
    declare
      l_stub varchar2(25) := 'select * from sys.dual ';
      l_sql  clob := l_stub || 'union all ';
      br     number(3) := 33;
    begin
      while length ( l_sql ) < 34000 loop
        l_sql := l_sql || l_stub || 'union all ';
      end loop;
      l_sql := l_sql || l_stub;
      for i in 1 .. ceil ( length ( l_sql ) / br ) loop
        dbms_output.put_line ( dbms_lob.substr ( l_sql, br, ( ( i - 1 ) * br ) + 1 ) );
      end loop;
      return l_sql;
    end;
    The dbms_output section is there to be able to run this code in SQL*Plus and confirm the size of the SQL is indeed larger than 32K.  When running this in SQL*Plus, the procedure is successful and produces a proper SQL statement which can be executed.  When I put this into the report region on apex.oracle.com, I get the ORA-06502 error.
    I can certainly implement a work-around for my issue by creating a 'Before Header' process on the page which populates an ApEx collection with the data I am returning and then the report can simply select from the collection, but according to documentation, the above 32K limitation should be resolved in 11g.  Thoughts?
    Shane.

    What setting do you use in your report properties - especially in Type and in Region Source?
    If you have Type="SQL Query", then you should have a SELECT statement in the Region Source. Something like: SELECT .... FROM ... WHERE
    According to the ERR-1101 error message, you have probably set Type to "SQL Query (PL/SQL function body returning SQL query)". In this situation APEX expects you to write a body of a PL/SQL function, that will generate the text of a SQL query that APEX should run. So it can be something like:
    declare
    mycond varchar2(4000);
    begin
    if :P1_REPORT_SEARCH is not null THEN
    mycond:='WHERE LAST_NAME like :P1_REPORT_SEARCH ||''%''';
    end if;
    return 'select EMPLOYEE_ID, FIRST_NAME, LAST_NAME from EMPLOYEES ' ||mycond;
    end;
    And for escaping - are you interested in escaping the LIKE wildcards, or the quotes?
    For escaping the wildcards in LIKE function so that when the user enters % you will find a record with % and not all functions, look into the SQL Reference:
    http://download-uk.oracle.com/docs/cd/B19306_01/server.102/b14200/conditions007.htm
    (You would than need to change the code of your function accordingly).
    If you are interested in escaping the quotes, try to avoid concatenating the values entered by the user into the SQL. If you can, use bind variables instead - as I have in my example above. If you start concatenating the values into the text of SQL, you are open to SQLInjection - user can enter anything, even things that will break your SQL. If you really need to allow users to choose the operator, I would probably give them a separate combo for operators and a textfield for values, than you could check if the operator is one of the allowed ones and create the condition accordingly - and than still use bind variable for inserting the filtering value into the query.

  • Setting Oracle Permissions for file access from a pl/sql function

    I have a pl/sql function that calls a java method which moves a
    file from a directory to another.
    Since we are using Linux, Oracle wants some permissions.
    Those permissions are set using:
    call dbms_java.grant_permission(USER, 'java.io.FilePermission',
    FILE, permission)
    OK, i want to use this in my pl/sql function, but it doesn't
    work.
    My function looks like something like this:
    -- some pl/sql code
    dbms_java.grant_permission(someUSER, 'java.io.FilePermission',
    sourceFILE, 'write');
    dbms_java.grant_permission(someUSER, 'java.io.FilePermission',
    destFILE, 'write');
    flag := move(sourceFILE, destFILE);
    -- flag is for 1 -> done and 0 -> error
    -- some more code ...
    The problem is the lines of
    dbms_java.grant_permission(someUSER, 'java.io.FilePermission',
    sourceFILE, 'write');
    do not work!
    When i grant permissions manually in sql plus it works great,
    but when i do it from the function it does not work!
    Any ideas anyone?
    Any help would be appreciated.

    The command :
    dbms_java.grant_permission
    (someUSER, 'java.io.FilePermission',sourceFILE, 'write');
    is right.
    Open sqlplus
    Connect as sys or system
    type :
    execute dbms_java.grant_permission
    (someUSER, 'java.io.FilePermission',sourceFILE, 'write');
    commit;
    try to compile again your procedure...does it work now ?
    bye
    Giovanni Regola

  • For each row of a table call a pl/sql function

    Hi,
    i have a search form in adf like this:
    parameter1:___
    parameter2:____
    buttonSearch
    Table with results
    field1 field2 field3
    row1 ------ --------- -------
    row2 ------ --------- -------
    row3 ------ --------- -------
    The user inputs the parameters 1 and 2 then press buttonSearch and the query execute and returns rows 1 to 3.
    What i need is for each row call pl/sql function and passed the parameter 1 and 2 and field 1 to 3 (plsql function recives 5 parameters (parameter1, parameter2, field1 , field2 and field3) )
    my buttonSearch call a java class that execute ExecuteWithParamters method.
    I create the call to my plsql function on Application module class and then export as a java interface.
    So i have the function to use in the viewcontroller layer, but i don't know where to use it, and how to pass the paramters: the parameter 1 and 2 that user inputs and the row fields.....
    any ideas....
    thanks!!

    Hi,
    for this you need to call the PLSQL function upon table rendering, which means that you need a field in the table referencing a managed bean. In the managed bean you can use #{row} and resolve it using a ValueExpression. #{row} gives you access to the current rendered row (this is why you need to do it when the table renders) and thus allows you to call getAttribute(name) to get the values of field 1 - 3. The search field value you should get through the bindings reference (assuming the search form uses ADF). Then you create an operation binding for the executeWithParameters and call operationBindingName.getParamsMap().put(argname, argvalue); on it.
    Frank
    Ps.: I am concerned about the performance you get and wonder if it isn't possible to create a transient attribute that executes the function and displays the results. As I understand, the search parameters are only to filter the result set, which you still can do

  • SQL Query (PL/SQL Function Body returning SQL query) doesn't return any row

    I have a region with the following type:
    SQL Query (PL/SQL Function Body returning SQL query).
    In a search screen the users can enter different numbers, separated by an ENTER.
    I want to check these numbers by replacing the ENTER, which is CHR(13) || CHR(10) I believe, with commas. And then I can use it like this: POD IN (<<text>>).
    It's something like this:
    If (:P30_POD Is Not Null) Then
    v_where := v_where || v_condition || 'POD IN (''''''''||REPLACE(''' || :P30_POD || ''', CHR(13) || CHR(10), '','')||'''''''''')';
    v_condition := ' AND ';
    End If;
    But the query doesn't return any rows.
    I tried to reproduce it in Toad:
    select * from asx_worklistitem
    where
    POD IN (''''||REPLACE('541449200000171813'||CHR(13) || CHR(10)||'541449206006341366', CHR(13) || CHR(10), ''',''')||'''')
    ==> This is the query that does't return any rows
    select (''''||REPLACE('541449200000171813'||CHR(13) || CHR(10)||'541449206006341366', CHR(13) || CHR(10), ''',''')||'''')
    from dual;
    ==> This returns '541449200000171813','541449206006341366'
    select * from asx_worklistitem
    where pod in ('541449200000171813','541449206006341366');
    ==> and when I copy/paste this in the above query, it does return my rows.
    So why does my first query doesn't work?
    Doe anyone have any idea?
    Kind regards,
    Geert
    Message was edited by:
    Zorry

    Thanks for the help.
    I made it work, but via the following code:
    If (:P30_POD Is Not Null) Then
    v_pods := REPLACE(:P30_POD, CHR(13) || CHR(10));
    v_where := v_where || v_condition || 'POD IN (';
    v_counter := 1;
    WHILE (v_counter < LENGTH(v_pods)) LOOP
    v_pod := SUBSTR(v_pods, v_counter, 18);
    IF (v_counter <> 1) THEN
    v_where := v_where || ',';
    END IF;
    v_where := v_where || '''' || v_pod || '''';
    v_counter := v_counter + 18;
    END LOOP;
    v_where := v_where || ')';
    v_condition := ' AND ';
    End If;But now I want to make an update of all the records that correspond to this search criteria. I can give in a status via a dropdownlist and that I want to update all the records that correspond to one of these POD's with that status.
    For a region you can build an SQL query via PL/SQL, but for a process you only have a PL/SQL block. Is the only way to update all these records by making a loop and make an update for every POD that is specified.
    Because I think this will have a lot of overhead.
    I would like to make something like a multi row update in an updateable report, but I want to specify the status from somewhere else. Is this possible?

  • How to use SQL functions in the queries

    hey guys i wanna know how to use SQL functions in the queries is it possible or not .

    Hi,
    Wat exactly that set values are?
    those from sql query?
    How to use count():
    The COUNT() function returns the number of rows that matches a specified criteria.
    SQL COUNT(column_name) Syntax
    The COUNT(column_name) function returns the number of values (NULL values will not be counted) of the specified column:
    SELECT COUNT(column_name) FROM table_name
    SQL COUNT(*) Syntax
    The COUNT(*) function returns the number of records in a table:
    SELECT COUNT(*) FROM table_name
    SQL COUNT(DISTINCT column_name) Syntax
    The COUNT(DISTINCT column_name) function returns the number of distinct values of the specified column:
    SELECT COUNT(DISTINCT column_name) FROM table_name
    The IN function helps reduce the need to use multiple OR conditions.
    The syntax for the IN function is:
    SELECT columns
    FROM tables
    WHERE column1 in (value1, value2, .... value_n);

  • SQL Query updateable report with row selector. Update process.

    I have a SQL Query updateable report with the row selector(s).
    How would I identify the row selector in an update process on the page.
    I would like to update certain columns to a value of a select box on the page.
    Using the basic:
    UPDATE table_name
    SET column1=value
    WHERE some_column=some_value
    I would need to do:
    UPDATE table_name
    SET column1= :P1_select
    WHERE [row selector] = ?
    Now sure how to identify the [row selector] and/or validate it is checked.
    Thanks,
    Bob

    I don't have the apex_application.g_f01(i) referenced in the page source...In the page source you wouldn't find anything by that name
    Identify the tabular form's checkbox column in the page(firebug/chrome developer panel makes this easy)
    It should be like
    &lt;input id=&quot;...&quot; value=&quot;&quot; type=&quot;checkbox&quot; name=&quot;fXX&quot; &gt;we are interested in the name attribute , get that number (between 01 and 50)
    Replace that number in the code, for instance if it was f05 , the code would use
    apex_application.g_f05
    --i'th checked record' primary keyWhen you loop through a checkbox array, it only contains the rows which are checked and it is common practice to returns the record's primary key as the value of the checkbox(available as the the i'th array index as apex_application.g_f05(i) , where i is sequence position of the checked row) so that you can identify the record.

Maybe you are looking for