Reg: Call By Value & Call By Reference

Dear Gurus,
Can anyone give me the exact difference between Call By Value and Call By Reference in calling procedures. And also give me which one is call by value&reference in In,Out,In Out.
Cheers,
Jai

Hi Alex,
Simple and elegant explanation, but I do have a question.
Passing a variable to an argument of a procedure or a function which has been defined as out will consider it as null inside the sub program block until the value actually get changed inside it, then what is the need of pass by value to an argument defined as OUT (apart from the point the value gets copied back after the program completion)
create or replace procedure test_proc(a out number,b in out number) as
begin
dbms_output.put_line('A Value :'||a);
dbms_output.put_line('B Value :'||b);
end;
declare
val_a number := 10;
val_b number := 10;
begin
test_proc(val_a,val_b);
dbms_output.put_line('val_A Value :'||val_a);
dbms_output.put_line('val_B Value :'||val_b);
end;
PRAZY@11gR1> /
A Value :
B Value :10
val_A Value :
val_B Value :10
PL/SQL procedure successfully completed.
Elapsed: 00:00:00.01And here A prints null even though we passed 10.
@OP: Pardon me for taking-over your thread.
Regards,
Prazy
Edited by: Prazy on Mar 26, 2010 2:49 PM

Similar Messages

  • Java is call by value or call by reference

    Hi! friends,
    I want to know,java is call by value and call by reference.
    Please give the the exact explanation with some example code.

    All parameters to methods are passed "by value." In other words, values of parameter variables in a method are copies of the values the invoker specified as arguments. If you pass a double to a method, its parameter is a copy of whatever value was being passed as an argument, and the method can change its parameter's value without affecting values in the code that invoked the method. For example:
    class PassByValue {
        public static void main(String[] args) {
            double one = 1.0;
            System.out.println("before: one = " + one);
            halveIt(one);
            System.out.println("after: one = " + one);
        public static void halveIt(double arg) {
            arg /= 2.0;     // divide arg by two
            System.out.println("halved: arg = " + arg);
    }The following output illustrates that the value of arg inside halveIt is divided by two without affecting the value of the variable one in main:before: one = 1.0
    halved: arg = 0.5
    after: one = 1.0You should note that when the parameter is an object reference, the object reference -- not the object itself -- is what is passed "by value." Thus, you can change which object a parameter refers to inside the method without affecting the reference that was passed. But if you change any fields of the object or invoke methods that change the object's state, the object is changed for every part of the program that holds a reference to it. Here is an example to show the distinction:
    class PassRef {
        public static void main(String[] args) {
            Body sirius = new Body("Sirius", null);
            System.out.println("before: " + sirius);
            commonName(sirius);
            System.out.println("after:  " + sirius);
        public static void commonName(Body bodyRef) {
            bodyRef.name = "Dog Star";
            bodyRef = null;
    }This program produces the following output: before: 0 (Sirius)
    after:  0 (Dog Star)Notice that the contents of the object have been modified with a name change, while the variable sirius still refers to the Body object even though the method commonName changed the value of its bodyRef parameter variable to null. This requires some explanation.
    The following diagram shows the state of the variables just after main invokes commonName:
    main()            |              |
        sirius------->| idNum: 0     |
                      | name --------+------>"Sirius"       
    commonName()----->| orbits: null |
        bodyRef       |______________|At this point, the two variables sirius (in main) and bodyRef (in commonName) both refer to the same underlying object. When commonName changes the field bodyRef.name, the name is changed in the underlying object that the two variables share. When commonName changes the value of bodyRef to null, only the value of the bodyRef variable is changed; the value of sirius remains unchanged because the parameter bodyRef is a pass-by-value copy of sirius. Inside the method commonName, all you are changing is the value in the parameter variable bodyRef, just as all you changed in halveIt was the value in the parameter variable arg. If changing bodyRef affected the value of sirius in main, the "after" line would say "null". However, the variable bodyRef in commonName and the variable sirius in main both refer to the same underlying object, so the change made inside commonName is visible through the reference sirius.
    Some people will say incorrectly that objects are passed "by reference." In programming language design, the term pass by reference properly means that when an argument is passed to a function, the invoked function gets a reference to the original value, not a copy of its value. If the function modifies its parameter, the value in the calling code will be changed because the argument and parameter use the same slot in memory. If the Java programming language actually had pass-by-reference parameters, there would be a way to declare halveIt so that the preceding code would modify the value of one, or so that commonName could change the variable sirius to null. This is not possible. The Java programming language does not pass objects by reference; it passes object references by value. Because two copies of the same reference refer to the same actual object, changes made through one reference variable are visible through the other. There is exactly one parameter passing mode -- pass by value -- and that helps keep things simple.
    -- Arnold, K., Gosling J., Holmes D. (2006). The Java� Programming Language Fourth Edition. Boston: Addison-Wesley.

  • Confusion about call-by -value and call - by reference

    class A{
    public boolean check(String source, ArrayList arr){
    //pROCESS ON ARRAYLIST
    class B {
    A con = new A();
    String source="this is string ";
    ArrayList arr = new ArrayList();
    // suppose Arraylist has some elements
    boolean  error= false;
    error = A.check(source,arr);
    }Is it call by value or call by ref .
    Please help
    }

    Object references are also passed by value. ???Yes, as demonstrated byclass Foo {
        public int bar = 0;
        public static void main(String[] args) {
                Foo foo = new Foo();
                foo.bar = 1;
                System.out.println(foo.bar);
                baz(foo);
                // if this was pass by reference the following line would print 3
                // but it doesn't, it prints 2
                System.out.println(foo.bar);
        private static void baz(Foo foo) {
            foo.bar = 2;
            foo = new Foo();
            foo.bar = 3;
    }

  • How to call applescript values?

    Hi,
    Now am working in indesign CS2 Scripting.. I need to call a applescript.. so that i used doScript..
    i have 2 doubts...
    1) If i choose a file in the javascript, the file path structure is like "~/Desktop/New/1.jpg". I need to get the full parent folder path of file.. is it possible???
    2) If i set a value to a variable in applescript.. how do i call the value from the javascript??? using doScript???
    Thanks in advance..
    by
    Subha

    I know very little about JS, but these are fairly easy to accomplish in AS.
    [1] get path to home folder
    will return the equivalent of the "~" path.
    Or in your specific example to get an image in the desktop folder you could also use something like:
    set myPath to ("" & (path to desktop folder) & "New:1.jpg")
    If you want it returned with slashes instead of colons in the path, add posix path of:
    set myPath to posix path of ("" & (path to desktop folder) & "New:1.jpg")
    [2] I think the last line of your AS should be something like "return myResult". Then whatever variable you assign the doScript to should get the results you return.

  • Call HEADER value into ITEM level in mapping

    HI,
    my structure is as below:
    H
    I
    I
    I
    P
    H
    I
    I
    P
    P
    H
    I
    I
    I
    I
    I
    P
    I have created a sequence in DB and retriving the value from DB using lookup for the header level(H) for feild ID.by using the code:
       //write your code here
       //write your code here
    String Query = " ";
    Channel channel = null;
    DataBaseAccessor accessor = null;
    DataBaseResult resultSet = null;
    try{
                    //container.getTrace().addWarning("Obtaining channel");
                    channel = LookupService.getChannel( businessSystem, communicationChannel);
                    //container.getTrace().addWarning("Channel OK");
                    //Get a system accessor for the channel. As the call is being made to an DB, an DatabaseAccessor is obtained.
                    accessor = LookupService.getDataBaseAccessor(channel);
                    //container.getTrace().addWarning("Accessor OK");
                    //Execute Query and get the values in resultset
                    resultSet = accessor.execute(" SELECT ID.NEXTVAL FROM DUAL");
                    //container.getTrace().addWarning("SELECT OK");
                    //String[] cols = resultSet.getMetaData().getColumnNames();
                    //for (int i=0; i<cols.length; i++){
                    //            container.getTrace().addWarning("Column name: " + cols<i>);
                    for(Iterator rows = resultSet.getRows();rows.hasNext();){
                                    //container.getTrace().addWarning("Result has rows");
                                    Map rowMap = (Map)rows.next();
                                    //container.getTrace().addWarning("Trying to get NEXTVAL");
                                    //Object obj = rowMap.get("NEXTVAL");
                                    //container.getTrace().addWarning("Data received " + obj);
                                    //return obj.toString();
                                    return rowMap.get("NEXTVAL").toString();
                                    //return ((String)rowMap.get("NEXTVAL"));
                    //container.getTrace().addWarning("Result has no rows");
                    throw new RuntimeException("Cannot obtain next service repair ID");
                    //return "-1";
    } catch(Exception ex){
                    container.getTrace().addWarning("Exception " + ex.getMessage());
                    throw new RuntimeException("Cannot obtain next service repair ID", ex);
                    //return "-1";
    finally {
                    try {
                                    if (accessor!=null) accessor.close();
                    catch(Exception e){
                                    container.getTrace().addWarning("Cannot close DataBaseAccessor for service " + businessSystem +
                                                                                    " and comm channel " + communicationChannel + " in getNextID user defined funcion");
    now my requirement is i have my to call the same value of ID feild into ID of I.to represent perticular I is related to so and so Header(H).
    Please suggest me how i can call the value to which is passing to ID(targetfeild) of H and map to ID(targetfeild) of I.
    please provide me UDF code....
    thanks in advance,
    Naveen.

    Use standard function UseOneAsMany (found under NodeFunctions) to populate the Header-value for each of the corresponding Item-segments.
    Input 1 - your header-fields as resulted from DB-lookup
    Input 2 - Item-segment
    Input 3 - Item-segment
    Make sure to set the context for Input 1 so that there are equal number of contexts in Input 1 as 2 & 3.
    -Kenneth

  • OCI-01555 exception on calling OracleXmlType .Value method

    Hi,
    I'm using Oracle 10g EX, and ODAC 1020221. I created an ODP.net based C# webservice that reads/writes xml data using stored procedures.
    I implemented the read as illustrated below:
    OracleConnection connection = new OracleConnection(...);
    OracleCommand command = connection.CreateCommand();
    OracleParameter param = command.CreateParameter();
    param.ParameterName = "XML_COL";
    param.OracleDbType = OracleDbType.XmlType;
    param.Direction = ParameterDirection.Output;
    command.ExecuteNonQuery();
    OracleParameter param = command.Parameters["XML_COL"];
    OracleXmlType xmlType = (OracleXmlType)param.Value;
    string value = xmlType.Value;
    This works fine as long I call it in a single-threaded test.
    However, when I run a multi-threaded test with more than 2 threads I'm getting the occasional exception on calling xmlType.Value:
    OCI-01555: Message 1555 not found; product=RDBMS; facility=OCI
    at Oracle.DataAccess.Client.OracleException.HandleErrorHelper(Int32 errCode, OracleConnection conn, IntPtr opsErrCtx, OpoSqlValCtx* pOpoSqlValCtx,
    Object src, String procedure)
    at Oracle.DataAccess.Client.OracleException.HandleError(Int32 errCode, OracleConnection conn, IntPtr opsErrCtx, Object src)
    at Oracle.DataAccess.Types.OracleXmlType.HandleError(Int32 errCode, OracleConnection conn, IntPtr opsErrCtx, Object src)
    at Oracle.DataAccess.Types.OracleXmlType.get_Value()
    Surprisingly, I have not been able to find any documentation regarding this error, though there is a ORA error with the same number indicating some rollback size issues.
    The problem seem to occur when another thread in my webservice updates the same record. The stored procedure is "safe-guarded" by a lock, however, I didn't implement additional locking in my webservice, because a) I thought odp.net can cope, and b) ado.net/sql has no problem with this approach, but perhaps I assumed wrongly?
    Has anybody seen this exception before and can explain what this is all about?
    Many thanks,
    Frank
    Edited by: 803211 on 19-Oct-2010 01:46

    we meet exactly the same problem.
    Did you fix it?

  • External value call from Lisenter Interface Implementation

    Hi,
    inside an actionPerformed func I've done some calculations, and I want to call these values from another class of the application.
    Is it possible without having to change my program structure?
    I've tried using seriazable object but it didn't work.
    Is there any though about this problem?
    There should be a way I suppose.
    Thanks In Advanced
    George

    Program Structure:
    class Manager extends JFrame {
    public void actionPerformed() {
    // use the values of array1 and vector1
    class Help extends JPanel {
    // and in some point
    public void actionPerformed() {
    // various calculations
    new arrar1;
    new Vector1; // anything
    As you can see basically, I'm giving an action from a button from Help class, the function does some calculations.
    Now I need to use these values to the Manager class-actioanPerformed.
    I dont think that something like Help h = new Help() will help. I think.
    That is the structure.
    T.I.A.
    George
    }

  • How to call & pass values to custom page from seeded page table region

    Hi All,
    can anyone tell me how to call & pass values to custom page from seeded page table region(Attribute is not available in seeded page VO)
    it is urgent. plssss
    Regards,
    purna

    Hi,
    Yes, we do this by extending controller, but you can also try this without extending controller.
    1. Create Submit Button on TableRN using personalization.
    2. Set "Destination URI" property to like below
    OA.jsp?page=/<yourname>/oracle/apps/ak/employee/webui/EmpDetailsPG&employeeNumber={@EmployeeId}&employeeName={@EmployeeName}&retainAM=Y&addBreadCrumb=Y
    Give your custom page path instead of EmpDetailsPG.
    EmployeeId and EmployeeName are VO attributes(Table Region)
    If you dont have desired attribute in VO, then write logic in your custom page controller to get required value using parameters passed from URL path.
    In this case, only personalization will do our job. Hope it helps.
    Thanks,
    Venkat Y.

  • Static method called from a null object reference

    Hello folks,
    Here´s the code:
    public class TestClass {
         public static void main(String[] args) {
              StaticNull _null_ = null;
              _null_.testNull();
    class StaticNull {
         public static void testNull() {
              System.out.println("testNull");
    }I know that a static method belongs to the class, so you don´t need an
    instantiated object of that class to call it. But in the code above, as
    I'm calling the testNull method from a null reference, shouldn't a NullPointerException
    be thrown?
    Best regards,
    Danniel

    sometimes wrote:
    yawmark wrote:
    Calling static methods from a reference variable should be considered a bad practice. Our coding standards prohibit it, and I suspect we're not the only ones.
    ~what are you trying to say? your coding standard encourages what tricks to invoke static methods? i mean other than using a 'reference variable'?I think you are misreading yawmark's comment. He was saying that invoking a static method using a reference variable -- as though the method weren't static:
    var.staticMethod();...is bad practice. His shop's coding standards prohibit it. And that's a common coding style standard. IDE's often warn you of that, right?
    edit: and judging by your reply #7, you and yawmark would bond over a few jars of cold beverages. You seem think with one mind.

  • System error occurred (RFC call),key value exists in duplicate

    hi bw expert ,
    i happen the error report.
    "system error occurred (RFC call).
    key value exists in duplicate (Not allowed by the ODS object type).
    Activation of data records from ODS object Z08TRFKP terminated.
    No confirmation for request odsr_80p13w4lqhnib3g9tiflvth56 when activating ODS object Z08TRFKP.
    Request REQU_EVZB7CK82H7YMS13X3G42GKQY , data package 000001 contains errors with status 5 .
    Request REQU_EVZB7CK82H7YMS13X3G42GKQY , data package 000001 not correct.
    Inserted records 1- ; Changed records 1- ; Deleted records 1-
    pls, help me .
    thanks.

    hi experts,
    the first, i initial update the data from r3 to bw ods, it is successful. the second, the system automatic touch off delta update from r3 to bw ods. it is false. now i have deleted the false delta update and repeat extractive. but it is also error.
    please help me again.
    thanks.

  • Total calls presented does not match with the calls presented value in CSQ activity report (by interval)

    Hi,
    We encountered a mismatch details between the call presented value and total call presented value. I attached the report here. If you count the number of calls presented and handled there are 2 calls but why is it the total calls only count 1. Where did the other call go?
    I look for some possible related problems but the answer only point out to a bug. The version of UCCX is 8.5.1 SU 3 and the bug was solved in version 7.0.
    Hope you can help me with this issue.
    Thanks and regards,
    Rona

    It looks like it may be an issue with the report file itself and not the report data. You can see both calls are shown in the report but the summary information doesn't appear to be calculating correctly. If you have the Crystal Reports Developer toolset you can open the report file and verify that the report summary is using SUM instead of something like MAX/AVG, etc.
    Tanner

  • Query to call udf value from BP on PO

    Hi All,
    I have created two udf's on BP, U_state and u_country to capture the state name and country name. I am trying to call teh value of these udf on PO.
    The code is ;
    SELECT Top 1(T2.[U_State]) FROM CRD1 T2  INNER JOIN OCRD T1 ON T2.CardCode = T1.CardCode INNER JOIN OPOR T0 ON T1.CardCode = T2.CardCode where  T2.[Address] = T0.[PayToCode] and T2.[AddrType] = 'B'
    (this is for state name)
    This is not giving any result. Please assist to correct this one.
    Thanks,
    Joseph
    Edited by: Joseph Antony on Sep 21, 2011 12:56 PM

    Hi Joseph,
    Please apply the following step by step ....
    -> create 2 UDF state & Country in CRD1 Table.
    -> Apply following the FMS on State UDF feild
    SELECT T0.Name FROM OCST T0 WHERE T0.Code =(select $[CRD1.State.Character])
    -> Apply following the FMS on Country UDF feild
    SELECT T0.Name FROM OCRY T0 WHERE T0.Code =(select $[CRD1.Country.Character])
    -> Create 2 UDF in Marketing Documents ie Purchase Order form
    ->Apply following the FMS on PO UDF feild
    SELECT T2.[U_State] FROM CRD1 T2  INNER JOIN OCRD T1 ON T2.CardCode = T1.CardCode 
    WHERE T1.CardCode =(select $[OPOR.Cardcode.Character])
    SELECT T2.[U_Country] FROM CRD1 T2  INNER JOIN OCRD T1 ON T2.CardCode = T1.CardCode 
    WHERE T1.CardCode =(select $[OPOR.Cardcode.Character])
    Check above FMs query ............
    Note :  replace [=http://
    Regards
    Kamlesh Naware

  • Calling the value change listner automatically for a checkbox.

    i have some booleancheckbox column in a table.i have defined some code in the valuechangelistner in backing bean.when i am clicking any part of the table's row it automatically calling the value change listner;but my requirement is it should call the value change listner when i am only checking the checkbox.
    i am using jdev 11.1.1.5.
    So can any one bring some solution .
    Thanks in advance.

    i have some booleancheckbox column in a table.i have defined some code in the valuechangelistner in backing bean.when i am clicking any part of the table's row it automatically calling the value change listner;but my requirement is it should call the value change listner when i am only checking the checkbox.
    i am using jdev 11.1.1.5.
    So can any one bring some solution .
    Thanks in advance.

  • Parameter passing by value or by reference in function module

    hi everybody:
    Im a beginner for abap.
    Below description is described in online help.
    In function module, the CALL FUNCTION statement can pass import, export, and changing parameters either by value or by reference. Table parameters are always transferred by reference.
    I understand parameters passing by value means values carried by parameters are transferred, but I do not understand what is "by reference".
    Please kindly give me a explanation.
    Regards.
    Andy

    hi,
    Function modules are modular units with interfaces. The interface can contain the following elements:
    Import parameters are parameters passed to the function module. In general, these are assigned
    standard ABAP Dictionary types. Import parameters can also be characterized as optional.
    Export parameters are passed from the function module to the calling program. Export parameters
    are always optional and for that reason do not need to be accepted by the calling program.
    Changing parameters are passed to the function module and can be changed by it. The result is
    returned to the calling program after the function module has executed.
    Exceptions are used to intercept errors. If an error triggers an exception in a function module, the
    function module stops. You can assign exceptions to numbers in the calling program, which sets the
    system field SY-SUBRC to that value. This return code can then be handled by the program.
    By reference Passes a pointer to the original memory location.  Very efficient
    By value Allocates a new memory location for use within the subroutine. The memory is freed when the subroutine ends.  Prevents changes to passed variable
    By value and result Similar to pass by value, but the contents of the new memory is copied back into the original memory before returning.  Allows changes and allows a rollback
    When you pass a parameter by reference, new memory is not allocated for the value. Instead, a pointer to the original memory location is passed. All references to the parameter are references to the original memory location. Changes to the variable within the subroutine update the original memory location immediately.
    1  report ztx1804.
    2  data f1 value 'A'.
    3
    4  perform s1 using f1.
    5  write / f1.
    6
    7  form s1 using p1.
    8      p1 = 'X'.
    9      endform.
    The code in Listing produces the following output:
    X
    Hope this helps, Do reward.

  • Do we have PB VALUE and PB REFERENCE in RFC'SN or BAPI'S

    HI ABAPers,
    greetings to all,
    I HAVE A DOUBT REGARDING RFC'S concept.
    Do  we have PASS BY VALUE and PASS BY REFERENCE (OR) CALL BY VALUE and CALL BY REFERENCE in RFC'S or BAPI'S.
    IF SO HOW DO THEY WORK.
    please provide information about this PBR and PBV.

    Hi
    The OID´s do return values which is good.
    But I´ve not been able to verify that this is inline with the acutal CPU load as shown via the GUI (Administration-Diagnostics-CPU utilisation)
    Someone (thread in support community) pointed out that these values are number of packets sent to the CPU rather than the load of CPU?
    CPU utilization for 5 seconds
    .1.3.6.1.4.1.9.6.1.101.1.7.0
    CPU utilization for 1 minutes
    .1.3.6.1.4.1.9.6.1.101.1.8.0
    CPU utilization for 5 minutes
    .1.3.6.1.4.1.9.6.1.101.1.9.0
    Can someone challenge that or verify the correctness of that statement?
    Thank you for you input here.

Maybe you are looking for

  • System failed

    help! I can't open my laptop. If I click on the "return to factory settings" will all my files be deleted? I don't have back up. is there a way that I can retrieve them? • Do not miss out on checking sad love quotes, it may bring a sentimental mood.

  • Problems with wi-fi connection after waking up from sleep

    Hey, I have MacBook Pro 13 (early 2011), MacOsX 10.7.2. I've got a problem - when I wake up after sleep my internet connection doesn't work for half a minute, may be more. I do diagnostics and it says that connection is ok, but still don't work. I've

  • Use time capsule for iTunes library

    I would like to use my new time capsule as the location for my iTunes library. How do I go about doing that? Currently my iTunes library is on my MacBook Pro.

  • [JOB] 2 F/T Flex Roles in NYC to 175k (Financial Services)

    Full details here: http://wp.me/pTfw1-4X

  • Patch 111685 breaks string concatenation!!!

    Patch 111685 for WS6U2 fixes a lot of problems but introduces a massive memory leak in operator+= for std::string. Sun has already acknowledged that it's a serious bug (bug id 4520126) although they are taking forever to fix it: This is the test case