Regarding Packaged function...!

Hi,
i have a packaged function which i am trying to use in my
report query....
i am passing 2 params for this function.....
one is report parameter and the other one is a col in the select query....
so i need to get rows returned based on the conditon satisfying in the query...!
i have a select stat for each condition which will return one column value to the
local variable which i am trying to check in the condition....
My problem is whenever i am running it it's get hanged or it takes a lot of time..
if iam hard coding the parameter value it's fetching records...
plz do the needful....
select
a.latest_version_no,
a.custom_ref_no,
d.customer_name1,
etc.....
etc.....
from
cstbs_contract a,
fxtbs_contract_master b,
cstbs_contractis c,
sttms_customer d
where
a.contract_ref_no=b.contract_ref_no
and
a.latest_version_no=b.version_no
and
b.contract_ref_no = c.contract_ref_no
and
d.customer_no=b.counterparty
and
NVL(b.netting_status,'N') ='N'
AND
b.VERSION_NO = (SELECT MAX(M1.VERSION_NO) FROM FXtbs_contract_master M1 WHERE M1.CONTRACT_REF_NO = B.CONTRACT_REF_NO)
AND
B.CONTRACT_REF_NO IN(SELECT PK_RET_ROWS.FN_RET_ROWS(:P_INST_CHANGE,'FXWFWXP023290102') FROM DUAL)

Ravi
For one thing you could avoid the unnecessary select from dual:
AND B.CONTRACT_REF_NO IN(SELECT PK_RET_ROWS.FN_RET_ROWS(:P_INST_CHANGE,'FXWFWXP023290102') FROM DUAL)can be changed to:
AND B.CONTRACT_REF_NO = PK_RET_ROWS.FN_RET_ROWS(:P_INST_CHANGE,'FXWFWXP023290102')You could simplify further, to make sure you only evaluate the function once, and definitely drive off M1, then B:
AND (B.CONTRACT_REF_NO, B.VERSION_NO) = (
SELECT M1.CONTRACT_REF_NO, M1.VERSION_NO
FROM FXtbs_contract_master M1
WHERE M1.CONTRACT_REF_NO = PK_RET_ROWS.FN_RET_ROWS(:P_INST_CHANGE,'FXWFWXP023290102')
)As for the speed: if you still have a problem, check you have the right indexes (eg on CONTRACT_REF_NO and (LATEST_)VERSION_NO for M1, A, B, C and on D.CUSTOMER_NO)?
HTH
Regards Nigel

Similar Messages

  • Problem in generating packaged functions!!!!!

    Does anybody know how to restrict generating packaged
    functions just in package script file?
    Generating packaged function, they are generated
    both in function script file and package script file
    while I need just in package script file.

    I think that by default the functions are included in the application default implementation as you create them. If you also include them in a package then they will be generated twice when the implementation is generated.
    If this is the case then simply delete the functions from the implementation, leaving just the package to be implemented and then everything should be ok.
    Regards,
    Steve

  • Package Function Runs OK in Database but fails inside a Mapping

    Dear Forum,
    I am stuck with an Odd Problem. I have a package.function that calculates a value using another function PNV and uses this value to update a table named F_CONTAGENS. When I run the function in the database (using SQLDeveloper) the function calculates the value and updates the column NUM_PNV_2_ANOS in table F_CONTAGENS.
    No errors . But when I run the function inside an OWB Mapping, the function returns 'NULL' and do not update the table. What could be the problem?! The mapping that uses this function is very simple: Function is connected to an Auxiliar Table (with INSERT option) that receives the value returned by the function (in this case 1). Both function's package and the mapping were already deployed without errors to the database
    Here is the function I am using (COD_MES := 200702) :
    CURSOR C_CONT IS
    SELECT C.COD_USF,
    C.COD_MES
    FROM F_CONTAGENS C
    , STG_DATA_CARREGAMENTO STC
    WHERE C.COD_MES = STC.COD_MES
    AND ((C.COD_USF = STC.COD_CARREGAMENTO_USF AND STC.COD_CARREGAMENTO_USF IS NOT NULL) OR STC.COD_CARREGAMENTO_USF IS NULL);
    BEGIN
    FOR R_CONT IN C_CONT LOOP
    UPDATE F_CONTAGENS
    SET NUM_PNV_2_ANOS =
    (SELECT SUM(PNV)
    FROM (SELECT DECODE(F_PNV(COD_UTENTE,R_CONT.COD_USF,R_CONT.COD_MES,SUBSTR(R_CONT.COD_MES,1,4)), 'N', 0, 1) AS PNV
    FROM (SELECT DISTINCT COD_UTENTE
    FROM D_UTENTE
    WHERE DATA_NASC >= ADD_MONTHS(R_CONT.COD_MES||'01', -24)
    AND DATA_NASC <= ADD_MONTHS(last_day(R_CONT.COD_MES||'01'), -24)
    AND MES_UTENTE = R_CONT.COD_MES
    AND COD_USF = R_CONT.COD_USF))
    WHERE COD_USF = R_CONT.COD_USF
    AND COD_MES = R_CONT.COD_MES;
    COMMIT;
    END LOOP;
    RETURN 1;
    EXCEPTION
    WHEN OTHERS THEN
    NULL; -- enter any exception code here
    RETURN NULL;
    END;
    Is the OWB not synchronized with the DB? Does any of you alredy experienced this situation?
    Thank you very much for your attention,
    Pedro.

    HI Pedro,
    if your function returns null then some exception has occured.
    Do not catch the exception in your function, then you will see it when you run the mapping.
    Maybe you run the mapping using a different db user than when running it directly? In that case some grants will help.
    The exception will tell you the reason.
    Regards,
    Carsten.

  • Export external links and store them through the package function

    Is possibile to export external links (like www.xxxxxxxxx.com) like images, fonts, source files in general trough package function.
    Or are there other ways to do it? We need to collect all links that we inserted in our application.
    Many thanks!
    MC

    Hello,
    welcome to the forum.
    This is the forum for the tool {forum:id=260}
    Your question would be better asked in {forum:id=75}
    Export to flat file
    http://tkyte.blogspot.de/2009/10/httpasktomoraclecomtkyteflat.html
    Export to formatted output
    {message:id=9360007}
    Regards
    Marcus

  • DBMS_JOB using Packaged Functions but Package goes invalid

    Is there any way to check a package while running a PL/SQL procedure to see if it's state is valid and then catch the exception?
    In my case usually just calling any function in the package 1x clears it up but the procedure in question runs as a DBMS_JOB it just keeps failing. This procedure could run often enough that Oracle will mark it as broken but I want to give it every shot at execution on time instead of having to make it wait till the next cycle.
    What I would like to do is to catch the exception for the package state being invalid and basically have it go back to the beginning of the procedure and give it another try before failing in case it is just a failure because the package has been altered.
    Is there any way to do this?

    Firstly, I'll copy/paste my standard response regarding package state going invalid as it usually helps to have an understanding of these things...
    Packages tend to fail because of their "package state". A package has a "state" when it contains package level variables/constants etc. and the package is called. Upon first calling the package, the "state" is created in memory to hold the values of those variables etc. If an object that the package depends upon e.g. a table is altered in some way e.g. dropped and recreated, then because of the database dependencies, the package takes on an INVALID status. When you next make a call to the package, Oracle looks at the status and sees that it is invalid, then determines that the package has a "state". Because something has altered that the package depended upon, the state is taken as being out of date and is discarded, thus causing the "Package state has been discarded" error message.
    If a package does not have package level variables etc. i.e. the "state" then, taking the same example above, the package takes on an INVALID status, but when you next make a call to the package, Oracle sees it as Invalid, but knows that there is no "state" attached to it, and so is able to recompile the package automatically and then carry on execution without causing any error messages. The only exception here is if the thing that the package was dependant on has changes in such a way that the package cannot compile, in which case you'll get an Invalid package type of error.
    And if you want to know how to prevent discarded package states....
    Move all constants and variables into a stand-alone package spec and reference those from your initial package. Thus when the status of your original package is invlidated for whatever reason, it has no package state and can be recompiled automatically, however the package containing the vars/const will not become invalidated as it has no dependencies, so the state that is in memory for that package will remain and can continue to be used.
    As for having package level cursors, you'll need to make these local to the procedures/functions using them as you won't be able to reference cursors across packages like that (not sure about using REF CURSORS though.... there's one for me to investigate!)
    This first example shows the package state being invalided by the addition of a new column on the table, and causing it to give a "Package state discarded" error...
    SQL> set serveroutput on
    SQL>
    SQL> create table dependonme (x number)
      2  /
    Table created.
    SQL>
    SQL> insert into dependonme values (5)
      2  /
    1 row created.
    SQL>
    SQL> create or replace package mypkg is
      2    procedure myproc;
      3  end mypkg;
      4  /
    Package created.
    SQL>
    SQL> create or replace package body mypkg is
      2    v_statevar number := 5; -- this means my package has a state
      3
      4    procedure myproc is
      5      myval number;
      6    begin
      7      select x
      8      into myval
      9      from dependonme;
    10
    11      myval := myval * v_statevar;
    12      DBMS_OUTPUT.PUT_LINE('My Result is: '||myval);
    13    end;
    14  end mypkg;
    15  /
    Package body created.
    SQL>
    SQL> exec mypkg.myproc
    My Result is: 25
    PL/SQL procedure successfully completed.
    SQL>
    SQL> select object_name, object_type, status from user_objects where object_name = 'MYPKG'
      2  /
    OBJECT_NAME
    OBJECT_TYPE         STATUS
    MYPKG
    PACKAGE             VALID
    MYPKG
    PACKAGE BODY        VALID
    SQL>
    SQL>
    SQL> alter table dependonme add (y number)
      2  /
    Table altered.
    SQL>
    SQL> select object_name, object_type, status from user_objects where object_name = 'MYPKG'
      2  /
    OBJECT_NAME
    OBJECT_TYPE         STATUS
    MYPKG
    PACKAGE             VALID
    MYPKG
    PACKAGE BODY        INVALID
    SQL>
    SQL> exec mypkg.myproc
    BEGIN mypkg.myproc; END;
    ERROR at line 1:
    ORA-04068: existing state of packages has been discarded
    ORA-04061: existing state of package body "SCOTT.MYPKG" has been invalidated
    ORA-06508: PL/SQL: could not find program unit being called: "SCOTT.MYPKG"
    ORA-06512: at line 1
    SQL>
    SQL> select object_name, object_type, status from user_objects where object_name = 'MYPKG'
      2  /
    OBJECT_NAME
    OBJECT_TYPE         STATUS
    MYPKG
    PACKAGE             VALID
    MYPKG
    PACKAGE BODY        INVALID
    SQL>
    SQL> exec mypkg.myproc
    PL/SQL procedure successfully completed.
    SQL>
    SQL> select object_name, object_type, status from user_objects where object_name = 'MYPKG'
      2  /
    OBJECT_NAME
    OBJECT_TYPE         STATUS
    MYPKG
    PACKAGE             VALID
    MYPKG
    PACKAGE BODY        VALIDAnd this next example shows how having the package variables in their own package spec, allows the package to automatically recompile when it is called even though it became invalidated by the action of adding a column to the table.
    SQL> drop table dependonme
      2  /
    Table dropped.
    SQL>
    SQL> drop package mypkg
      2  /
    Package dropped.
    SQL>
    SQL> set serveroutput on
    SQL>
    SQL> create table dependonme (x number)
      2  /
    Table created.
    SQL>
    SQL> insert into dependonme values (5)
      2  /
    1 row created.
    SQL>
    SQL> create or replace package mypkg is
      2    procedure myproc;
      3  end mypkg;
      4  /
    Package created.
    SQL>
    SQL> create or replace package mypkg_state is
      2    v_statevar number := 5; -- package state in seperate package spec
      3  end mypkg_state;
      4  /
    Package created.
    SQL>
    SQL> create or replace package body mypkg is
      2    -- this package has no state area
      3
      4    procedure myproc is
      5      myval number;
      6    begin
      7      select x
      8      into myval
      9      from dependonme;
    10
    11      myval := myval * mypkg_state.v_statevar;  -- note: references the mypkg_state package
    12      DBMS_OUTPUT.PUT_LINE('My Result is: '||myval);
    13    end;
    14  end mypkg;
    15  /
    Package body created.
    SQL>
    SQL> exec mypkg.myproc
    My Result is: 25
    PL/SQL procedure successfully completed.
    SQL>
    SQL> select object_name, object_type, status from user_objects where object_name = 'MYPKG'
      2  /
    OBJECT_NAME
    OBJECT_TYPE         STATUS
    MYPKG
    PACKAGE             VALID
    MYPKG
    PACKAGE BODY        VALID
    SQL>
    SQL> alter table dependonme add (y number)
      2  /
    Table altered.
    SQL>
    SQL> select object_name, object_type, status from user_objects where object_name = 'MYPKG'
      2  /
    OBJECT_NAME
    OBJECT_TYPE         STATUS
    MYPKG
    PACKAGE             VALID
    MYPKG
    PACKAGE BODY        INVALID
    SQL>
    SQL> exec mypkg.myproc
    My Result is: 25
    PL/SQL procedure successfully completed.---------------------------------------------------------------------------------------------
    Secondly, from this above standard response, you can see how to check for package state if you want to determine it programatically.
    ;)

  • A query regarding synchronised functions, using shared object

    Hi all.
    I have this little query, regarding the functions that are synchronised, based on accessing the lock to the object, which is being used for synchronizing.
    Ok, I will clear myself with the following example :
    class First
    int a;
    static int b;
    public void func_one()
    synchronized((Integer) a)
    { // function logic
    } // End of func_one
    public void func_two()
    synchronized((Integer) b)
    { / function logic
    } // End of func_two
    public static void func_three()
    synchronized((Integer) a)
    { // function logic
    } // End of func_three, WHICH IS ACTUALLY NOT ALLOWED,
    // just written here for completeness.
    public static void func_four()
    synchronized((Integer) b)
    { / function logic
    } // End of func_four
    First obj1 = new First();
    First obj2 = new First();
    Note that the four functions are different on the following criteria :
    a) Whether the function is static or non-static.
    b) Whether the object on which synchronization is based is a static, or a non-static member of the class.
    Now, first my-thoughts; kindly correct me if I am wrong :
    a) In case 1, we have a non-static function, synchronized on a non-static object. Thus, effectively, there is no-synchronisation, since in case obj1 and obj2 happen to call the func_one at the same time, obj1 will obtain lock for obj1.a; and obj2 will obtain lock to obj2.a; and both can go inside the supposed-to-be-synchronized-function-but-actually-is-not merrily.
    Kindly correct me I am wrong anywhere in the above.
    b) In case 2, we have a non-static function, synchronized on a static object. Here, again if obj1, and obj2 happen to call the function at the same time, obj1 will try to obtain lock for obj1.a; while obj2 will try to obtain lock for obj2.a. However, since obj1.a and obj2.a are the same, thus we will indeed obtain sychronisation.
    Kindly correct me I am wrong anywhere in the above.
    c) In case 3, we have a static function , synchronized on a non-static object. However, Java does not allow functions of this type, so we may safely move forward.
    d) In case 4, we have a static function, synchronized on a static object.
    Here, again if obj1, and obj2 happen to call the function at the same time, obj1 will try to obtain lock for obj1.a; while obj2 will try to obtain lock for obj2.a. However, since obj1.a and obj2.a are the same, thus we will indeed obtain sychronisation. But we are only partly done for this case.
    First, Kindly correct me I am wrong anywhere in the above.
    Now, I have a query : what happens if the call is made in a classically static manner, i.e. using the statement "First.func_four;".
    Another query : so far we have been assuming that the only objects contending for the synchronized function are obj1, and obj2, in a single thread. Now, consider this, suppose we have the same reference obj1, in two threads, and the call "obj1.func_four;" happens to occur at the same time from each of these threads. Thus, we have obj1 rying to obtain lock for obj1.a; and again obj1 trying to obtain lock for obj1.a, which are the same locks. So, if obj1.a of the first thread obtains the lock, then it will enter the function no-doubt, but the call from the second thread will also succeed. Thus, effectively, our synchronisation is broken.
    Or am I being dumb ?
    Looking forward to replies..
    Ashutosh

    a) In case 1, we have a non-static function, synchronized on a non-static object. Thus, effectively, there is no-synchronisationThere is no synchronization between distinct First objects, but that's what you specified. Apart from the coding bug noted below, there would be synchronization between different threads using the same instance of First.
    b) In case 2, we have a non-static function, synchronized on a static object. Here, again if obj1, and obj2 happen to call the function at the same time, obj1 will try to obtain lock for obj1.a; while obj2 will try to obtain lock for obj2.a.obj1/2 don't call methods or try to obtain locks. The two different threads do that. And you mean First.b, not obj1.b and obj2.b, but see also below.
    d) In case 4, we have a static function, synchronized on a static object. Here, again if obj1, and obj2 happen to call the function at the same time, obj1 will try to obtain lock for obj1.a; while obj2 will try to obtain lock for obj2.a.Again, obj1/2 don't call methods or try to obtain locks. The two different threads do that. And again, you mean First.b. obj1.b and obj2.b are the same as First.b. Does that make it clearer?
    Now, I have a query : what happens if the call is made in a classically static manner, i.e. using the statement "First.func_four;".That's what happens in any case whether you write obj1.func_four(), obj2.func)four(), or First.func_four(). All these are identical when func_four(0 is static.
    Now, consider this, suppose we have the same reference obj1, in two threads, and the call "obj1.func_four;" happens to occur at the same time from each of these threads. Thus, we have obj1 rying to obtain lock for obj1.aNo we don't, we have a thread trying to obtain the lock on First.b.
    and again obj1 trying to obtain lock for obj1.aYou mean obj2 and First.b, but obj2 doesn't obtain the lock, the thread does.
    which are the same locks. So, if obj1.a of the first thread obtains the lock, then it will enter the function no-doubt, but the call from the second thread will also succeed.Of course it won't. Your reasoning here makes zero sense..Once First.b is locked it is locked. End of story.
    Thus, effectively, our synchronisation is broken.No it isn't. The second thread will wait on the same First.b object that the first thread has locked.
    However in any case you have a much bigger problem here. You're autoboxing your local 'int' variable to a possibly brand-new Integer object every call, so there may be no synchronization at all.
    You need:
    Object a = new Object();
    static Object b = new Object();

  • Calling Oracle Package Function from Visual Basic

    Hi,
    Oracle Client 8.04
    Oracle ODBC Driver 8.00.04
    VB 6.0
    Windows 2000
    I'm stumped here. I want to have a Oracle stored procedure run a
    query and return a result set which I can assign to a recordset
    object in VB. Based on things I've read here and on MS's site,
    here's what I've done:
    In the Oracle Schema Manager under the Packages folder I created
    the following package:
    PACKAGE test
    IS
    TYPE test_cur IS REF CURSOR;
    FUNCTION mycur RETURN test_cur;
    END test;
    and under the Package Body folder created:
    PACKAGE BODY test
    IS
    FUNCTION mycur RETURN test_cur
    IS
    c_return test_cur;
    BEGIN
    OPEN c_return FOR
    SELECT * FROM table_A;
    RETURN c_return;
    CLOSE c_return;
    END mycur;
    END test;
    They both compile without errors and in Oracle SQL Worksheet I
    can enter the following:
    variable x refcursor;
    execute :x :=test.mycur;
    print x;
    and the query results are displayed as expected.
    The problem is trying to get the result back into a VB recordset
    object.
    In VB 6.0 I have done this:
    Dim RS As ADODB.Recordset
    Dim Conn As ADODB.Connection
    Dim sConnection As String
    Dim sSQL As String
    sSQL = "{call test.mycur}"
    sConnection = "Provider=MSDASQL;UID=" & sUserID & ";PWD=" &
    sPassword & ";Driver={Microsoft ODBC for Oracle}; Server=" &
    sInstance & ";"
    Conn.Open sConnection
    RS.CursorLocation = adUseClient
    RS.Open sSQL, Conn, adOpenForwardOnly, adLockOptimistic,
    adCmdStoredProc ' or adCmdText
    but get:
    ?err.Number -2147217900
    ?err.Source Microsoft OLE DB Provider for ODBC Drivers
    ?err.Description [Microsoft][ODBC driver for Oracle]Syntax error
    or access violation
    The problem is not with the connection or permissions, since the
    query works fine when I just use the select statement in the
    package function as the string, instead of calling the function
    in the package (eg sSQL = "Select * from table_A") and can
    process the resulting recordset in VB.
    I've also tried variations using:
    Set RS = Conn.Execute("{call test.mycur}")
    or using a Command object something like:
    Dim com As ADODB.Command
    Set com = New ADODB.Command
    With Conn
    .ConnectionString = sConnection
    .CursorLocation = adUseClient
    .Open
    End With
    With com
    .ActiveConnection = Conn
    .CommandText = sSQL
    .CommandType = adCmdText
    End With
    Set RS.Source = com
    RS.Open
    But still get the same errors. Any help is appreciated. Also, in
    my package body, is it necessary to explicitly close the cursor,
    or does the function just exit when it executes the return and
    not ever hit the close statement?
    Thanks,
    Ed Holloman

    Hi
    i don't know if you got your answer, but i work with VB and
    Oracle.
    the procedure in the DB should have the cursor like you writen
    in your mail.
    to call a procedure in Oracle and get the data back
    into a recordset you shuld use a Command object like this:
    Dim conn As ADODB.Connection
    Dim cmd As ADODB.Command
    Dim rs As ADODB.Recordset
    Set conn = CreateObject("adodb.connection")
    Set cmd = CreateObject("adodb.command")
    Set rs = CreateObject("adodb.recordset")
    With conn
    .ConnectionString = ""
    .CursorLocation = adUseClient
    .Open
    End With
    'THE IMPORTENT SECTION IS THIS WHERE YOU SET THE COMMAND TO THE
    STORE PROCEDURE TYPE
    With cmd
    .ActiveConnection = conn
    .CommandText = "proc.fun"
    .CommandType = adCmdStoredProc
    End With
    'Then you set the rs to the command
    Set rs = cmd.Execute
    Set conn = Nothing
    Set rs = Nothing
    Set cmd = Nothing

  • 2.1.0.62: Problem with Package.Functions and Unit Tests

    I like the new Sqldeveloper - I startet trying Unit Tests as described here: Link: [http://www.oracle.com/technology/obe/11gr2_db_prod/appdev/sqldev/sqldev_unit_test/sqldev_unit_test.htm#t4]
    It worked with a test-procedure. Now i am trying to test my package functions, but all i get is this:
    Die folgende Prozedur wurde ausgeführt.
    Ausführungsaufruf
    BEGIN
    :1 := "PKG_MYPACK"."CREATEFUNCTION"(IN_PROGRAMMEID=>:2,
    IN_AMOUNT=>:3,
    IN_SWS=>:4);
    END;
    Bind-Variablen verwendet
    1 INTEGER OUT (null)
    2 INTEGER IN 1
    3 INTEGER IN 10
    4 INTEGER IN 11
    Ausführungsergebnisse
    ERROR
    Ungültige Konvertierung angefordert
    oracle.jdbc.driver.SQLStateMapping.newSQLException(SQLStateMapping.java:70)
    oracle.jdbc.driver.DatabaseError.newSQLException(DatabaseError.java:110)
    oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:171)
    oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:227)
    oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:439)
    oracle.jdbc.driver.OraclePreparedStatement.setObjectCritical(OraclePreparedStatement.java:7723)
    oracle.jdbc.driver.OraclePreparedStatement.setObjectInternal(OraclePreparedStatement.java:7496)
    oracle.jdbc.driver.OraclePreparedStatement.setObjectInternal(OraclePreparedStatement.java:7978)
    oracle.jdbc.driver.OracleCallableStatement.setObject(OracleCallableStatement.java:4063)
    oracle.jdbc.driver.OraclePreparedStatementWrapper.setObject(OraclePreparedStatementWrapper.java:221)
    oracle.dbtools.raptor.datatypes.strategies.callablestatement.CallableBindingDatum.customBindIN(CallableBindingDatum.java:135)
    oracle. ...
    what can i do?

    Created
    Bug 8976245 - EA1: UNIT_TEST: INVALID CONVERSION ERROR USING INTEGER PARAMETER
    and have asked bug responder to keep you updated on status here in the forum.
    Bad news is that any INTEGER parameter for which you specify a non-null value will fail.
    Possibly helpful news is that if you create a 'clone' of you function using NUMBER as the data type, you can continue to experiment with how unit testing may be of use to you.
    Sorry no instant answer. :(
    Brian
    SQL Developer Team

  • Using packaged functions in Apex

    Hi,
    I'm fairly new to apex and I am about to write an app which needs to access a SQL server database. My local dba has set up the transparent gateway and I can select from and update the SQLServer database no problem via a db link. What I need to decide is whether to code the sql for reports etc directly into the apex page or to call a pl/sql function returning a select statement. I would like to have all the code in packages as a lot of it will be used by multiple apps in future but is there any extra overhead in doing this:
    declare
    l_sql varchar2(4000);
    begin
    select package.function into l_sql from dual;
    return l_sql;
    end;
    rather than coding the SQL directly in the page? Also is there a more efficient way of using packaged functions to select data rather that just have it returning sql statements.
    Thanks in advance.
    Dave

    Hi
    I only use function returning select when I have a strong reason to do so, because it is so much more difficult to test and maintain. Not sure about performance, but I think it is not that much worse.
    If you simply want to reuse SELECT statements, you could use views instead.
    Anyway, if you decide to use the package solution, at least you can make it much simpler -- just code like this in the page:
    return package.function;
    I hope this helps.
    Luis

  • How to use type, packages, functions, and procedures in another schema ?

    I have two target schema in one OWB project, such as A and B. In a mapping of A, I would like to use some types, packages, functions, and procedures from B. I have tried the method of synonym as suggested, but I could not find the metadata of these when importing ... The only type of synonym I can import is the synonym for table. Is there a bug for synonym?
    If I cannot use synonym for this issue, is there another way to solve the problem?

    Now, in some instances you will absolutely need to create the second module as Carsten describes, however it should also be noted that you can reference objects in things like Expressions even if you have not loaded up the metadata. It is only when you need strong binding that it becomes neccessary to import objects. For everything else, as long as the reference will resolve at compile-time then you are good to go.
    For example, I have a function in one target schema (S1) and a private synonym to it in another(s2). A mapping in the S2 schema has an expression object that uses the synonym to the function in the expression property for a couple of the output attirbutes. The synonym has not been loaded into metadata - indeed OWB has no knowledge of its existance. But it resolves at compile time so the mapping validates and generates successfully.
    Mike

  • How to debug a Package / function in PL SQL developer ??

    How can we debug a Package / function in PL SQL developer ??
    i want to debug a code line by line

    Karthick_Arp wrote:
    This question does not belong to this fourm. We have a {forum:id=260} forum for such question.Not even there Karthick. PL/SQL Developer is a 3rd party tool, not Oracle's SQL Developer, so it doesn't even belong on the Oracle forums.

  • Using a packaged function in a query

    Hi ,
    I have read the following statement (correct option for the question)in 1z0-147 questions.
    The question is :: WHEN USING A PACKAGED FUNCTION IN A QUERY which of the following is true ::
    The packaged function cannot execute DML statements against the table that is being queriedI tried the following to understand the above statement
    create or replace package test_pk is
    function fn_test(i number) return number ;
    end;
    create or replace package body test_pk is
    function fn_test (i number) return number is
      j number:=1;
    begin
        insert into a values(200,300);
        commit;
       return j;
       end;
    end test_pk;  Upon executing the above function in the select statement
    select TEST_PK.FN_TEST(1) from dualI got the error saying that Can't perform DML Inside SElect
    Is this example for the above statement is TRUE ????
    Could you please explain me if my example is wrong
    Thanks
    Edited by: Smile on Nov 22, 2012 9:47 AM

    No, it is not true. Any function used in SQL is not allowed to perform a DML operation other than SELECT regardless if it is against the table that is being queried or not. Select is allowed against any table. And function in your example does INSERT which is not allowed. Also, Any function used in SQL is not allowed to perform commit/rollback/savepoint.
    SY.
    Edit: unless function is autonomous transaction.
    Edited by: Solomon Yakobson on Nov 22, 2012 10:22 AM

  • JPublisher generated wrapper package function name contains "ORIG_PKG"$FN

    jPublisher generated wrapper package function name contains "ORIG_PKG"$FN
    which shows compilation error as
    Compilation errors for PACKAGE BODY <schema>.JPUB_PLSQL_WRAPPER
    Error: PLS-00181: unsupported preprocessor directive '$FN'
    Line: 2699
    Text: FUNCTION "ORIG_PKG"$FN (P_SOURCE VARCHAR2,
    Along with this, the generated .sqlj file have a calling sqlj content having the same format as
    #sql [getConnectionContext()] __jPt_result = { VALUES(JPUB_PLSQL_WRAPPER."ORIG_PKG"$FN( ...
    This also show sqlj compilation error such as
    Error(91,5): Expected "$FN" and found ")" instead.
    and a warning
    Warning(91,5): Invalid SQL syntax at:
    JPUB_PLSQL_WRAPPER."ORIG_PKG"$FN(
    ^^^^
    Encountered "$FN" :
    Was expecting one of:
    <EOF>
    "AND" ...
    "BETWEEN" ...
    "IN" ...
    "IS" ...
    "LIKE" ...
    "NOT" ...
    "OR" ...
    "ROW" ...
    "AT" ...
    "MOD" ...
    "RANGE" ...
    <CONCAT_OP_> ...
    Any suggestion would be helpful. thank you.

    Just to put a proper closure to this thread, there were 2 issues with the Jdev version I was using (11.1.2.0.0)
    1) Wrapper for PL/SQL not getting generated properly.
    2) Webservice proxies are not getting generated properly.
    The 2 issues were taken care by generating the wrapper and proxy on a much higher version of Jdev.

  • Pass more parameter to the packaged function with REMAP_DATA in EXPDP

    1) can we pass more than one parameter to the packaged function specified in REMAP_DATA during DATA pump export?
    2) if yes to point#1 then, how can we pass rownum & some other columns value in the same record passed into the function?

    when all else fails, Read The Fine Manual
    http://download.oracle.com/docs/cd/E11882_01/server.112/e16536/dp_export.htm#sthref115

  • ORA-00904 and packaged function in report

    Oracle 9.2.0.7
    APEX 2.0
    Is APEX not able to deal with SQL that calls a packaged function?
    I ask because I'm able to execute this query:
    SELECT s.doc_id,
    s.last_name || ', ' || s.first_name full_name,
    s.p_id,
    s.create_date
    , rwa_wfrole.get_role_list(s.proj_id, s.p_id) wfrole_label
    FROM signatures_vw s
    WHERE s.proj_id = 182
    AND s.status = 'APPROVED'
    ORDER BY s.create_date, s.last_name, s.first_name
    in SQL*Plus, but not in the SQL Workshop or in a report region. In the latter case I get "ORA-00904 invalid identifier" for "rwa_wfrole.get_role_list"... which is a packaged function. Actually, to be more precise, it's a package in a remote database. In the APEX instance, I have a synonym pointing to it.
    Thanks for insight.
    -John

    I can't reproduce this in 10g. I did find bug 4177810 (Fixed in 9.2.0.8 Server Patch Set) that looks a bit like this problem.
      Description
        An unexpected ORA-904 can occur for some internally generated SQL
        when the select list contains non-column constants and the select
        appears in the FROM clause. This can occur for SQL produced for
        parallel query or for remote / distributed queries.
        Workaround:
          Rewrite the query to avoid constant expressions in the FROM clause select lists.***************************
    There are also recommendations dating way back that you should include the schema name in the Create Synonym statement.
    Scott

Maybe you are looking for

  • HP Laserjet pRO 200 COLOR MFP m276

    Suddenly while scanning one page at a time, appears this message: A scanner Automatic Document Feeder (ADF) misfeed ocurred. Reload the pages to scan into the ADF and try again. I do not know what is an ADF, I do not use an ADF, I just want to scan p

  • Oracle 11g OCA certification

    I am newbie .I would like to know a good book for Oracle 11g OCA certification ,1Z0-051 and 1Z0-052(with lesser number of mistakes).Appreciate a response.

  • Lite vs. Personal edition, help please

    Hi, I'm trying to get more experience with Oracle. I plan to take some cert. courses next month in Dallas in Oracle. I thought I would 'bone-up' a little. I registered for the Oracle Lite, but someone told me I should download the Oracle Personal Edi

  • I keep getting Norton 'performance alerts' that Firefox is using a lot of memory. Should I worry?

    Is there some action I should take because of thes alaerts? It happens every time I start Firefox

  • Buggy Flash Builder?

    2 strange things just happened in my code. 1.  i have a vector object called myVector.  i want to remove all object in the vector so i write myVector.splice(0).  it claimes there is an error becasue the function splice (apparently) requires 2 paramet