Java - functions and PL/SQL procedures?

It is my understanding that Java can call stored PL/SQL and PL/SQL procedures and functions can call Java stored procedures and functions.

The reason why I ask this is that my company is considering options on how to migrate our product. Our consultant said that PL/SQL cannot access Java procedures. I think they can. I am not well educated in the present, but I'm trying to learn as much as I can before we committed.

Our graphical interface is written in Java, but they are still debating the back-end (lots of great transaction). Some think that it should be written in Java, some Java State itself would be too slow. I read the mantra of AskTom - SQL, PL/SQL, Java, and C.

So, what's the scoop?

What is the preference, or best practices?

>
It's the answer that confused me: PL/SQL cannot access Java procedures in an external JAVA virtual machine, but Oracle has its own JAVA virtual machine integrated in the database (except express edition).
>
Since I wrote it I'll try to explain it.

Oracle, with the exception of the express edition, has a functionality integrated into the database (including the JVM) Java. You can import the java classes and jar files in the Oracle database and run Java code using the JAVA virtual machine, which is part of the Oracle.

By "External JVM", I hear one application that is launched from the OS and Java Virtual Machine and it is a stand-alone process; in other words, not a part of the Oracle or Oracle of FMV at all.

Both JVMs running in the 'sandbox' different and do not have access to each other code, classes, or process. Of course, they may be able to communicate using sockets, JNDI, EJBs and other features of wrapper, but they cannot access each other classes, instances of class or methods as they would if only there wasn't one JAVA virtual machine.

So a stand-alone Java application can call stored procedures in Oracle (even those written in Java), Oracle PL/SQL procedures can call Java from Oracle procedures, Oracle Java procedures can call Oracle PL/SQL procedures. But procedures Oracle PL/SQL or Java can't call procedures or access to Classes or class instances that are part of an external JAVA virtual machine.

Tags: Database

Similar Questions

  • Passage of tables through multiple functions and PL/SQL procedures

    I am now a great application of PL/SQL. There is a main procedure which is initially called who subsequently passes information to other PL/SQL functions and procedures. Ultimately an error code and the string is passed to PUT_LINE so it can be displayed. I want to be able to do is to have a table that stores an error code and a string for every error it then go through each of the procedures and functions. This would mean passing these codes and the strings of a function to a function within the pl/sql application. What would be the best way to implement this and is it possible to move heavy or folders to other PL/SQL functions? Thank you.

    Here is a simulation->

    satyaki>
    satyaki>select * from v$version;
    
    BANNER
    ----------------------------------------------------------------
    Oracle Database 10g Enterprise Edition Release 10.2.0.3.0 - Prod
    PL/SQL Release 10.2.0.3.0 - Production
    CORE    10.2.0.3.0      Production
    TNS for 32-bit Windows: Version 10.2.0.3.0 - Production
    NLSRTL Version 10.2.0.3.0 - Production
    
    Elapsed: 00:00:00.20
    satyaki>
    satyaki>
    satyaki>create or replace type n_array is table of number;
      2  /
    
    Type created.
    
    Elapsed: 00:00:07.10
    satyaki>
    satyaki>CREATE OR REPLACE PROCEDURE Get_Array(array_in IN n_array,
      2                                        array_out OUT n_array)
      3  IS
      4  BEGIN
      5    array_out := n_array();
      6    FOR i IN 1..array_in.count
      7    LOOP
      8      array_out.extend;
      9      array_out(i) := array_in(i) * 2;
     10    END LOOP;
     11  END Get_Array;
     12  /
    
    Procedure created.
    
    Elapsed: 00:00:00.89
    satyaki>
    satyaki>
    satyaki>Create or Replace Procedure Set_Array(myArray IN n_array)
      2  is
      3    i   number(10);
      4    rec emp%rowtype;
      5    w n_array:=n_array(1200,3200);
      6    bucket n_array := n_array();
      7  Begin
      8    Get_Array(w,bucket);
      9
     10    for i in 1..myArray.count
     11    loop
     12      select *
     13      into rec
     14      from emp
     15      where empno = myArray(i);
     16      dbms_output.put_line('Employee No:'||rec.empno||' Name:'||rec.ename);
     17      for j in 1..bucket.count
     18      loop
     19        dbms_output.put_line('Commission Sub Type: '||bucket(j));
     20      end loop;
     21    end loop;
     22  End Set_Array;
     23  /
    
    Procedure created.
    
    Elapsed: 00:00:01.33
    satyaki>
    satyaki>
    satyaki>select * from emp;
    
         EMPNO ENAME      JOB              MGR HIREDATE         SAL       COMM     DEPTNO
    ---------- ---------- --------- ---------- --------- ---------- ---------- ----------
          9999 SATYAKI    SLS             7698 02-NOV-08      55000       3455         10
          7777 SOURAV     SLS                  14-SEP-08      45000       3400         10
          7521 WARD       SALESMAN        7698 22-FEB-81       1250        500         30
          7566 JONES      MANAGER         7839 02-APR-81       2975                    20
          7654 MARTIN     SALESMAN        7698 28-SEP-81       1250       1400         30
          7698 BLAKE      MANAGER         7839 01-MAY-81       2850                    30
          7782 CLARK      MANAGER         7839 09-JUN-81       4450                    10
          7788 SCOTT      ANALYST         7566 19-APR-87       3000                    20
          7839 KING       PRESIDENT            17-NOV-81       7000                    10
          7844 TURNER     SALESMAN        7698 08-SEP-81       1500          0         30
          7876 ADAMS      CLERK           7788 23-MAY-87       1100                    20
    
         EMPNO ENAME      JOB              MGR HIREDATE         SAL       COMM     DEPTNO
    ---------- ---------- --------- ---------- --------- ---------- ---------- ----------
          7900 JAMES      CLERK           7698 03-DEC-81        950                    30
          7902 FORD       ANALYST         7566 03-DEC-81       3000                    20
    
    13 rows selected.
    
    Elapsed: 00:00:00.28
    satyaki>
    satyaki>declare
      2    v n_array:=n_array(9999,7777);
      3  begin
      4    Set_Array(v);
      5  end;
      6  /
    Employee No:9999 Name:SATYAKI
    Commission Sub Type: 2400
    Commission Sub Type: 6400
    Employee No:7777 Name:SOURAV
    Commission Sub Type: 2400
    Commission Sub Type: 6400
    
    PL/SQL procedure successfully completed.
    
    Elapsed: 00:00:00.15
    satyaki>
    satyaki>
    

    Kind regards.

    LOULOU.

  • Difference between function and stored procedure

    Hi guys, I don't understand the exact difference between a function and a stored procedure. I have a lot of google but still. Can someone explain in simple terms. Thank you.

    Hello

    Here is an example of a user-defined function:

    CREATE OR REPLACE FUNCTION     factorial
    (      in_num       IN     PLS_INTEGER
    )
    RETURN     PLS_INTEGER
    DETERMINISTIC
    IS
    BEGIN
         IF  in_num IS NULL
         THEN
              RETURN     NULL;
         ELSIF in_num <= 1
         THEN
              RETURN  1;
         ELSE
              RETURN  in_num * factorial (in_num - 1);
         END IF;
    END     factorial;
    /
    SHOW ERRORS
    

    This function returns an integer. You can use the function (or, more exactly, the integer returned) everywhere where a whole expression is allowed.
    For example

    SELECT     ROWNUM
    ,     factorial (ROWNUM)     AS f
    ,     loc
    ,     SUBSTR ( loc
                , 1
                , factorial (ROWNUM)
                )          AS s
    FROM     scott.dept;
    

    Output:

    `   ROWNUM          F LOC           S
    ---------- ---------- ------------- -------------
             1          1 NEW YORK      N
             2          2 DALLAS        DA
             3          6 CHICAGO       CHICAG
             4         24 BOSTON        BOSTON
    
  • PL - SQL procedures and functions

    Hi all

    When playing on the PL - SQL procedures, I came across a concept, which says that we cannot include bind or host variables in procedures because the compiler cannot resolve the reference to bind the variable.

    Can someone please explain more carefully.

    Thank you.

    983037 wrote:

    When playing on the PL - SQL procedures, I came across a concept, which says that we cannot include bind or host variables in procedures because the compiler cannot resolve the reference to bind the variable.

    Fix. This code cannot compile the way he needs to a connection variable to respect:

    create or replace function GetEmpName return varchar2 is
      empName emp.ename%Type;
    begin
      select
        e.ename into empName
      from emp
      where emp_no = :BIND_VARIABLE;
      return( empName );
    end;
    

    Stored code cannot include bind variables as what compiler Oracle to know the data type of +: BIND_VARIABLE + - or run the service running when the code is already compiled, but it lacks a bind call to provide a value for +: BIND_VARIABLE +?

    If the code should look like the following instead:

    create or replace function GetEmpName( empID number ) return varchar2 is
      empName emp.ename%Type;
    begin
      select
        e.ename into empName
      from emp
      where emp_no = empID;
      return( empName );
    end;
    

    The variable from PL/SQL empID is treated (transparent) as a variable binding when the SQL SELECT in this function is parsed and executed as a SQL cursor.

    You as a visitor, however need to provide variable bind when you call this function from an external client (such as SQL * Plus, Java, C/C++, etc.). For example

    --// using sqlplus as example - create 2 sqlplus host variables
    var name varchar2(100)
    var id number
    
    --// assign a value to a host variable
    exec :id := 12345;
    
    --// execute the stored function code binding host variables as bind variables
    begin
      :name := GetEmpName( :id );
    end;
    /
    
    --// display host variable
    print name
    
  • How to move the functions and procedures of packages in a schema?

    Hello

    I have less than the needs for a work at home and my question is if anyone can point me in the right direction to find documentation that can help me solve below. Any information will be appreciated. Thank you.

    Write procedures and functions (included or not in packets) as .txt or .sql scripts. Once they have been launched in Developer SQL they should, in addition, the functions and procedures of packages in the current schema. If the current schema contains only 2 packages, pac1 (p11, p12 procedures and functions f11, f12, f13) and pac2 (contains the p21 following procedures, p22, p23 and f21 and functions f21 (case of overload), running the scripts produce the following effects:)

    • Procedures p11, p12, p21, p22, p23, and f11, f12 and f13 functions will be created in the current schema.
    • PAC2 will contain 2 instances of the function of overload-f21; they will be kept in the package, without be created in the current schema. If all overloaded procedures/functions will be kept in their original packaging
    • If pac1 contains variables, cursors, and public types, keep us only the details of the package (and remove the body); usually if the packages contain no overloaded functions or procedures the body will be removed and if no variable, cursors, types of public then we will remove the header.
    • If in the triggers, procedures and functions we will call procedures/functions packages (procedures and functions moved into the current schema) they reference will need to be updated (via editing the body or recompilation) for example if pa1.p12 will be replaced with p12.
    • Scripts must have numbers in the next series (01... n) and the characters that explain the content.

    My only advice would be to remember that these are public forums and if YOU can find them, therefore cannot your instructors.

    In addition, those are horrible procedure names and function

    This mission seems to be around to overload the pl/sql objects and... prioritize a research on Oracle documentation around overhead and legacy
    http://docs.Oracle.com/CD/B28359_01/AppDev.111/b28371/adobjplsql.htm#i21148

  • Same algorithm in function and procedure so that one will be better?

    Why is better to pl sql function calculates a value instead of the procedure?
    If I apply the same algorithm in function and procedure while one will perform better?

    Siddharth Singh says:
    Oracle documentation

    http://docs.Oracle.com/CD/B10500_01/AppDev.920/a96624/08_subs.htm

    This:

    Generally, you use a procedure to perform an action and a function to calculate a value.

    Does not mean that the function are better to calculate a value, but you usually use functions to calculate a value.

    Usually, a function is can be more useful if you plan to use in a query.
    that is to say:

    SELECT myfunc(col1) from mytable;
    

    That you can't do with a procedure. Functions are also usually limited to the returning a single value, while procedures may have several OUTPUT parameters.

    Kind regards.
    Al

    Published by: Alberto Faenza on 21 November 2012 15:31

  • Send String [] [] type of pl/sql function in App.module procedure

    Hello
    I use jdveloper 11.1.1.3.0

    I have a pl/sql procedure. entry type argument is array (TAR) 2 Dimensions:

    types:
    create or replace TYPE ARRAYWEB in the varray (160) of VARCHAR2 (200);
    create or replace TYPE TAR as the ARRAYWEB table;

    Procedure:
    PROCEDURE of translations (info in TAR)

    I want to send the String [] [] type to this procedure from a function in the Application module:

    1: string [] [] str;

    2: CallableStatement plsqlBlock = null;

    3: string declaration = "BEGIN testi(:1); END; « ;

    4: plsqlBlock is getDBTransaction () .createCallableStatement (statement, 0);.

    5: plsqlBlock.setArray (1, str); Get the error

    6: plsqlBlock.executeUpdate ();

    but in line 5 I do not know what type should I use and this type (Array) does not work

    Habib

    Maybe this can help: http://www.devx.com/tips/Tip/22034

    Dario

  • Doubts in functions and procedures

    Hello world

    Can someone tell the exact differences between function and procedure?

    My doubts are
    1. If the procedure can return and is not necessary it must return a value (in other words, if we want to come back and is not as one can write procedure) then why do we need to function?

    2. I tried to call a function that updates a table in the code, I got an error saying that the function does not use DML.

    3. I want to know the combination that
    procedure a. can call a function and vice versa?
    b. function (which uses DML instructions) can be called from sql statement?
    and if all other combinations are there let me know with reasons.

    Thanks in advance,
    Vinay

    Have you looked at in the [reference Guide and the User Guide for PL/SQL | http://download.oracle.com/docs/cd/B19306_01/appdev.102/b14261/toc.htm] already?
    http://download.Oracle.com/docs/CD/B19306_01/AppDev.102/b14261/subprograms.htm#i4075
    http://download.Oracle.com/docs/CD/B19306_01/AppDev.102/b14261/subprograms.htm#i4074

    (1) for example: functions can be used in SQL, procedures cannot.
    (2) generally, the methods are used for DML.
    It depends on how you are performing the function:

    hoek&XE> create table t as select 1 col from dual;
    
    Tabel is aangemaakt.
    
    hoek&XE> create or replace function f
      2   return number
      3   as
      4    num number;
      5   begin
      6    update t
      7    set col = 2;
      8    num := sql%rowcount;
      9   return(num);
     10  end;
     11  /
    
    Functie is aangemaakt.
    
    hoek&XE> select f from dual;
    select f from dual
           *
    FOUT in regel 1:
    .ORA-14551: cannot perform a DML operation inside a query
    ORA-06512: at "HOEK.F", line 6
    
    hoek&XE> 
    
    hoek&XE> var num number
    hoek&XE> exec :num := f;
    
    PL/SQL-procedure is geslaagd.
    
    hoek&XE> print :num
    
           NUM
    ----------
             1
    
    hoek&XE> select * from t;
    
           COL
    ----------
             2
    

    Yes 3A)
    No. 3B), see 2.

  • Problem inserting new line in a VO with SQL functions and subqueries

    Hello

    I use JDeveloper 10.1.3.4 and and stuck with insertion of a new line when the values to insert into some fields of the new line are returns of SQL functions and subqueries.

    At the sqlplus prompt, the following sql statement is tested and developed successfully:
    insert into VALIDATIONS values (
       '111223333', 'JANE', 'DOE',
       SYSDATE,
       (select to_char(sysdate, 'yymmdd') from dual)||
       (select to_char(count(TRANSACTION_DATE)+1,'fm0999') from VALIDATIONS
          where trunc(TRANSACTION_DATE) = to_char(sysdate))
    );
    Note that the values for the fields of 4th and 5th are returns of subqueries and SQL functions.

    Ideally, it would be simple to assemble a SQL and executed him as he did to the old way of servlet:
    String sql = "insert into VALIDATIONS values ('" + id + "', '" + firstName + "', '" + lastName + "', SYSDATE, (select to_char( ......)))";
    statement.executeUpdate(sql);
    I'm not sure it can be done in JDeveloper, and it was not found in the developer's guide. What I found was rather:
    // 1. Find the ServiceRequests view object instance.
    ViewObject svcReqs = am.findViewObject("ServiceRequests");
    // 2. Create a new row and insert it into the row set
    Row newSvcReq = svcReqs.createRow();
    svcReqs.insertRow(newSvcReq);
    // 3. Show effect of entity object defaulting for Status attribute
    System.out.println("Status defaults to: "+newSvcReq.getAttribute("Status"));
    // 4. Set values for some of the required attributes
    newSvcReq.setAttribute("CreatedBy",308); // Nancy Greenberg (user)
    Date now = new Date(new Timestamp(System.currentTimeMillis()));
    newSvcReq.setAttribute("RequestDate",now);
    newSvcReq.setAttribute("ProdId",119); // Ice Maker
    newSvcReq.setAttribute("ProblemDescription","Cubes melt immediately");
    // 5. Commit the transaction
    am.getTransaction().commit();
    In my case, it would be OK for the first three fields as shown below (in the code of transactionsRecords is a display object). But what about the 4th and 5th fields?
    Row newTransaction = transactionsRecords.createRow();
    transactionsRecords.insertRow(newTransaction);
    newTransaction.setAttribute("StudentId", id);
    newTransaction.setAttribute("FirstName", firstName);
    newTransaction.setAttribute("LastName", lastName);
    
    newTransaction.setAttribute("TransactionDate", <how to put "SYSDATE" here?>);
    newTransaction.setAttribute("ConfirmNumber", <how to put subqueries here?>);
    A big thank you to those who know or have experience before!


    Newman

    Newman,
    You can do this via a procedure call. This technique is described here
    I guess you can't do this directly in the EO or VO.
    You can do it the old way to create a prepared directly query and call it as you described. To get the declaration use getDBTransaction () .createPreparedStatement (...) method available in the module of your application.
    Be aware of the implications using the given solution. The framework doesn't know anything of what you are doing. So to see the changes that you used to update the tables that you change.

    Timo

  • Manipulation of PL/SQL, an overload of functions and NULL

    Hello

    I am trying to write a package of assistance with the same name of function that takes a different type of settings (VARCHAR2 or NUMBER or DATE) and processing them. Please check the example below.

    create or replace package is MY_PACKAGE
    performOperation (var1 VARCHAR2) return feature NUMBER;
    performOperation (var1 NUMBER) function return NUMBER;
    performOperation (var1 DATE) function return NUMBER;
    end MY_PACKAGE;

    This package works well until I pass a VARCHAR2 or NUMBER or DATE values. If I pass NULL, I get error PL-00307/ORA-06550. Check for null before adoption is not an option. Is there a better way to handle the NULL value inside this package.

    Thanks for your help on this.

    vbforums wrote:
    Thanks for the reply of Solomon.

    I prefer not to determine the type of data from the start, I'm too load methods. If it manages the NULL, I could use different names for all three data type

    There is no need, unless you use a PL/SQL NULL or NULL SQL function:

    SQL> create or replace package body MY_PACKAGE is
      2  function performOperation(var1 VARCHAR2) return NUMBER is begin return 1; end;
      3  function performOperation(var1 NUMBER) return NUMBER is begin return 2; end;
      4  function performOperation(var1 DATE) return NUMBER is begin return 3; end;
      5  end MY_PACKAGE;
      6  /
    
    Package body created.
    
    SQL> set serveroutput on
    SQL> declare
      2      v_num number;
      3      v_str varchar2(1);
      4      v_dt  date;
      5  begin
      6      dbms_output.put_line(my_package.performOperation(v_str));
      7      dbms_output.put_line(my_package.performOperation(v_num));
      8      dbms_output.put_line(my_package.performOperation(v_dt));
      9  end;
     10  /
    1
    2
    3
    
    PL/SQL procedure successfully completed.
    
    SQL> 
    

    However, if you use use the PL/SQL NULL or NULL SQL function, you must convert it into an appropriate type as NULL itself is without (the unknown value of an unknown type) type. When NULL is assigned to a variable or a column, it becomes an unknown variable value or a column of data type. This is why PL/SQL can understand an overload.

    SY.

  • all functions and procedures works this way? (dbms_lock)

    Hi guys,.

    throughout, I thought...

    Start
    dbms_output.put_line ('a');
    dbms_output.put_line ('b');
    end;

    When built, I thought of the oracle pl/sql interpreter read the source line by line
    the steps below

    -seen dbms_output.put_line ('a'), print a
    -seen dbms_output.put_line ('b'); ... print b

    That's all...

    but after using dbms_lock, I realize its abit differs from the way I thought...

    Start
    dbms_output.put_line ('a');
    DBMS_LOCK. Sleep (10);
    dbms_output.put_line ('b');
    end;
    /

    I'd actually wait for 10 seconds before I see the result 'a' and 'b '...
    so it seems to me

    the interpreter would be
    (1) see dbms_output.put_line ('a'); -It's going to print 'a' but which is still
    (2) see dbms_lock.sleep (10); -sleep for 10 sec...
    (3) see dmbS_output.put_line ('b') - you know it's going to print 'b', but which is still
    (4) see at the end; -ok print 'a' and 'b '.


    so, somehow, to return the result or printing... He seems to have done until the END of the block/procedure/function instead of intepreting line-by-line and runs it.
    However, for dbms_lock.sleep (10), its seems to be interpreted and executed immediately in the middle of the block.

    so can I conclude that
    for his return / displaying the result, it is done at the end of the block
    for others, it is done during the block

    Am I wrong?

    Best regards
    Noob

    The thought is always a good thing, but read the docs is also useful. PL/SQL unit is still running on the side of server database and always as a unit. written dbms_output.put_line('A') simply has to a buffer and PL/SQL unit continues to run. any unit buffer has all the lines written. Now the client tool, SQL * Plus, in your case, can read the contents of the buffer and display it. SQL * more is it based on the command SET SERVEROUTPUT on / off. I hope now you understand that DBMS_OUTPUT does not provide an interface to display the customer exit, but rather store it in a buffer.

    SY.

  • Oracle form functions and procedures in the APEX, how?

    I'm working to recreate in the APEX, already existing read only forms in Oracle Forms. Report features interactive APEX among other things, in fact worth as well as to target a different audience than utilizies versions of Oracle Form. Versions of Oracle Forms use a lot of pre and post query triggers, PLSQL functions.

    In Oracle Forms that places, these functions can be found in the "Units of program" section of the form. A feature typical of this kind, based on a particular Mission ID route, collecting names of regular passengers, is shaped with a comma and a space after each of them, in a single string that is returned and displayed the list of passengers of a line.

    I have all of this written code so I can move most of the main request of the Oracle form in an interactive report. These functions and triggers called in the form of the "Units of program" section of the Oracle form rather than stored in the database schema in a package, where they would go inside the APEX? Can I create a 'shortcut' in the APEX and call it from the interactive report "Source Région"? I can create the PLSQL function at the level of the region of the interactive report or page level? Or, my best bet creates a package that is stored in the database, all these functions and/or proecedures I might need the original form of Oracle?

    Some advice would be greatly appreciated.

    RLBickham wrote:
    I don't think I've been pretty clear in the description of the specific thing I want to do, simply, it does not reach the level of forms of conversion of the APEX. It is basically a problem of PLSQL function.

    I have an interactive report which is currently 90 percent of what I want however, each line, which represents a Mission may have several feet. Each arm has two places or ICAO codes attached to it. Based on the number of Mission, I want to loop through the array of leg, collect all the codes of ICAO for this Mission, put them together in 1 variable separated by a coma and add this variable to display the columns in this interactive report as the last column.

    In Oracle Forms, I have a function registered in the database, which is called in the main query. Maybe I ask a question that does not need to be asked, but anyway my question is can I put this function currently in the database somewhere within the interactive report and somehow reference it via Http, or should I just stick with set of functions and procedures in the packages stored in the database and called the conventional way?

    You could switch the function to the database and call it from the report query, but it sounds as if it were superfluous. In the report query using any form of Re: 4. How can I convert rows to columns? is appropriate for your version of the (unspecified) database.

    -----

    When you have a problem, you will get an answer faster, more efficient including information as much information as possible from the outset. This should include:

  • Full version of APEX
  • Complete operating system DB, version, edition, host
  • Architecture of Web server (EPG, SST or APEX listener/host operating system)
  • Browser (s) and version (s) used
  • Theme
  • Model (s)

  • Region/section type (s) (particularly as to distinguish if a 'report' is a standard report, an interactive report, or indeed a 'update report' (i.e. a tabular presentation))

    With APEX, we also had the chance to have a great resource in apex.oracle.com where we can reproduce and share problems. Reproduce things is the best way to solve most of the questions, particularly those relating to the layout and Visual formatting. If you expect a detailed response it is appropriate that you take on an important part of the effort by getting as much as possible with an example of the problem on apex.oracle.com before asking for help on specific issues, then we can see firsthand.

  • Any difference between the separate function and aggregation in sql query cost?

    Hello
    I've run many models sql stmts - such as:
    one) using a single table
    (b) using the two tables, using simple joins or outer joins

    but I didn't notice a difference in sql stmts in cost and implementation plan...
    In any case, my colleague insists on only using the aggregate function is less expensive compared to
    separate... (something I've not confirmed, that is why I believe that they are exactly the same...)

    For the situation described above under 1 sql... We could for example use
    select distinct deptno
    from emp
    select count(*), deptno
    from emp
    group by deptno
    select distinct owner, object_type from all_objects
    select count(*), owner, object_type from all_objects
    group by owner, object_type
    Have you ever found no difference between the two...?

    Note: I use Ora DB 10g v2.

    Thank you
    SIM

    Alexandre Gelin says:
    function separate and aggregation are for different uses and can give the same result, but if you use the aggregate function to get the separate records, it will be expensive...

    really? I find them almost identical to 11g. Actually GROUP BY is almost always more fast for me in the old days.

    article about this askTom Re: any difference between the separate function and aggregation in sql query cost?
    This applies mainly to the older oracle versions http://www.oracle.com/technology/products/rdb/pdf/distinct_derivedtables_groupby_sort_tech_article.pdf

  • I used the inverse function for a palindrome bulk pl/Sql program, but it is said to declare the inverse function and my code is below! Please suggest me some friends of ideas and thanks in advance

    declare

    i_var varchar2 (30): = '& enter_string';

    Vout varchar2 (20);

    Start

    :=Lower(Reverse(i_var)) Vout;

    If lower (i_var) = vout can

    dbms_output.put_line ('this is a palindrome');

    on the other

    dbms_output.put_line ('this is not a palindrome');

    end if;

    end;

    I agree completely

    SQL > declare

    2 i_var varchar2 (30): = "& enter_string;

    3 vout varchar2 (20);

    4 start

    5 Select lower (reverse (i_var))

    6 in vout

    7 double;

    8 lower (i_var) = vout

    9. can

    10 dbms_output.put_line (i_var |) 'is a palindrome');

    11 other

    12 dbms_output.put_line (i_var |) (' ' is not a palindrome ");

    13 end if;

    14 end;

    15.

    Enter the value of enter_string: Bolton

    2 old: i_var varchar2 (30): = "& enter_string;

    2 new: i_var varchar2 (30): = 'Bolton ';

    Bolton is not a palindrome

    PL/SQL procedure successfully completed.

  • How to use the pl/sql procedure

    Hi all,

    How to use pl/sql packages and especially in what situations we are pl/sql, which is the cause of the procedure. Please explain with precision using small example.

    Thanks and greetings

    RAM

    I could tell this at a very high level.

    PL/SQL's procedural extension to SQL. SQL (structured query language) has no procedural capacity. They are executed as a stand-alone statement. When you want to generate a process flow with several SQL statement that you need to have a procedural language that could accommodate your SQL. PL/SQL is something similar to Java and Dot Net in this aspect. Said that PL/SQL is Oracle DB. This has some advantages. The most important thing is that when you have your SQL in PL/SQL oracle maintains its reliance on the object. Any database oracle related so you want to build, then you can consider to PL/SQL as the best way to use process flows.

    PL/SQL provides various methods such as the PROCEDURE, FUNCTION and the PACKAGE. The only thing that race stands is in its ability to modularize your code. So, using the package you can create process workflows that is modular and easy to understand.

Maybe you are looking for