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.

Similar Messages

  • Variable database name in SQL Server query using Oracle database link

    Hi All,
    I have an ApEx 4.1 app running on 11g x64 (11.2.0.1) on Windows Server 2008 x64, and I have some data integration points with a SQL Server (2005 and 2008) that I need to establish. I have configured the database link with dg4odbc and it works beautifully... I can execute queries against the SQL Server database without any problems using the database link.
    However, there is a scenario where the SQL Server database name is dynamic, and I need to generate it on the fly in a PL/SQL block, and then use that in a dynamic SQL query (all of this in ApEx). This is where I run into problems... when I am querying the default database based on the ODBC connection and I don't have to specify the database name, there is no issue. But when I need to access one of several other non-default databases, I keep receiving the "invalid table" error.
    This runs fine:* (note that "fv" is the name of my database link)
    v_query1 := 'select "ReleaseDate" from dbo.Schedules@fv where dbo.Schedules."SchedID" = :schedule';
    EXECUTE IMMEDIATE v_query1 into rel_date using schedule;
    I then take that rel_date variable, convert to a varchar2 (rel_date_char), and then use it as the database name in the next query...
    This returns an error_ (Error ORA-00903: invalid table name)
    v_query2 := 'select "PARTNO" from :rel_date_char.dbo.ProdDetails@fv where "SchedID" = :schedule and "UnitID" = :unit
    and "MasterKey" = :master and "ParentKey" = :parent';
    EXECUTE IMMEDIATE v_query2 into part_number using schedule, unit, master, parent;
    I have also tried using all of the following to no avail:
    'select "PARTNO" from ' || :rel_date_char || '.dbo.ProdDetails@fv where "SchedID"...
    'select "PARTNO" from ' || rel_date_char || '.dbo.ProdDetails@fv where "SchedID"...
    'select "PARTNO" from ' || @rel_date_char || '.dbo.ProdDetails@fv where "SchedID"...
    'select "PARTNO" from @rel_date_char.dbo.ProdDetails@fv where "SchedID"...
    Is there a way to do this in PL/SQL?
    Thanks for any help!
    -Ian C.
    Edited by: 946532 on Jul 15, 2012 7:45 PM

    Just did a test using passthrough:
    SQL> set serveroutput on
    SQL> declare
    2 val varchar2(100);
    3 c integer;
    4 nr integer;
    5 begin
    6 c:= dbms_hs_passthrough.open_cursor@FREETDS_DG4ODBC_EMGTW_11_2_0_3;
    7 dbms_hs_passthrough.parse@FREETDS_DG4ODBC_EMGTW_11_2_0_3 (c, 'select count(*) from EMP');
    8 LOOP
    9 nr:= DBMS_Hs_Passthrough.fetch_row@FREETDS_DG4ODBC_EMGTW_11_2_0_3(c);
    10 exit when nr=0;
    11 dbms_hs_passthrough.get_value@FREETDS_DG4ODBC_EMGTW_11_2_0_3(c,1,val);
    12 dbms_output.put_line(val);
    13 end loop;
    14 dbms_hs_passthrough.close_cursor@FREETDS_DG4ODBC_EMGTW_11_2_0_3(c);
    15 end;
    16 /
    24576
    PL/SQL procedure successfully completed.
    SQL> declare
    2 val varchar2(100);
    3 c integer;
    4 nr integer;
    5 begin
    6 c:= dbms_hs_passthrough.open_cursor@FREETDS_DG4ODBC_EMGTW_11_2_0_3;
    7 dbms_hs_passthrough.parse@FREETDS_DG4ODBC_EMGTW_11_2_0_3 (c, 'select count(*) from dbo.EMP');
    8 LOOP
    9 nr:= DBMS_Hs_Passthrough.fetch_row@FREETDS_DG4ODBC_EMGTW_11_2_0_3(c);
    10 exit when nr=0;
    11 dbms_hs_passthrough.get_value@FREETDS_DG4ODBC_EMGTW_11_2_0_3(c,1,val);
    12 dbms_output.put_line(val);
    13 end loop;
    14 dbms_hs_passthrough.close_cursor@FREETDS_DG4ODBC_EMGTW_11_2_0_3(c);
    15 end;
    16 /
    24576
    PL/SQL procedure successfully completed.
    So all 3 ways work for me.
    Edited by: kgronau on Jul 23, 2012 10:08 AM
    Now using variables to perform the select:
    SQL> declare
    2 val varchar2(100);
    3 c integer;
    4 nr integer;
    5 tabname varchar2(20) :='EMP';
    6 ownr varchar2(20) :='dbo';
    7 dbname varchar2(20) :='gateway';
    8 begin
    9 c:= dbms_hs_passthrough.open_cursor@FREETDS_DG4ODBC_EMGTW_11_2_0_3;
    10 dbms_hs_passthrough.parse@FREETDS_DG4ODBC_EMGTW_11_2_0_3 (c, 'SELECT count(*) FROM '||dbname||'.'|| ownr || '.'||tabname||'');
    11 LOOP
    12 nr:= DBMS_Hs_Passthrough.fetch_row@FREETDS_DG4ODBC_EMGTW_11_2_0_3(c);
    13 exit when nr=0;
    14 dbms_hs_passthrough.get_value@FREETDS_DG4ODBC_EMGTW_11_2_0_3(c,1,val);
    15 dbms_output.put_line(val);
    16 end loop;
    17 dbms_hs_passthrough.close_cursor@FREETDS_DG4ODBC_EMGTW_11_2_0_3(c);
    18 end;
    19 /
    24576
    PL/SQL procedure successfully completed.
    => instead of executing the statement using "execute Immediate" we have to use PASTHROUGH package to pass the statement to the SQL Server.
    Edited by: kgronau on Jul 23, 2012 10:10 AM

  • How to access APEX variables within compiled pl/sql function.

    Hi,
    My initial problem is to create pl/sql code returning column names for my custom calendar report.
    There are 7 columns for each day of the week and I want it to be on two rows - first the day of the week, such as 'Monday' and below it (with BR tag) the date, such as '18-08-2008'.
    What I want is to set additional tags for underline, italics, etc. on the column heading which date is currently selected for viewing (I have DATE item for this purpose).
    But as the code is getting quite complex, I decided to write a function in my schema that would return the column delimited values for the headings.
    What I can't do is the following.
    1) How do I reference an APEX item value, such as my DATE item? using v('P4_DATE') results in unknown function 'v'.
    2) How do I use char-date and vice versa conversion using the already set application format mask, available in APEX 3.1? So that when I change the date format mask within the application, it would still work.
    10x and I hope I'm not repeating s.o. else's question.

    Hi,
    I won't try to create the entire function here, just enough to point you in the right direction.
    Create a function something like:
    create or replace FUNCTION "GETHEADINGS" (inDATE IN VARCHAR2, inFORMAT IN VARCHAR2)
    RETURN VARCHAR2
    IS
    BEGIN
      DECLARE
        vTHISDATE DATE;
        vSTRING VARCHAR2(1000);
      BEGIN
        vTHISDATE := TO_DATE(inDATE, inFORMAT);
        vSTRING := TO_CHAR(vTHISDATE, inFORMAT);
        RETURN vSTRING;
      END;
    ENDinDate would receive the item's date value and inFORMAT receives the date format. vTHISDATE converts the date supplied into a date using the date format and vSTRING turns that into a string, again using the date format. Obviously, this example will just return the original date.
    To add styling to any column, just surround the column text with the appropriate tags whilst building up your string. For example:
    '&lt;i&gt;' || columnheading || '&lt;/i&gt;'Now, in your report's Report Attributes, change the Headings Type to PL/SQL and enter in something like:
    DECLARE
    vHEADINGS VARCHAR2(1000);
    BEGIN
    SELECT GETHEADINGS(:P1_DATE_FIELD, :PICK_DATE_FORMAT_MASK) INTO vHEADINGS FROM DUAL;
    RETURN vHEADINGS;
    END;When you've created the function you need, the string returned should be in the column headings delimited with colons.
    Andy

  • Is it possible to retrieve RAD's extended variables with a pl/sql function?

    Good morning everyone,
    We have our forms and reports(10g) application, SSO enabled and we are using OID on 10g app server. some of our users use smart card to log in to the system and some who do not have smart cards provide their database userid, password and SID.
    In the case of users who login with smart card, as a one time effort, they have to register their smart card. At that point OID presents a form prompting for their username, password, sid and then a RAD record is created for that particular user.
    And from then on when the user enters the system using his smart card(12345@mil), forms servlet, does the look up of dbusername,dbpswd,sid which belong to the 12345@mil and user's database credentials are passed to the application. The entire application logic is based on that userid which is also an internal userid in the application. Everything is working fine.
    I have read the documentation and found that 12345@mil is stored in the "cn" parameter and the orclownerguid and orclusernameattribute are stored under "cn"=extended properties in the oid. I am able to see this from the oid console.
    But now I need some help. If I only know the id of the user as "12345@mil" , is it possible to manually query the RAD and retrieve the orclusername from a pl/sql function?
    Any help is greatly appreciated.
    Regards,
    Suma.

    Please can anyone help me????
    Regards,
    Suma.

  • 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

  • Using Variables in a "Report Custom Functions"

    Hi!
    I created a custom function using Basic Syntax where I am trying to declare/use variables.  I keep getting syntax errors and don't know why.  Here is my code so far:
    Function cdQSIPeriod () As String
    YY = Year(CurrentDate)
    MM = Month(CurrentDate)
    If MM = 1 then
        MM = 12
        YY = YY - 1
    else
        MM = MM - 1
    cdQSIPeriod = String(MM)& String(YY)
    End Function
    Any help you can provide will be appreciated.

    You need to add
    dim YY as number
    dim MM as number
    HTH,
    Carl

  • 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

  • Help with using variable for name of table in PLSQL block...

    I am trying to use a variable for the name of a table but getting errors ...i am sure I am close to the correct form here but something is wrong. I sure would appreciate some help!
    DECLARE
    ln_month Number;
    ln_day Number;
    ln_year Number;
    ls_year VarChar2(4);
    ls_prev_table VarChar2(30);
    ls_cur_table VarChar2(30);
    ln_prev_year Number;
    ls_prev_year VarChar2(4);
    ln_prev_month Number;
    BEGIN
    Select To_Number(To_Char(sysdate, 'MM')) into ln_month from dual;
    Select To_Number(To_Char(sysdate, 'DD')) into ln_day from dual;
    Select To_Number(To_Char(sysdate, 'YYYY')) into ln_year from dual;
    If ln_month = 01 Then
    ls_cur_table := "T_CPRS_FDW_CUR_JAN_ACTUALS";
    ls_prev_table := "T_CPRS_FDW_PREV_DEC_ACTUALS";
    ln_prev_year := ln_year - 1;
    /***above is where I am trying to use variables for assignement to years and months tables***//// ln_prev_month := 12;
    End If;
    /*------MORE IF STATEMENTS FOR EACH MONTH ---OF --THE YEAR ...AND its the following 2 variable statements that the compiler doesnt like! */
    If ln_day < 20 Then
    Delete from :ls_prev_table;
    INSERT INTO :ls_prev_table /*(STUFF TO BE INSERTED GOES HERE)*/
    HELP PLEASE!
    null

    Hi,
    The parser does not under variables directly in dml statements.u need to form a statement and the parse and execute the same...
    so the soln is
    Declare
    lv_stmt varchar2(250);
    Begin
    lv_stmt := 'Delete from '&#0124; &#0124;ls_prev_table;
    execute immediate lv_stmt;
    -- Same is the case with the insert stmt--
    End;
    This should solve ur problem.
    u could also give a direct call like
    execute immediate 'Delete from '&#0124; &#0124;ls_prev_table ;
    Note: This statement "execute immediate" holds good for oracle versions 8.x and above which makes the stmt very simple. For lower version u need to use the dbms_sql package to parse and execute the statement which has a series of statements for the same.
    Kiran

  • Additional Results Custom Step using Variables in Name and Value to Log expressions?

    I am trying to create a Custom Step Type for logging additional results - requiring a single Name and Value data pair included in the step.
    I want to pass the name and value data in using two specific variables.
    This functionality can of course be explicitly coded on a test step without problem, but I can't find a way to create a custom test step which inserts such a step i.e. automatically inserting the correct variable names into Name and Value to Log fields.
    Any ideas how to accomplish this? I don't want the custom step users to have to type in the variable names every time they use it.
    I am using TestStand 4.1.1
    Message Edited by CIM1 on 04-20-2009 07:26 AM

    Hi CIM1,
    There are a few ways of doing this.
    The simplest one would be to configure the expression in the Pre-Expression or Post-Expression (depending on whether you would like the Step Type to use the value in the variables or write the value to the variables) and then from here you can lock away the expressions from being edited. The caveat with this method is that you are obviously restricing the Pre/Post-Expressions for the step type. 
    Another Method would be to code some code modules to Write to/Read from the Variables and then calling these in the Steps Pre-Step SubStep or Post-Step Substep. The advantages of this method would be that you can search for the Variable, and if the variable is not present, you could create it before writing to it.
    Hope this Helps.
    Best Regards,
    Steve H 

  • Cursor using variable table name

    I'm new to Oracle, and am wondering if I can create a cursor that can take a variable name as the table it's selecting from. I am working on an application that is loading data to 1 of 3 tables. The table name is stored as a variable and the loads are done using dymanic sql to constuct the insert statement. At the end, I want to select and process some specific info from the table that's been loaded by cycling thru a cursor on whichever of the 3 tables was populated. I could create 3 cursors, one for each table, test the table_name variable, and then reference the specific cursor that way, but I thought there must be another way to do this. I want to be able to do something like this:
    CURSOR loaded_table is select distinct(process_key) from 'v_tablename' (where v_tablename is either TABLE2, TABLE2 or TABLE3)
    Any suggestions would be greatly appreciated.
    Tks...MCR

    It's possible to use dynamic SQL for something like this. If we're only talking about three tables, though, my hunch is that you'll be much happier defining three different cursors. Dynamic SQL is significantly harder to write, debug, and maintain than static SQL, so you're better off resorting to it only when there are so many tables that static SQL is impractical.
    Justin
    Distributed Database Consulting, Inc.
    www.ddbcinc.com/askDDBC

  • Use Variable value name???

    Is there a way to use a variable value's name to load data?
    What mean is, if I have a variable called "var1" and I load
    "var1" from an XML file so the value of "var1" == "XYZ", is there a
    way to use the value "XYZ" to load data to a Dynamic textbox call
    "XYZ"?
    var1 = "XYZ"
    ( XYZ is a dynamic textbox on the stage and I need to load
    XYZ with incoming data )
    Example: XYZ = "What ever text I have"
    ( but XYZ is really the vaue of "var1")
    Thanks - Gary

    yes, you can resolve strings into objects by using array
    notation. for example, if XYZ is the instance name of a textfield
    on the _root timeline and var1="XYZ", you can use:

  • Bundle install directory - using variables folder name

    Hello,
    I have bundle that has to copy a file to a specific folder in the userdirectory.
    In windows, I can use the %username% variable to get the folder name.
    How can I use that in my bundle .
    Ex : c:\users\%username%\....
    thanks in advance
    Greetings
    Lainkes

    Lainkes,
    The better variable to use would be %USERPROFILE%, which will point to the user profile directory on both Windows XP and Windows 7.
    You have a couple of options for your file copy action - you can either use a batch script within a "run script" bundle, or you can use an "install file" action.
    I'd recommend the "install file" action if it's not a terribly large file since that action results in the file being uploaded to the repository, and therefore does not require any mapped drives or UNC paths in order to copy to the client.
    Simply specify %USERPROFILE% in the "Destination Directory:" box in the install file action.
    Jacob
    Originally Posted by alain-janquart
    Hello,
    I have bundle that has to copy a file to a specific folder in the userdirectory.
    In windows, I can use the %username% variable to get the folder name.
    How can I use that in my bundle .
    Ex : c:\users\%username%\....
    thanks in advance
    Greetings
    Lainkes

  • 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;

  • 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

Maybe you are looking for

  • Report Printing Through Menu.........

    Hi i am going to print a Report from Menu with following settings.. Destype=Printer, Desname=\\machin_name\printer_name, Paramform=yes There should be only one file,but here i got amazing result. I got 2 files.. One before PARAFORM, whitch gives only

  • PCO 2.1 and PI Historiam

    Dear all, I have MII 12.2 recently installed and also PCO 2.1. I want to display PI Historian data through an OLEDB connection as i was doing with the UDS before. I have defined the connection in PCO successfully as Source System. Do i need to make a

  • I'd like to create a keyboard shortcut that involves 'two levels'- how to?

    In Premiere Pro CC I'd like to be able to create a keyboard shortcut that allows me to add an edit with the razor tool wherever I am in the timeline, even if I am currently in the selection tool. Could someone walk me through how to do this? I use a

  • ACS on virtual server

    Hello, I want to install ACS 4.2 on Microsoft Windows 2003 inside Microsoft Virtual Server. Is see that VMWare ESX is supported by Cisco. But no answer about VirtualServer. Is anyone have idee about the Cisco support with Microsoft Virtal Server host

  • Bom billing plan

    PLEASE TELL ME STEP BY STEP PROCESS OF CONFIGURING MILE STONENBILLING IN CASE OF  BOM ITEMS