Calling function from sql folder vs report

Hi,
A report based on a custom sql folder is taking a long time to run. One of the things that I noticed is that when I run the sql in plsql it takes a long time, but if I remove the row where I call a function, it runs pretty quickly.
In general, is there a difference between running a function from the sql custom folder and calling it from the report itself?
Thanks.
Leah

Hi Tamir,
I might check out the execution plans, but truthfully, understanding the plans and the meaning of the differences is not my strong point.
I thought that maybe there was some general rule that, for instance, it is better to keep functions out of the sql folder and use them in a condition in the report itself, or the opposite, or that maybe it makes no difference at all.
I appreciate the response.
Thanks.
Leah

Similar Messages

  • Getting session hang When calling Function from SQL query

    Hi All,
    I am using Oracle 8.1.7.4.0. I have a fucntion in a Package and I am calling it from the SQL query. When I am firing the query my oracle session is going to hang position and I am not able to any thing. I have to kill the session.
    But this same thing is working fine in Oracle 9.i.
    There are no out parameter and no DML, DDL and DCL statement in this fucntion.
    Could you please get back me what is the problem on it.
    Regards
    SUN

    Check why your session hangs.
    Just a few ideas:
    * Blocking locks?
    * Endless loop?
    * Performance (maybe it is just slow in orac8i and you have to wait a bit longer). Check the execution plans of the SQL statements in your function.
    * Don't use a function, but direct SQL, it is faster in both versions.

  • Regarding Restrictions on calling functions from sql expressions

    Hi all,
    While going through the functions of oracle 9i plsql documentation i came across restrictions on calling a function, i that i did not understand the following statement. can anyone explain me with an example. Please.........
    Functions called from SQL statements cannot contain statements that end the transactions.
    Regards,
    Sri Ram.

    Some where from google
    http://www.ucertify.com/article/what-are-the-restrictions-on-a-user-defined-function-that-is-called-from-a-sql-expression.html
    >
    •The function cannot contain statements that end the transaction. For example, the function cannot contain transaction control statements (such as COMMIT), session control statements (such as SET ROLE), or system control statements (such as ALTER SYSTEM). Also, it cannot contain DDL statements (such as CREATE) because they are followed by an automatic COMMIT.

  • Calling a function from SQL prompt that returns a record

    Hi,
    I've been trying to execute a function that is present on a different database. for eg. I am loged on to a database say 'A' and trying to execute a function present in database 'B'. this function is present in a package 'X' which has 2 functions and two procedures. From the packages i am able to execute the two procedures and one of the function.
    So i guess it is not a problem with the access permissions. The function that i am trying to call say function I has got 3 OUT
    parameters and 1 IN parameter. the Function returns a record. When i try to execute this function i get an error. Can you please let me know as to how exactly i need to call this function from the SQL prompt...
    thanx in advance
    null

    Hi Anand,
    As your function has 3 OUT parameters and it returns a record you can not just call it from SQL Plus. You need to write small PL/SQL program and use variables to hold the OUT values and the returned record.
    Good Luck,
    RajKiran
    null

  • Call function from data base with clob input parameter.

    Hello,
    In this project I use Jdev 11g.
    I call function from database.
    create or replace function get_fa_list (
    p_fa_id_list in clob
    return sys_refcursor
    is
    vCursor sys_refcursor;
    begin
    put_msg ('begin');
    if p_fa_id_list is null then
    put_msg ('CLOB is null!');
    else
    put_msg ('size CLOB: ' || dbms_lob.getlength (p_fa_id_list));
    end if;
    put_msg ('Save');
    open vCursor for
    select rownum as id, s.*
    from (
    select f.latitude, f.longitude, count (distinct f.res_id) as res_count, count (*) as fa_count, 16711680 as color, res_concat_distinct (f.res_id) as station_list
    from mv_frequency_assignment f, table (SplitClob (p_fa_id_list, ',')) l
    where f.ext_system = 'BI' and
    f.ext_sys_id = l.column_value
    group by f.latitude, f.longitude
    ) s;
    put_msg ('Open and End');
    return vCursor;
    end get_fa_list;
    I use TopLink in ejb.
    i use follow code for call function and get result.
    public List<TmpResPoints> findAllPointsBI(String p_id){
    UnitOfWork uow = getSessionFactory().acquireUnitOfWork();
    uow.beginEarlyTransaction();
    StoredFunctionCall call = new StoredFunctionCall();
    call.setProcedureName("get_fa_list");
    call.useUnnamedCursorOutputAsResultSet();
    ClobDomain c = new ClobDomain(p_id);
    //System.out.println(c.toString());
    call.addNamedArgumentValue("p_fa_id_list", c);
    ReadAllQuery query = new ReadAllQuery();
    query.setReferenceClass(TmpResPoints.class);
    query.setCall(call);
    List<TmpResPoints> result = (List<TmpResPoints>)uow.executeQuery(query);
    uow.commit();
    uow.release();
    return result;
    But size parameter "p_fa_id_list" is 0. (geting from temp table in Data base). this code in function >>
    if p_fa_id_list is null then
    put_msg ('CLOB is null!');
    else
    put_msg ('size CLOB: ' || dbms_lob.getlength (p_fa_id_list));
    end if;)
    How I can call this function from dataBase and get result?
    thx,
    Demka.

    What is the SQL generated?
    The argument should just be the Clob value (a String) not the domain object.
    Also try addNamedArgument, and then pass the named argument to the query.
    James : http://www.eclipselink.org

  • How to Call Function from SAPSCRIPT

    I want to Call a function from my SAPSCRIPT to get some data and print the same in the form , Can I get an example for this

    Hi Nandan,
    U cannot directly call function from SAPScript... For that u have to create one include in which u need to write the code. Using Perform... EndPerform u can call the same from SAPScript. See the below example
    u need to write this code in SAPScript
    PERFORM formname IN PROGRAM includename
    USING &field1&                                      
    USING &field2&                                      
    CHANGING &field3&                                     
    ENDPERFORM                                               
    Here includename is your include type program.
    u need to write this code in your include type program..
    FORM formname TABLES in_par STRUCTURE itcsy
                            out_par STRUCTURE itcsy.
    data : var1 like field1,
           var2 like field2,
           var3 like field3.
      READ TABLE in_par WITH KEY 'field1'.
      CHECK sy-subrc = 0.
      var1 = in_par-value.
      READ TABLE in_par WITH KEY 'field2'.
      CHECK sy-subrc = 0.
      var2 = in_par-value.
    now u can call corresponding function using local VAR1 and VAR2. Here u can pass N no of USING parameters.
    After processing on VAR3...
      READ TABLE out_par WITH KEY 'field3'.
      out_par-value = VAR3.
      MODIFY out_par INDEX sy-tabix.
    EndForm.
    Here in_par and out_par are the structures which will be used to communicate with SAPScript. And this is the only way as per my view.
    I m sure this code will work fine. Here i have used dummy variables that u need to change as per your requirement. If u have more queries write me back.
    And yes if this works than dont forget to give the points.
    Regards,
    Sagar

  • Send data to ECC table through RFC Call function from SAP B1 via  b1if

    Hi,
    I have created scenario in B1if which triggers from SAP B1, now I have to send this data in to ECC table, so I have created scenario for that with inbound SAP B1, outbound void and in process RFC Call atom is there but I am not getting data in receiver and also how to write xml to send data in RFC function. Function for RFC has configured from ECC end and have access of that function.
    So please help me to send data to ECC table through RFC Call function from SAP B1 (9.0) via b1if
    Thanks

    Solved by my own.

  • Calling function from PL/SQL block

    Hi,
    A very simple question.
    A have a function called "test1" in my database. It is there i double chekked.
    I would like to call this function from a block:
    DECLARE
    BEGIN
    TEST1(1202);
    END;
    This gives me an error.
    Why is this?

    user610868 wrote:
    Hi,
    A very simple question.
    A have a function called "test1" in my database. It is there i double chekked.
    I would like to call this function from a block:
    DECLARE
    BEGIN
    TEST1(1202);
    END;
    This gives me an error.
    Why is this?Hello
    A very very basic thing to do when you get an error is to include details of it. That helps narrow it down from one of the 1000s of potential Oracle errors it could be.
    Anyway, a function returns a value, and in PL/SQL you need to capture that otherwise you'll get "an error". Modify your code like so
    DECLARE
       l_Test1Val     VARCHAR2(4000); --CHANGE THIS TO BE THE SAME AS THE RETURN TYPE FOR YOUR FUNCTION
    BEGIN
       l_Test1Val :=  TEST1(1202);
    END;HTH
    David
    Edited by: Bravid on Oct 25, 2011 3:57 PM
    removed a ;

  • Calling a function from sql*plus

    I can call my procedure from sql *plus
    by doing
    sql>call Proc_name(x,y);
    How do you call a function?
    null

    John,
    I think moifying the statement
    CREATE OR REPLACE PROCEDURE "OGUSER"."OGX1" (user_county in integer, user_permit in integer )
    TO
    CREATE OR REPLACE FUNCTION "OGUSER"."OGX1" (user_county in integer, user_permit in integer ) return NUMBER is
    AND before end you will have to add a return statement
    (Probably
    return 0;
    exception
    when others then
    return 1;
    end;
    This will change your procedure to a function but I am not sure you'll be able to see your dbms_output's, if you call the function using select ...
    <BLOCKQUOTE><font size="1" face="Verdana, Arial, Helvetica">quote:</font><HR>Originally posted by john saucer ([email protected]):
    I want to turn my procedure into a function.
    So I can call it with a select statement.
    I'm kind of having problems with the return statement at the top and bottom.
    I don't quite understand how to declare the type in the return. My procedure calculates 2 pl/sql tables....
    My procedure looks like.
    CREATE OR REPLACE PROCEDURE "OGUSER"."OGX1" (user_county in integer, user_permit in integer )
    as
    i integer :=0;
    j integer :=0;
    type dept_table_type is table of ogxtest%rowtype
    index by binary_integer;
    type dept2_table_type is table of ogxtest%rowtype
    index by binary_integer;
    my_dept_table dept_table_type;
    my_dept2_table dept2_table_type;
    v_cotemp number := user_county;
    v_permittemp number := user_permit;
    v_origcotemp number := user_county;
    v_origpermittemp number := user_permit;
    v_count number(2) :=1;
    v_count2 number(2) := 1;
    v_oldcount number(2) :=1;
    v_oldcount2 number(2) := 1;
    begin
    select count(*) into v_count from ogxtest where oco=v_cotemp and opermit=v_permittemp;
    select count(*) into v_oldcount from ogxtest where nco=v_cotemp and npermit=v_permittemp;
    while v_count >= 1 LOOP
    i := i+1;
    v_count2 := v_count2 +1;
    select *
    into my_dept_table(i)
    from ogxtest where oco=v_cotemp and opermit=v_permittemp;
    v_cotemp := my_dept_table(i).nco;
    v_permittemp := my_dept_table(i).npermit;
    select count(*) into v_count from ogxtest where oco=v_cotemp and opermit=v_permittemp;
    end loop;
    while v_oldcount >= 1 LOOP
    j := j+1;
    v_oldcount2 := v_oldcount2 +1;
    select *
    into my_dept2_table(j)
    from ogxtest where nco=v_origcotemp and npermit=v_origpermittemp;
    v_origcotemp := my_dept2_table(j).oco;
    v_origpermittemp := my_dept2_table(j).opermit;
    select count(*) into v_oldcount from ogxtest where nco=v_origcotemp and npermit=v_origpermittemp;
    end loop;
    for i in 1..v_count2-1
    loop
    dbms_output.put_line(' reassigned to - orig county ' | |my_dept_table(i).oco | | ' orig permit ' | |my_dept_table(i).opermit| | ' new county ' | |
    my_dept_table(i).nco | | ' new permit ' | |my_dept_table(i).npermit );
    end loop;
    for j in 1..v_oldcount2-1
    loop
    dbms_output.put_line(' reassigned from - orig county ' | |my_dept2_table(j).oco | | ' orig permit ' | |my_dept2_table(j).opermit| | ' new county ' | |
    my_dept2_table(j).nco | | ' new permit ' | |my_dept2_table(j).npermit );
    end loop;
    end;
    <HR></BLOCKQUOTE>
    null

  • Put SQL query in a function/ call function from region

    How can I write a SQL query (like SELECT EMPNO, ENAME, JOB FROM EMP) as PL/SQL function, and then call this function from the PL/SQL Function Returning SQL Statement region?
    Thanks, Tom

    thanks jverd for your quick reply.
    I know passing in a reference to an object will do the job if I want to change the value several parameters in one function call.
    But I want to ask, is there any other ways?
    the following code works.....
    public class TestParameter {
         public static void main(String[] args) {
              Test2 t2 = new Test2();
              invokeChange(t2);
              System.out.println("x = " + t2.x + "\t y = " + t2.y);
         static void invokeChange(Test2 t2) {
              t2.x = 10;
              t2.y = 15;          
    class Test2 {     
         int x;
         int y;     
    }

  • Calling ORACLE Functions from within CF Builder report

    Hi, I have an ORACLE function that I would like to call from within my CF REPORT.
    I know there is a section in the report builder where you can write coldfusion code to perform tasks, but I would rather simply call the ORACLE function for each detail row in the report
    I do not want to call this function from within my main ORACLE query that I use for the report, so please don't suggest that.
    Thanks so much.
    -Jim

    6.0.5 is not certified against 10g database, so I suggest to upgrade to 6.0.8.26 (6i patch 17) first to see if the problem is gone.

  • Calling a BOOLEAN returning function from SQL

    Hello All,
    I have created below function which return BOOLEAN value :
    CREATE OR REPLACE FUNCTION FUNC_1
    P_EMPID IN emp.empno%type
    )RETURN BOOLEAN
    AS
    L_VAR NUMBER;
    BEGIN
    SELECT 1 INTO L_VAR
    FROM EMP
    WHERE EMPNO = P_EMPID;
    IF L_VAR = 1 THEN
    RETURN TRUE;
    ELSE
    RETURN FALSE;
    END IF;
    END;Now I want to call this function from SELECT but I know that SQL does not support BOOLEAN value so I tried in other way i.e. via CASE
    SELECT CASE FUNC_1(7788)
           WHEN TRUE THEN 'TRUE'
           WHEN FALSE THEN 'FALSE'
           ELSE 'NULL'
           END CASE
    FROM DUALBut it is giving me error "ORA-00904: "FALSE": invalid identifier'
    How can I achieve this ?
    Thanks & Regards,
    Rakesh

    Hi Rakesh,
    Why cant you try something like this, When BOOLEAN type is not supported in SQL.
    Here I have made the return value a number. And, at case comparison, we get the BOOLEAN
    result as TRUE of FALSE.
    CREATE OR REPLACE FUNCTION func_1 (p_empid IN emp.empno%TYPE)
       RETURN NUMBER
    AS
       l_var   NUMBER;
    BEGIN
       SELECT count(*)
         INTO l_var
         FROM emp
        WHERE empno = p_empid;
       IF l_var = 1
       THEN
          RETURN 1;
       ELSE
          RETURN 0;
       END IF;
    END;And,
    SELECT CASE func_1 (55656)
              WHEN 1
                 THEN 'TRUE'
              WHEN 0
                 THEN 'FALSE'
           END
      FROM DUAL;Which return TRUE if the Employee Number Exists and FALSE if doesnot.
    Thanks,
    Shankar.

  • Calling the function from SQL query

    Hi,
    I am trying to run the below statement,
    Select to_number(apps.pay_balance_pkg.get_value( 326, :paa.assignment_action_id,to_date ('31032011','ddmmyyyy'))) from dual;
    getting an error as :
    ORA-14552 cannot perform a DDL, commit or rollback inside a query or DML
    ORA - 06512 at apps.pay_balance_pkg , line 4526.
    How can I execute this funciton "apps.pay_balance_pkg.get_value" from sql query?
    Thanks in advance.

    user1175432 wrote:
    Hi,
    I am trying to run the below statement,
    Select to_number(apps.pay_balance_pkg.get_value( 326, :paa.assignment_action_id,to_date ('31032011','ddmmyyyy'))) from dual;
    getting an error as :
    ORA-14552 cannot perform a DDL, commit or rollback inside a query or DML
    ORA - 06512 at apps.pay_balance_pkg , line 4526.
    How can I execute this funciton "apps.pay_balance_pkg.get_value" from sql query?
    Thanks in advance.If the function is performing DDL, commit or rollback inside it then you will not be able to call it from an SQL statement.
    Either change the function so it doesn't perform DDL, commit or rollback, or use a different means to obtain the information you want (assuming you can't change the function)

  • Call external function from SQL query

    Hi,
    I am new to PL/SQL programming.I don't think this is possible but please let me know if there is a way to achieve this. I have a function written in VB.net and I would want to call from the query.
    create table temp as select id, callvbfunction(note_text) from temp2
    Here callvbfunction is the vb.net function.I need to pass note_text field value to the function.
    Thanks..

    Yes it is possible.
    No idea how to specifically call a .Net function (from Oracle) as I do not do Windows (except for playing games ;-) ). But external procedures (extproc) and Java stored procs can be wrapped by PL/SQL wrapper functions and used in SQL statements.

  • Call function from pl/sql when the name of funcion is in variable

    Hi,
    is it possible to do the following:
    I want to call (excute) a function within a pl/sql block, but the problem is that the name of the called function is stored in variable (is got as a parameter to mine pl/sql block).
    let's imagine:
    DECLARE
    name_of_function varchar2(10);
    result number;
    BEGIN
    result := ???name_of_function????;
    END;
    thanks for any suggestion,
    valer

    thanks for answer this exactly what i need.
    as i learned EXECUTE IMMEDIATELY does invoke pl/sql block dynamicaly.
    I tried it for invoking procedure. it woked fine. But not for function.
    So, does it work also for invoking FUNCTIONS ?

Maybe you are looking for