GeekInterview.com
Series: Subject: Topic:
Question: 374 of 490

What is the difference between In, Out, InOut Parameters. Can we pass value or reference or both to the In Out Parameter.

Asked by: sbagai2001 | Member Since May-2006 | Asked on: May 26th, 2006

View all questions by sbagai2001   View all answers by sbagai2001

Showing Answers 1 - 7 of 7 Answers
narasimhulu

Answered On : May 31st, 2006

View all answers by narasimhulu

By default, OUT and IN OUT parameters are passed by value. The values of any INOUT parameters are copied before the subprogram is executed. During subprogramexecution, temporary variables hold the output parameter values. If the subprogramexits normally, these values are copied to the actual parameters. If the subprogramexits with an unhandled exception, the original parameters are unchanged.

  
Login to rate this answer.

How do pass value to  out or InOut Parameter by Reference.

  
Login to rate this answer.
bankimcn

Answered On : May 31st, 2006

View all answers by bankimcn

Eg for in out parameterBellow the parameter having x (eg x_return_status)as suffix is OUT,p (eg p_calling_fn)as suffix is IN and px (px_trans_rec)as suffix is INOUT.Initializing In parameter is mandatory to get desired output,OUT will be the result of procedure execution and INOUT will store result processed by the procedure.Initialize fl_chr_validation, l_num_messg_count,l_chr_messg,l_chr_trans,l_chr_disttrans proc1( p_validation_level => l_chr_validation , x_return_status => l_chr_return_status , x_msg_count => l_num_messg_count , x_msg_data => l_chr_messg , p_calling_fn => NULL , px_trans_rec => l_chr_trans , px_dist_trans_rec => l_chr_disttrans);NOTE:- for better analysis/execution Always initkialize all the parameter IN and OUT.

  
Login to rate this answer.

In     1 Default mode                       2 Value is passed into   subprogram3  Formal parameter acts as   a constant4 Actual parameter can be a   literal, expression,   constant, or initialized    variable5 Can be assigned a default    valueOUT 1 Must be specified2 Returned to   calling   environment3  Uninitialized variable4 Must be a variable5 Cannot be   assigned   a default valueINOUT1 Must be specified2 Passed into  subprogram;  returned to calling  environment3  Initialized  variable4 Must be a variable5 Cannot be   assigned   a default value Can we pass value or reference or both to the In Out Parameter.function checkf(form) { var f = document.form1;if (document.form1.cmt.value=='') { alert('Please enter the comment'); return false; }} Yes, we can by using NOCOPY keyword

  
Login to rate this answer.
Shefali

Answered On : Aug 15th, 2006

You can use NOCOPY hint for passing it by reference

  
Login to rate this answer.
raghav_sy

Answered On : Jan 15th, 2007

View all answers by raghav_sy

hi friends,To make it simple, keep in mind,IN : It is a CONSTANT in the sub-program and u can not modify its value in sub-      program. if its value is modified in the sub-program then it will give a error. OUT: the out parameter will always have a NULL value during the begining of the sub-program, we can modify its value in the sub-program and then this modified value can be sent to the calling program. Suppose from calling evironment u are sending a variable which has some value to the sub-program, but if that corresponding  variable is mrked as OUT in the sub-program, then in the sub-program that value will be replaced with NULL, and then the operation in the sub-program will be done.NOTE: this behaviour can be changed using the NOCOPY option, but remmeber the restriction imposed on NOPCOY.IN-OUT: well this is the variable, where u can read the variable and write the variable. And one more thing to note is that, for OUT and IN-OUT the variables will be passed  by value. if NOCOPY option is not used,but the restriction with the NOCOPY is that its a hint to the compiler, and  not necessary that the compiler will be using it, so be careful while usin the NOCOPY option.

  
Login to rate this answer.
saishradha

Answered On : Nov 26th, 2008

View all answers by saishradha

Here is the answer in 1 lineIN-- value is used in a program.       It cannot be a variable .COuld be literal,expression,value .OUT-- value is returned back from the program to the caller.Must be a variable.IN OUT-- Its combination of IN and OUT as name suggests. It acts like a varible ie value can be used in the program and than can be returned back to the caller from the programHope you get some idea.Jai Sairam

  
Login to rate this answer.

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

Related Open Questions

Ads

Connect

twitter fb Linkedin GPlus RSS

Ads

Interview Question

 Ask Interview Question?

 

Latest Questions

Interview & Career Tips

Get invaluable Interview and Career Tips delivered directly to your inbox. Get your news alert set up today, Once you confirm your Email subscription, you will be able to download Job Inteview Questions Ebook . Please contact me if you there is any issue with the download.