Function returns object

My question is-
1) what happens(physically on computer memory) when you create an object? do each object get its own memory in Heap and what is the life time of the object.
2) what happens when you return an object from a function?
My doubt:- I think when an object is returned it is returned along with the varibale(values) with it. so that other it can be saved to another variable.
3) How does a object get returned? Is object returned as an struct or string?(Physical structure).
Can I save it to any varibale(int,string, float).
Please help me out...............................thanks
_I have a class webuser_
public class WebUser
public String userName;
public String application;
public String getUserName()
{return userName;}
public void setUserName(String userName){     this.userName = userName;}
public String getApplication(){return application;}     
public void setApplication(String application){this.application = application;}
Another class* just returns this object
public WebUser getProfile(String userName, String application)
WebUser webUser = new WebUser();
webUser.setApplication(application);
webUser.setUserName(userName);           
return webUser;
In my coldfusion program I am saving the it  to a variable
<cfset sha=WebUser.getprofile("mother","Home")/>
How is it saved? Is ir returned as a struct or is it returned as a string.

shafiur wrote:
It means can you express it to me in lay terms
"Each object gets its own memory on the heap but only what's specific for each object gets stored."
Lets suppose a class has
Class A
public static void main(String args[])
int x=5;
String s="Muddu";
float y=1.505;
float z;
z=add(x,y);
public float add(int a, int b)
float m;
m=a+b;
return m;
in other class
class b
A a=new A();//What happens here(how is it get stored here. What does a have now. does it have its variables with it stored in heap.
class C
A b=new A();///Now what happens to this object. Is it different from the other one. If I change variable values here, does it effect my object a in the class b.
Sorry for this dummy questions. But I get confused by this.
}When you do
A a = new A(); it creates an A object, and assigns a reference to it to variable "a".
If you later do a = new A(); again, then you will create another A object, and put a reference to it into "a", which will then lose its reference to the first A object. That first object is then eligible for GC, if nothing else is referring to it.
Then, if you do A a2 = a; you are not creating or copying an object. You're just copying the reference from "a" to "a2", so both variables point to the same object.

Similar Messages

  • Function Returning Object

    Function Returning Object
    Hi Experts,
    Here is my code,
    -- DROP TYPE TYP_EMP;
    -- DROP TYPE TYP_EMP_OBJ;
    CREATE OR REPLACE TYPE TYP_EMP_OBJ AS OBJECT
        TOTAL       NUMBER,
        ROWINDEX    NUMBER,
        EMPNO       NUMBER,
        ENAME       VARCHAR2(50),
        LOC         VARCHAR2(100)
    CREATE OR REPLACE TYPE TYP_EMP AS TABLE OF TYP_EMP_OBJ;
    CREATE OR REPLACE FUNCTION FUN_GETEMP_LOCATION(pmDeptno IN NUMBER) RETURN VARCHAR2
    AS
        vLocation  DEPT.LOC%TYPE;
    BEGIN
        SELECT LOC INTO vLocation FROM DEPT WHERE DEPTNO=pmDeptno;
        RETURN vLocation;
    END;
    CREATE OR REPLACE FUNCTION FUN_GET_EMP_DETAILS
        pmType      IN NUMBER,
        pmStartPage IN NUMBER,
        pmEndPage   IN NUMBER,
        pmOrderBy   IN VARCHAR2
    RETURN TYP_EMP PIPELINED
    AS
        vString VARCHAR2(100);
        TYPE vRefCursor IS REF CURSOR;
        Cur  vRefCursor;  
        Rec  TYP_EMP_OBJ := TYP_EMP_OBJ(NULL,NULL,NULL,NULL,NULL);
    BEGIN
        IF pmType IS NULL THEN
            SELECT 0,NULL,NULL,NULL,NULL INTO Rec.TOTAL,Rec.ROWINDEX,Rec.EMPNO,Rec.ENAME,Rec.LOC FROM DUAL;
            RETURN;
        END IF;
        IF pmType =1 THEN
        OPEN Cur FOR
        'SELECT * FROM(
            SELECT
                COUNT(*) OVER(),
                ROW_NUMBER() OVER('||pmOrderBy||') ROW_INDEX,
                EMPNO,
                ENAME,
                FUN_GETEMP_LOCATION(EMP.DEPTNO) LOC
            FROM EMP)T
        WHERE T.ROW_INDEX BETWEEN '||pmStartPage||' AND '||pmEndPage;
        ELSE
        OPEN Cur FOR
        'SELECT * FROM(
            SELECT
                COUNT(*) OVER(),
                ROW_NUMBER() OVER('||pmOrderBy||') ROW_INDEX,
                2,
                ENAME,
                FUN_GETEMP_LOCATION(EMP.DEPTNO) LOC
            FROM EMP)T
        WHERE T.ROW_INDEX BETWEEN '||pmStartPage||' AND '||pmEndPage;
        END IF;   
    LOOP
        FETCH Cur INTO Rec.TOTAL,Rec.ROWINDEX,Rec.EMPNO,Rec.ENAME,Rec.LOC;
            EXIT WHEN Cur%NOTFOUND;
        PIPE ROW(Rec);
    END LOOP;
    CLOSE Cur;
    RETURN;
    END;
    SELECT * FROM TABLE(FUN_GET_EMP_DETAILS(NULL,1,10,'ORDER BY EMPNO DESC'));
    SELECT * FROM TABLE(FUN_GET_EMP_DETAILS(1,1,10,'ORDER BY EMPNO DESC'));
    SELECT * FROM TABLE(FUN_GET_EMP_DETAILS(2,1,10,'ORDER BY EMPNO DESC'));
    Executing First Query
    Actually Whats happening on Executing first Query, it does not return as specified
    SELECT 0,NULL,NULL,NULL,NULL INTO Rec.TOTAL,Rec.ROWINDEX,Rec.EMPNO,Rec.ENAME,Rec.LOC FROM DUAL;
    It just returning null;
    Executing Second Query
    It return correctly.
    Executing Third Query
    It return correctly.
    Can anyone suggest how to work out like this?
    Thanks,
    Dharan V

    You dint pipe the row if pmType is NULL
    CREATE OR REPLACE FUNCTION FUN_GET_EMP_DETAILS
        pmType      IN NUMBER,
        pmStartPage IN NUMBER,
        pmEndPage   IN NUMBER,
        pmOrderBy   IN VARCHAR2
    RETURN TYP_EMP PIPELINED
    AS
        vString VARCHAR2(100);
        TYPE vRefCursor IS REF CURSOR;
        Cur  vRefCursor;  
        Rec  TYP_EMP_OBJ := TYP_EMP_OBJ(NULL,NULL,NULL,NULL,NULL);
    BEGIN
        IF pmType IS NULL THEN
            SELECT 0,NULL,NULL,NULL,NULL INTO Rec.TOTAL,Rec.ROWINDEX,Rec.EMPNO,Rec.ENAME,Rec.LOC FROM DUAL;
            pipe row(rec); ----------------<<<<----------------- This is required
            RETURN;
        END IF;
        IF pmType =1 THEN
        OPEN Cur FOR
        'SELECT * FROM(
            SELECT
                COUNT(*) OVER(),
                ROW_NUMBER() OVER('||pmOrderBy||') ROW_INDEX,
                EMPNO,
                ENAME,
                FUN_GETEMP_LOCATION(EMP.DEPTNO) LOC
            FROM EMP)T
        WHERE T.ROW_INDEX BETWEEN '||pmStartPage||' AND '||pmEndPage;
        ELSE
        OPEN Cur FOR
        'SELECT * FROM(
            SELECT
                COUNT(*) OVER(),
                ROW_NUMBER() OVER('||pmOrderBy||') ROW_INDEX,
                2,
                ENAME,
                FUN_GETEMP_LOCATION(EMP.DEPTNO) LOC
            FROM EMP)T
        WHERE T.ROW_INDEX BETWEEN '||pmStartPage||' AND '||pmEndPage;
        END IF;   
    LOOP
        FETCH Cur INTO Rec.TOTAL,Rec.ROWINDEX,Rec.EMPNO,Rec.ENAME,Rec.LOC;
            EXIT WHEN Cur%NOTFOUND;
        PIPE ROW(Rec);
    END LOOP;
    CLOSE Cur;
    RETURN;
    END;Edited by: Karthick_Arp on Dec 24, 2009 2:12 AM

  • Can Evaluate function return object type

    Hi
    Evaluate function can be used to call db functions in OBIEE. I have a function which returns an object ( pl/sql table).
    Created a simple report in Oracle Answers and added following in one of the columns
    evaluate( 'get_ccid(%1)' as t_ccid , @{p_request})
    When I try to run this in Oracle answers, getting syntax error. If same function returns varchar or number it works well.

    evaluate( 'get_ccid(%1)' as t_ccid , @{p_request})Eakta, You syntax seems to be wrong here. What type of data your presentation variable contains here ?? You are saying its working fine with Number datatype..so can you try..somthing like below with some default value..
    EVALUATE('get_ccid(%1)',@{p_request}{2})
    OR
    EVALUATE('get_ccid(%1)' as varchar(250),@{p_request}{ABC})
    Also, refer
    Syntax for Evaluate function in OBIEE
    http://108obiee.blogspot.com/2009/04/using-presentation-variable-from-first.html
    Hope its useful

  • Materialized View with column based on PL/SQL function returning object

    I have the following problem - it is known that materialized view wants PL/SQL functions used in it to be DETERMINISTIC. And it appears that a function which returns SDO_GEOMETRY cannot be DETERMINISTIC - I can add DETERMINISTIC modifier to my function which returns sdo_geometry based on USNG grid ID and save the package, and it compiles and runs fine with regular queries, but when it comes to materialized view (mview), the following error is thrown:
    ORA-12018: following error encountered during code generation for "SCHEMA"."MVIEW_NAME"
    ORA-00932: inconsistent datatypes: expected NUMBER got MDSYS.SDO_GEOMETRY
    Looks like DETERMINISTIC modifier is not fully supported for object types. I have tried to use SDO_CS.FROM_USNG Oracle's function, and it appeared that this function is also non-deterministic - I cannot refresh mview with P or F on-demand refresh method (see http://download-uk.oracle.com/docs/cd/B19306_01/server.102/b14223/refresh.htm#i1008349 for a list of on-demand refresh methods). Without that function I can refresh mview with P or F flags.

    Hi,
    Yes, the Chart Series can be based on "Function Returing SQL Query" and the "SQL" would be something like:
    DECLARE
    vSQL VARCHAR2(1000);
    BEGIN
    vSQL := 'SELECT NULL LINK, ENAME LABEL, SAL VALUE FROM EMP ORDER BY ENAME';
    RETURN vSQL;
    END;You should tick the "Save query without validation" underneath that. Without this, there is a validation error - the ; at the end is required to get the chart to function correctly but the validator sees this as an error.
    You would need to create this separately from the report. No matter how you did it, the chart would still run a SQL statement to generate the output. If you wanted to use the "same data", then you could create a collection using the PL/SQL and base both the report and the chart on the collection instead.
    Andy

  • How to call a function having OBJECT type as Return type

    Hi,
    I've the following function returning OBJECT type.
    Pease advice me how to call this function
    CREATE OR REPLACE TYPE GET_EMP_OBJ is object
       ( emp_name varchar2(50) ,
         mgr_id   number,
         dept_id  number
    CREATE OR REPLACE FUNCTION get_emp(P_emp_no NUMBER )
      RETURN GET_EMP_OBJ  IS
      t_emp_info GET_EMP_OBJ ;
      v_ename  EMP.ename%TYPE;
      v_mgr    EMP.mgr%TYPE ;
      v_deptno EMP.deptno%TYPE;
      v_ename1  EMP.ename%TYPE;
      v_mgr1    EMP.mgr%TYPE ;
      v_deptno1 EMP.deptno%TYPE;
    BEGIN
      FOR rec IN ( SELECT ename , mgr , deptno
                     FROM emp )
      LOOP
         v_ename := rec.ename ;
         v_ename1 := v_ename1||'|'||v_ename ;
         v_mgr   := rec.mgr   ;
         v_mgr1  := v_mgr1||'|'||v_mgr ;
         v_deptno:= rec.deptno;
         v_deptno1 := v_deptno1||'|'||v_deptno ;
      END LOOP ;
      t_emp_info  := GET_EMP_OBJ (v_ename,v_mgr,v_deptno ) ;
      RETURN t_emp_info ;
    EXCEPTION WHEN OTHERS THEN
      DBMS_OUTPUT.put_line ('Error'||SQLCODE||','||SQLERRM ) ;
    END;The above function got created successfully.
    And i'm confused how to call this functions. I tried like below but didn't work
    DECLARE
      t_emp_info_1  GET_EMP_OBJ ;
    BEGIN
       t_emp_info_1 := get_emp(7566) ;
       for i in 1..t_emp_info_1.COUNT
          LOOP
             DBMS_OUTPUT.put_line ('Values are'||i.emp_name ) ;
         END LOOP;
    END;  

    SQL> CREATE OR REPLACE TYPE GET_EMP_OBJ is object
      2     ( emp_name varchar2(50) ,
      3       mgr_id   number,
      4       dept_id  number
      5     );
      6  /
    Type created.
    SQL> ed
    Wrote file afiedt.buf
      1  CREATE OR REPLACE FUNCTION get_emp(empno NUMBER )
      2    RETURN GET_EMP_OBJ  IS
      3    t_emp_info GET_EMP_OBJ ;
      4  BEGIN
      5    begin
      6      select get_emp_obj(ename, mgr, deptno) into t_emp_info
      7      from emp
      8      where empno = get_emp.empno;
      9    exception
    10      when no_data_found then
    11        t_emp_info := new get_emp_obj(null,null,null);
    12    end;
    13    return t_emp_info;
    14* END;
    SQL> /
    Function created.
    SQL> set serverout on
    SQL>
    SQL> declare
      2    t_emp_info  GET_EMP_OBJ ;
      3  BEGIN
      4     t_emp_info := get_emp(7566);
      5     DBMS_OUTPUT.put_line ('Values are: '||t_emp_info.emp_name||', '||t_emp_info.mgr_id||', '||t_emp_info.dept_id);
      6  END;
      7  /
    Values are: JONES, 7839, 20
    PL/SQL procedure successfully completed.
    SQL>

  • Function return value == -10. Native error code -2146824584 ADOBD.Recordset: Operation is not allowed when object is closed

    I want to call Stored Procedure that return records and output parameter, from CVI
    I can get output parrameter but when I want to get records stream I recieve following wrror:
    function return value == -10. Native error code -2146824584 ADOBD.Recordset: Operation is not allowed when object is closed

    in Stored procedure I create table variable and and insert into string values
    when I remove usage of table variable the error desappear

  • JAVA Calling Oracle Function and Returning OBJECT

    HI,
    I am working as a developer in java/j2ee project.
    I am facing one issue:
    I need to call Oracle function from java code. Oracle User define function is residing in oracle package and returning Object which contains data.
    Can you please help me
    With Best Regards

    golduniya wrote:
    I need to call Oracle function from java code. Oracle User define function is residing in oracle package and returning Object which contains data.
    Can you please help meIt requires a great deal of Oracle jdbc driver specific code.
    [http://download-west.oracle.com/docs/cd/B10501_01/java.920/a96654/oraint.htm#1012664]

  • How can a function return a constant reference to an object

    how can a function return a constant reference to an object so that the calling party dont have rights to change it.
    like this example
    class obj = somefunc();
    obj.changeit(); // this line lust give error saying that its read only..
    somefunc()
    return criticalobj;
    in c++ we can achieve this by using the const pointer to the object.. how can we do this in java???

    arun160411 wrote:
    in c++ we can achieve this by using the const pointer to the object.. how can we do this in java???Of course the first thing anyone learns about const pointers is how to cast away constness, so this is completely useless, up there with the chastity movement's thong underwear with the stop sign on it. If you can read this, you're too close!

  • How to migrate sql server 2000 user defined function returns table

    Hi,
    How do I capture the SQL Server 200 user defined function that returns table? Is this supported in the current version of Oracle Migration Workbench? I am using the latest version - Release 9.2.0.1.0 with SQL SERVER 2000 plug-in.
    I was able to capture the SQL Server 2000 user defined function that returns string and smalldatetime but not the functions return table during the migrate data source stage.
    Thanks in Advance,
    Susan

    Susan,
    This is not currently supported. The next release of the Oracle Migration Workbench (due very soon), will do a better job of catching this mad reporting an error. We are looking into a suitable mapping and have created bug # 2355073 - TABLE DEFINITIONS NOT ACCEPTED FOR TABLE FUNCTIONS to track this issue.
    Once possible solution we are looking into is using the object type to emulate. Here is an example from the bug:
    Original table
    SQL> create table tabela (a number, b number, c number, d number);
    SQL> insert some values...
    SQL> select * from tabela;
    A B C D
    1 1 1 1
    2 2 2 2
    3 3 3 3
    4 4 4 4
    SQL Server 2000 code
    CREATE FUNCTION FUNCRETORNATABELA()
    RETURNS TABLE
    AS
    RETURN SELECT A,B,C,D FROM TABELA
    SELECT A,B,C,D
    FROM FUNCRETORNATABELA()
    ORDER BY A
    Oracle code (workaround)
    SQL> create or replace type MyObjType as object (
    2 a number, b number, c number, d number);
    3 /
    Type created.
    SQL> create or replace type MyTabType as table of MyObjType;
    2 /
    Type created.
    SQL> create or replace function teste return Mytabtype pipelined as
    2 aa MyObjType := MyObjType(null, null, null, null);
    3 cursor c1 is select a,b,c,d from tabela;
    4 begin
    5 open c1;
    6 loop
    7 fetch c1 into aa.a, aa.b, aa.c, aa.d;
    8 exit when c1%NOTFOUND;
    9 pipe row (aa);
    10 end loop;
    11 close c1;
    12 return;
    13 end;
    14 /
    Function created.
    SQL> select * from table(teste);
    A B C D
    1 1 1 1
    2 2 2 2
    3 3 3 3
    4 4 4 4
    SQL> select a, c from table(teste) order by c desc;
    A C
    4 4
    3 3
    2 2
    1 1
    Donal

  • Cannot call member function on object type

    On 8.1.6 I cannot call a member function from SQL in the way described in the manual.
    The following example is almost copied from the manual:
    create or replace TYPE foo AS OBJECT (a1 NUMBER,
    MEMBER FUNCTION getbar RETURN NUMBER);
    create or replace type body foo is
    MEMBER FUNCTION getbar RETURN NUMBER is
    begin
    return 45;
    end;
    end;
    CREATE TABLE footab(col foo);
    SELECT col,foo.getbar(col) FROM footab; -- OK
    select col,col.getbar() from footab; -- ERROR
    The second select is the way it should be, but I get an error "invalid column name".
    Using the first select, I get the result. This is strange because this is more or less the 'static member' notation (filling in the implicit self parameter myself).
    Is this a known bug in 8.1.6, maybe fixed in later versions?

    Konstantin,
    Did you use loadjava to load the compiled class into the Oracle Database?
    Regards,
    Geoff
    Hello!
    I need to write a member function for object type with java.
    for example:
    create type test as object(
    id number,
    name varchar2(20),
    member function hallo return number);
    create type body test as
    member function hallo return number
    as language java
    name 'test.hallo() return int;
    create table test of test;
    My java-file is:
    public class test {
    public int hallo() {
    return 5;
    select t.hallo() from test t;
    It's does not run. Why?
    I get always an error back. Wrong types or numbers of parameters!!
    please help me.
    thanks in advance
    Konstantin

  • Call stored function return array

    Hi all,
    I have a function as follow:
    create or replace TYPE string_table IS TABLE OF VARCHAR2(2000);
    create or replace TYPE ARRAYTYPE is VARRAY(20) OF VARCHAR2(30);
    create or replace FUNCTION getEmpArray(s varchar2, t varchar2, st string_table) RETURN ARRAYTYPE AS
    l_data ARRAYTYPE := ARRAYTYPE();
    BEGIN
    l_data.extend; l_data(l_data.count) := s; l_data.extend; l_data(l_data.count) := t; l_data.extend; l_data(l_data.count) := st(1); RETURN l_data;
    END;
    I want to call this function by StoredFunctionCall
    code:
    StoredFunctionCall fun = new StoredFunctionCall();
    fun.setProcedureName("getEmpArray".toUpperCase());
    Object[] arr = new Object[]{"aa", "fgfg", "bbb"};
    ArrayDescriptor arrDescriptor =
    ArrayDescriptor.createDescriptor("string_table".toUpperCase(),
    connection);
    ARRAY arrayToPass = new ARRAY(arrDescriptor, connection, arr);
    fun.addUnamedArgumentValue("a");
    fun.addUnamedArgumentValue("b");
    fun.addUnamedArgumentValue(arrayToPass);
    fun.setResult("FUNCTION_RESULT"); // for get result by this name
    Vector<DatabaseRecord> list = session.executeSelectingCall(fun);
    But Exception
    PLS-00382: expression is of wrong type
    ORA-06550: line 1, column 7:
    PL/SQL: Statement ignored
    Error Code: 6550
    Call: BEGIN ? := GETEMPARRAY(?, ?, ?); END;
         bind => [=> FUNCTION_RESULT, a, b, oracle.sql.ARRAY@21fbc01]
    Please help me
    Edited by: fbg on 21:52 26-04-2010

    A few issues,
    1 - JDBC does not support the PLSQL TABLE type, you must use a VARRAY type, or wrap the TABLE function call in a function that takes a VARRAY.
    TopLink also has support for PLSQL types in its PLSQLStoredProcedureCall class, but no support is currently offered for StoredFunctions.
    You can't pass the VARRAY type for the TABLE argument.
    2 - Your function returns a VARRAY, so you need to define this type in the StoredFunctionCall result.
    We don't currently expose the API to set a Array type for the result, so you would need to access the call's first parameter directly, or use a StoredProcedureCall (and convert your function to a procedure).
    You may also wish to investigate returning a cursor from a stored procedure instead of the varray.
    You could also access the JDBC connection directly and perform the call using JDBC code.
    Feel free to log these issues in EclipseLink.
    James : www.eclipselink.org

  • Can a function return two values???

    Hi guys can a function return more than values?

    Or even better return an Object.
    ie
    public class Tester{
         public static Multi getM()
              Multi m=new Multi();
              m.x="testing";
              m.y="new value";
         public static void main(String [] args)
              Multi mt=getM();
              System.out.println(mt.x);
              System.out.println(mt.y);
         class Multi{
              public String x;
              public String y;
    }

  • HashCode function in Object class.

    Hi! to all!
    I have got a confusion about hashCode function of Object class, which returns an integer.
    What is the real purpose of introducing this method in Object class.
    Please comment.

    hashCode() method of the object is intorduced for the benefit of collections like HashTables. Typically
    hashCode method should return distinct integers for distinct objects which are decided distinct based on
    equals method of the object. Though this is not mandatory , if distinct objects have distinct
    hashCodes, it will improve the performance of HashTables.A good distribution of hash codes will indeed help in the performance of a HashMap or Hashtable. However, by definition, hashcodes are not necessarily distinct for objects that are distinct based on equals. Two objects for which "equals" is true should have the same hashcode, but two objects which have the same hashcode don't have to have "equals" be true. There is a limited number of hashcodes (the range of int), but an unlimited number of objects. So, some objects will necessarily have the same hashcode. The pigeonhole principle describes this situation:
    http://en.wikipedia.org/wiki/Pigeonhole_principle

  • Return Objects by Value/Reference?

    Could someone please tell me which of this methods would be faster:
    import java.util.ArrayList;
    import java.util.List;
    public class Test {
        public static final int MAX_ITER = 2000000;
        public static void main(String[] args) {
             long begin, end = 0;
             //Return Object by Value
             begin = System.currentTimeMillis();
             List list1 = returnByValue();
             end = System.currentTimeMillis();
             System.out.println(end - begin);
             //Return Object by reference
             begin = System.currentTimeMillis();
             List list2 = new ArrayList();
             returnByRef(list2);
             end = System.currentTimeMillis();
             System.out.println(end - begin);
        public static List returnByValue() {
             List list = new ArrayList();
             for(int i=0; i<MAX_ITER; i++)
                  list.add(new Integer(i));
             return list;
        public static void returnByRef(List list) {
             for(int i=0; i<MAX_ITER; i++)
                  list.add(new Integer(i));
    }From what I understand, returnByValue would be slower as it involves creating a local List, and then returning it by way of copying itself? But surprisingly, both methods take almost identical times to run. Also, please run each method individually one at a time per run, otherwise for some reason, the second method always takes longer if ran simultaneously. Thanks.

    Okay, I thought about that, too, because I thought
    that your post did sound a bit sarcastic. Your post was most useful. I think s/he's refering to me.
    I don't care about my post count. Maybe next time
    I'll help people who are more appreciative of my
    information, instead of helping you.Actually, I think s/he's most appreciative of your excellent contribution. I believe I'm the problem.
    I think that telling people to believe the evidence in front of them is a good service to provide. You ran a test that told you the two were virtually identical. I gave you another viewpoint that said side effect free functions should be preferred, especially in situations like this one. No post count boosting there. That's good information. You just need to be sharp enough to realize it.
    %

  • Returning object by reference

    Hi all.
    I'm new to java programming an I'm confused about calling functions with objects as par�meters.
    For example I have the following function definition.
    public ErrorInfo GetDBConnection( Connection con){
    // get a connection from the pool and assign it to con
    I want to call this function as follows;
    Conection conec = null;
    ErrorInfo error;
    error = GetDBConnection(conec);
    After this line conec has the value "null" but when I trace the function it assignes a value to con.
    Please give me some guidelines to achieve this.
    Thanks in advance.
    Marko.

    You can't do that in Java since all objects are passed by reference. That is, the reference is passed by value, so it cannot be altered and returned. Any parameter in Java behaves as a local variable.
    Anyway, a much better method for achieving the behaviour that you seem to want is this:
    public Connection getDBConnection() throws SomeException {
        // Return the connection or throw an exception if an error
        // occurs.
    try {
        Connection conec = getDBConnection();
    } catch (SomeException e) {
        // Handle your error here
    }You can either declare your own exception class to pass the error information or use one of the pre-defined. I suppose that you use JDBC which declares SQLException.
    S&oslash;ren

Maybe you are looking for

  • Mail to all the employess in the internal table.

    Hi Experts, I have a internal table where the employee IDs are saved.. I need to send a mail to all the employees in the internal table. How will i be able to send a mail from the function module SAP_WAPI_START_WORKFLOW? where will i pass the interna

  • After transfer to new mac lots of image not supported!

    Hello all. I have just tranferred to a new imac and copied over my aperture folder. In one particular project as I click on each image the image breifly shows then appears to currpot and is replaced with a black box saying its unsupported. they are f

  • User validation for the BSP application

    I wanted a user to access the bsp application. I already have the user names maintained in the database who will be using the application. i am using the application class for my application. where should i do the user validation and how. i know tst

  • Stopping a header reloading with each page

    I've had loads of conflicting advice on this one. Someone must know surely. How do I stop a flash movie from reloading each time a link button is clicked. In other words I just want the movie to load once on the home page and the integrated buttons t

  • Bloated CSS Style Sheet...

    My style sheet is about 60k... much too big. Trying to find a way to put it on a diet. Is there a way to convert it to ' css shorthand'? I set the preferences to use shorthand for css declarations but don't see any change in existing style sheets. He