Getting return value from sql funtion
I have to following plsql.
declare x number;
begin
x := PK_GET_STUDENT_ID(parm1, parm2 parm3);
end;My question is how can I get the value of x so I can store it in a variable in side java? Please help.
How should this callable statement look? I thought I could just remove the declare statement and then replace "X :=" with "?=" but that will not work b/c if I do that then how is it supposed to know what to put in the second statment. Will someone please help me out on how I should make statement look? I know I have to register the variable before I execute the statement but how do this is done. Obiviously I know the registerOutParameter(...) but which ones do I need so I can execute this statement?
(PLSQL)
================
" DECLARE X NUMBER; "+
" BEGIN " +
" X := DOSOMETHING?,?,?,?,?,?,?,?,?,?,?,?,?); " +
" PK_CUSTOMER.ASSIGN_MAILING_CONTACT(?,?,X); " + "END; ";
Similar Messages
-
I have balance column and i need to pick only positive values from sql query.
Balance
200
-20
-220
100
Expected
Balance
200
100Hi Frank,
Sorry i think i am not clear.
below is my function get_total.
one billing_key is nothing but one billing period-each period has 6 programkeys.
by following function i will get 6 records by passing 6 programkeys and one biling key
now i need to get over all balance of all periods per program. condition is i need to take only +ve amounts from the below function and sum it up
expected out. i am just giving an example of output.
actual
programkey get_total
a 100
a -50
a -50
b 200
c 300
c -200
d -100
d -25
d 400
e 500
e -10
f 600
f -200
we are taking only +ve amounts from the above.
How can i write a procedure or script to acheive program_key and balance as below.
programkey balance
a 100
b 200
c 300
d 400
e 500
f 600
create or replace FUNCTION GET_TOTAL (p_bill_key IN varchar2,
p_prog_key IN varchar2) RETURN NUMBER AS
l_total NUMBER;
l_dum_bill NUMBER;
p_count NUMBER:=0;
BEGIN
BEGIN
SELECT count(*) into p_count
FROM billing_adjust b where b.billing_key = p_bill_key ;
if p_count < 1 then
SELECT NVL(surch_amount,0) + NVL(adjust_amount,0)
INTO l_total
FROM mv_billing a, mv_prog_surch b
WHERE a.billing_key = b.billing_key and
a.billing_key = p_bill_key and
b.program_key = p_prog_key;
return l_total ;
end if;
SELECT NVL(surch_amount,0) + NVL(adjust_amount,0)
INTO l_total
FROM billing_adjust b, prog_surch_adjust c
WHERE b.billing_adjust_key = c.billing_adjust_key and
b.billing_key = p_bill_key and
c.program_key = p_prog_key;
return l_total;
EXCEPTION
WHEN NO_DATA_FOUND THEN
null;
End;
RETURN 0;
END GET_TOTAL;
This is what i have started writing to acheive expected output need help on this.
Create or replace function balance(p_company_id) return number as
v_total_due number:=0;
v_total number:=0;
CURSOR p_idn IS
SELECT PROGRAM_KEY,PROGRAM_NAME FROM MV_PROGRAM_DICT where CURRENT_YN = 'Y' order by PROGRAM_NAME_ID;
cursor p_billkey_idn is
select biling_key from billing where company_id=p_company_id;
Begin
for v_idn in p_idn loop
for v_billkey in p_billkey loop
SELECT sum(get_total(v_billkey.billing_key,v_idn.program_key)) into balance
FROM dual
WHERE get_total(v_billkey.billing_key,v_idn.program_key)>0;
END LOOP;
END loop; -
How to get return values from stored procedure to ssis packge?
Hi,
I need returnn values from my stored procedure to ssis package -
My procedure look like and ssis package .Kindly help me to oget returnn value to my ssis package
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
-- =============================================
-- Author: <Author,,Name>
-- Create date: <Create Date,,>
-- Description: <Description,,>
-- =============================================
ALTER PROCEDURE [TSC]
-- Add the parameters for the stored procedure here
@P_STAGE VARCHAR(2000)
AS
BEGIN
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
SET NOCOUNT ON;
-- Insert statements for procedure here
--SELECT <@Param1, sysname, @p1>, <@Param2, sysname, @p2>
truncate table [INPUTS];
INSERT
INTO
[INPUTS_BASE]
SELECT
[COLUMN]
FROM [INPUTS];
RETURN
END
and i am trying to get the return value from execute sql task and shown below
and i am taking my returnn value to result set variableYou need to have either OUTPUT parameters or use RETURN statement to return a value in stored procedures. RETURN can only return integer values whereas OUTPUT parameters can be of any type
First modify your procedure to define return value or OUTPUT parameter based on requirement
for details see
http://www.sqlteam.com/article/stored-procedures-returning-data
Once that is done in SSIS call sp from Execute SQL Task and in parameter mapping tabe shown above add required parameters and map them to variables created in SSIS and select Direction as Output or Return Value based on what option you used in your
procedure.
Please Mark This As Answer if it helps to solve the issue Visakh ---------------------------- http://visakhm.blogspot.com/ https://www.facebook.com/VmBlogs -
How to get return value from Java runtime.getRuntime.exec?
I'm running shell commands from an Oracle db (11gr2) on aix.
But, I would like to get a return value from a shell comand... like you get with "echo $?"
I use a code like
CREATE OR REPLACE JAVA SOURCE NAMED common."Host" AS
import java.io.*;
public class Host {
public static int executeCommand(String command) {
int retval=0;
try {
String[] finalCommand;
finalCommand = new String[3];
finalCommand[0] = "/bin/sh";
finalCommand[1] = "-c";
finalCommand[2] = command;
final Process pr = Runtime.getRuntime().exec(finalCommand);
pr.waitFor();
catch (Exception ex) {
System.out.println(ex.getLocalizedMessage());
retval=-1;
return retval;
/but I do not get a return value... because I don't know how to get return value..
Edited by: user9158455 on 22-Sep-2010 07:33Hi,
Have your tried pr.exitValue() ?
I think you also need a finally block that destroys the subprocess
Regards
Peter -
Getting Return values from RFC function call with visual basic
Hi,
I am creating a sample app to connect to a SAP system which call its RFC functions created with ABAP. It was known that the function will return more than 1 return values.
SAP Function name ==> "ZFMTP_RFC_GET_RESULT"
Export parameters (to SAP):
- Student Name [char 10] ==> "STUNAME"
- Student ID [char 20] ==> "STUID"
Return values (From SAP):
- Results [char 10] ==> "RESULT"
- Remarks [char 200] ==> "REMARKS"
i have managed to get sample codes for connecting and call a RFC function with vb but they only get a return value. How do i retrieve multiple return values like the above function "RESULT" and "REMARKS"?
Here's my vb code to accessing the function
Dim R3 As Object
Dim FBFunc As Object
Dim returnFunc As Boolean
Dim connected As Boolean
R3 = CreateObject("SAP.Functions")
R3.Connection.Client = "000"
R3.Connection.User = "BCUSER"
R3.Connection.Password = "minisap"
R3.Connection.Language = "DE"
R3.Connection.System = "dtsystem"
R3.Connection.Applicationserver = "xxx.xxx.xxx.xxx"
connected = R3.Connection.Logon(0, True)
If connected <> True Then
MsgBox("Unable to connect to SAP")
End If
FBFunc = R3.add("ZFMTP_RFC_GET_RESULT")
FBFunc.exports("STUNAME") = "Jonny"
FBFunc.exports("STUID") = "12345"
returnFunc = FBFunc.Call() <<== How do i get the return value? or RESULT and REMARKS of the RFC Function?
thanks alot.
Edited by: Eugene Tan on Mar 4, 2008 7:17 AMHi Gregor,
Thanks for the link....i am having some doubts with the codes, hope you can clarify them for me if you know the codes..
Below is the code snippet.
Set impReturn = CHPASS_FN.Imports("RETURN") <<=== is RETURN the standard keyword to get a return object?
expPassword.Value = currpass
expNewPass.Value = newpass
expFillRet.Value = "1"
''' Call change password function
If CHPASS_FN.Call = True Then
outFile.Write (", Called Function")
Message = impReturn("MESSAGE") <<==== So if i have 3 return values..i just replace with the return value variable names?
outFile.WriteLine " : " & Message
Else
outFile.Write (", Call to function failed")
End If
thanks alot...all your help is very appreciated. -
How to get return value from java and read by other application?
i want to read return value from java and the other application read it.
for example:
public class test_return {
test_return(){
public int check(){
return 1;
public static void main(String args[]){
new test_return().check();
}from that class i make as jar file. How to read the return value (1) by other application?
thx..If your installer is requiring some process it invokes to return a particular value on failure, then the installer is seriously broken. There are a bazillion commands your installer could invoke, and any of them could fail, which in turn could invalidate the entire install process, and any of them could return any value on failure. The only value that's consistent (in my experience) is that zero means success and non-zero means failure, with specific non-zero values being different in different programs.
About the only control you have over the JVM's exit code is that if your main method completes without throwing an exception, the JVM will have an exit code of 0, and if main throws an exception (either explicitly or by not catching one thrown from below), it will be non-zero. I'm not even sure if that's guaranteed, but I would guess that's the case.
EDIT: I'm kind of full of crap here. If you're writing the Java code, you can call System.exit(whatever). But nonetheless, if your installer requires certain exit codes from any app--java or otherwise--you have a problem.
Edited by: jverd on Oct 29, 2009 1:27 AM -
Error getting return value from function
Hello
I'm getting a error calling a function with ODP.NET from C#
Code:
OracleCommand oraCom = new OracleCommand("NORMALIZACION.nif",oraCon);
oraCom.CommandType = CommandType.StoredProcedure;
OracleParameter param1 = new OracleParameter("numnif",OracleDbType.Varchar2);
param1.Value= "73667866A";
param1.Direction = ParameterDirection.Input;
OracleParameter param2 = new OracleParameter("nif",OracleDbType.Varchar2);
param2.Size = 10; //FIXME line
param2.Direction = ParameterDirection.ReturnValue;
oraCom.Parameters.Add(param1);
oraCom.Parameters.Add(param2);
oraCom.ExecuteNonQuery();
nif_norm = oraCom.Parameters["nif"].Value.ToString();
if i write the FIXME line i get a error (ORA-06502) complaining about the size, no matter the value i wrote.
If i don't write the FIXME line, it works but nif_norm is always empty, although the function i call is a single return 'Hello';
Where am I wrong??
Any help, examples with varchar2 as return value???
BTW: the same code with the MS provider for Oracle works fine.Good point -- i shall do so.
What I think I'm missing, in my quest for ODP.NET competence, is a solid set of example code. I've searched around and found various fragements here and there, but when it comes to data access from .NET there must surely be some finitie set of possibilities (if we can discount bad practices like building dynamic SQL statements without bind variables).
For example, possibly in increasing order of complexity ...
* Read a single value from a SQL statement ... "select emp_name from emp where rownum < 2"
* Read a single value by passing in a parameter ... "select emp_name from emp where user_id = :?"
* read multiple values ... "select emp_name from emp where user_id in (:?,:?)"
* execute a stored procedure with no in or out parameters
* retreive a value from a function with no parameters
* pass a parameter to a stored procedure
* read an out parameter from a stored procedure
Then work with in and out ref cursors, blobs, whatever.
Thoughts? -
Getting return value from sqlplus script while running a unix job
I am trying to run a unix script that calls sqlplus. The following code outlines the unix/sql code that I trying to execute:
return_count=`sqlplus $ORACLE_ID/$ORACLE_PWD@$ORACLE_SID <<EOF | grep '^RETURN_VAL' | sed 's/^RETURN_VAL//'
SET SERVEROUTPUT ON
VARIABLE ReturnValue NUMBER
EXEC :ReturnValue := 1
BEGIN
UPDATE seq_control_nbr
SET table_seq_nbr = table_seq_nbr + 1,
last_updt_dttmstp = systimestamp,
last_updt_user_id = 'ECVMSONS'
WHERE table_key = 'ONSTAR';
IF SQL%ROWCOUNT = 1 THEN
COMMIT;
:ReturnValue := 0;
ELSE
ROLLBACK;
:ReturnValue := 99;
END IF;
DBMS_OUTPUT.PUT_LINE ('RETURN_VAL '||:ReturnValue);
END;
EXIT
EOF`
The above outlined sqlplus script does run because the values on the table are updated. However, I cannot get the value of ReturnValue to be displayed, so it can be returned to the unix script.
Any ideas?ok do the following:-
return_count=`sqlplus $ORACLE_ID/$ORACLE_PWD@$ORACLE_SID <<EOF
SET SERVEROUTPUT ON
whenever OSERROR exit 1
whenever SQLERROR exit 2
UPDATE seq_control_nbr
SET table_seq_nbr = table_seq_nbr + 1,
last_updt_dttmstp = systimestamp,
last_updt_user_id = 'ECVMSONS'
WHERE table_key = 'ONSTAR';
EXIT
EOF`
rowsupdated=`echo $return_count|cut -f1 -d' '`
echo "Rows updated =" $rowsupdated
retcode=`echo $?`
case "$retcode" in
0) echo "Update executed successfully on " ;;
1) echo "Update failed OSERROR ";;
2) echo "Update failed SQLError " ;;
*) echo "Update failed - Unknown Error ";;
esac -
Getting return value from webengine.executescript when embedded in Swing
Hi,
Got a WebView embedded through a JFXPanel in a Swing app. I'm now trying to get some value back from the WebEngine.executeScript method in a synchronous way.
All examples I can find on Swing embedding use Platform.runLater, which of course doesn't return the value straight away.
Through some digging I found PlatformImpl.runAndWait(Runnable) and when I use that I do get a synchronous call and thus the return value of Webengine.executeScript immediately.
Question now is if it's save for me to use PlatformImpl.runAndWait(Runnable) or if I should refrain from using it for some reason. I wasn't able to find anything on the topic, but so far in my tests if seems to work fine.
Only thing I found were 2 implementations of sort of the same functionality: http://www.guigarage.com/2013/01/invokeandwait-for-javafx/ and https://code.google.com/p/jacp/source/browse/branches/working/JACP.JavaFX/src/main/java/org/jacp/javafx/rcp/worker/AFXComponentWorker.java (invokeOnFXThreadAndWait method)
TIA,
K.Using the impl method for run and wait is not advised as it may be removed in a future JavaFX version.
However you can easily copy the source of this simple method to create your own implementation:
See the following thread for details:
http://markmail.org/message/kaui2t34ufx3vdwe
Note that in making what is normally an asynchronous call synchronous, you must be careful to avoid deadlock and UI freezing performance issues. -
How to get return values from task flow in af:region ?
Hi!
I'm working with a taskFlow that is rendered inside a popup using the "popup inside a region pattern" (http://www.oracle.com/technology/products/adf/patterns/popupregionpattern.pdf), but now this taskFlow has an input parameter and a return value definition. So the question is how to get a value returned by this taskFlow thas is called inside a region?
Any suggestion?
Thanks in advance!Hi,
write the value to a shared memory scope like session and read it in the regionNavigation listener. If you follow the paper you refer to then the listener determines of the viewId is null, this a return happens. It wuld then look in the memory scope for the return value.
Another option would be to use an object that you pass as an argument to the task flow you open in the popup. Then you change the object you passed in, which then makes the return information available in teh calling flow. The object you pass in would have to be in a shared scope too
Frank -
How to get return values from region?
I add a page flow as region into a page. The page flow has a return parameter. How to get the return value in parent page?
I have been also intrigued by this question.
There is however a workaround that you can set the values in requestScope.
We can have a regionNavigationListener on the region and catch the end of taskflow if viewid is null.
regionNavigationEvent.getNewViewId() == null
Here we can read the request values and set wherever to be used.
maniesh (sid) -
How to get return values from a button to main program.
hello,
I have a main program which has a button Authenticate. On click of authenticate open a form for auth which has USERNAME FIELS AND PASSWORD.
If entered fields are true then enable editing of jtable in main program..
Basically something like this :
//main program
Authenticate.addActionListener(new ActionListener()
public void actionPerformed(ActionEvent ae)
UpdateAuth ua=new UpdateAuth();// opens form which has username and pass for authentication
ua.setVisible(true);
//need code here for enabling table
if(s=="mactus")
enable table editing
//table.repaint();
// form open for auth..(class UpdateAuth )
private String SigninMouseClicked(java.awt.event.MouseEvent evt) {
String aname=Aname.getText();
String apass=Apassword.getText();
if(aname.equals("") && apass.equals(""))
JOptionPane.showMessageDialog(null,"Enter login name or password","Error",JOptionPane.ERROR_MESSAGE);
if(!(aname.equals("") && apass.equals("")))
if(aname.equals("harshil") && apass.equals("harshil123"))
String s="mactus"; /// if username and password is success enable table editing in main program
return s;
else if (!aname.equals("mactus") && !apass.equals("mactus123"))
Aname.setText("");
Apassword.setText("");
return null;
}986154 wrote:
hello,
I have a main program which has a button Authenticate. On click of authenticate open a form for auth which has USERNAME FIELS AND PASSWORD.
If entered fields are true then enable editing of jtable in main program..Well, you might be in over your head.
//need code here for enabling table
if(s=="mactus") If you don't know how to correctly test for String equality, you will have no chance of getting this to work.
You need to hit the tutorials. First the basic one, then the Swing one. -
How to get a value from JavaScript
How to get return value from Java Script and catch it in c++ code. I have tried following code, but its not working in my case.
what I want is if it returns true then call some function if it returns false then do nothing, so how to get those values in c++
ScriptData::ScriptDataType fDataType = resultData.GetType();
if (fDataType == kTrue)
CAlert::InformationAlert("sucess");
//call some function
else
CAlert::InformationAlert("Error");
// do nothing
JavaScript Code:
if(app.scriptArgs.isDefined("paramkeyname1"))
var value = app.scriptArgs.get("paramkeyname1");
alert(value);
return true;
else
alert ("SORRY");
return false;How to get java script result into JSResult i m not getting it.
I have wriiten follwing code in c++ :
WideString scriptPath("\\InDesign\\Source1.jsx");
IDFile scriptFile(scriptPath);
InterfacePtr<IScriptRunner>scriptRunner(Utils<IScriptUtils>()->QueryScriptRunner(scriptFi le));
if(scriptRunner)
ScriptRecordData arguments;
ScriptIDValuePair arg;
ScriptID aID;
ScriptData script(scriptFile);
ScriptData resultData;
PMString errorString;
KeyValuePair<ScriptID,ScriptData> ScriptIDValuePair(aID,script);
arguments.push_back(ScriptIDValuePair);
PMString paramkeyname1;
Utils<IScriptArgs>()->Save();
Utils<IScriptArgs>()->Set("paramkeyname1",scriptPath);
Utils<IScriptUtils>()->DispatchScriptRunner(scriptRunner,script,arguments,resultData,erro rString,kFalse);
Utils<IScriptArgs>()->Restore();
ScriptData::ScriptDataType fDataType = resultData.GetType(); // here i should get true or false which i m passing it from javascript code......not as s_boolean
if (fDataType == kTrue)
//CAlert::InformationAlert("sucess");
iOrigActionComponent->DoAction(ac, actionID, mousePoint, widget);
else
this->PreProcess(PMString(kCstAFltAboutBoxStringKey));
Java script code:
function main()
var scrpt_var;
var scriptPath,scrptMsg;
var frntDoc=app.documents[0];
if(app.scriptArgs.isDefined("paramkeyname1"))
var value = app.scriptArgs.get("paramkeyname1");
alert(value);
return true; // i want this value i should get in c++ code...How to get these values in c++
else
alert ("Error");
return false; // i want this value i should get in c++ code...How to get these values in c++ -
Get a return value from a stored procedure.
hi all ,
i need to know where i am going wrong with the below code. I am trying to get a value from a stored procedure. the return type is int. The stored procedure works fine as i've debugged it. The variable have been declared correctly.
int n = 0;
proc = conn.prepareCall("{ ? = call SP_GETITEMCURRENTSOH(?,?) }");
proc.registerOutParameter(1, java.sql.Types.INTEGER);
proc.setString(1, locationCode);
proc.setString(2, itemCode);
proc.execute();
n = proc.getInt(1);thanksHi ayub_a,
According the [ *setString*|http://java.sun.com/javase/6/docs/api/java/sql/CallableStatement.html#setString(java.lang.String,%20java.lang.String)] method of the [*CallableStatement*|http://java.sun.com/javase/6/docs/api/java/sql/CallableStatement.html] interface, the first parameter must be a parameter name and not an ordinal position index !!!
Edit : I've just found out the solution, it must be :
int n = 0;
proc = conn.prepareCall("{ ? = call SP_GETITEMCURRENTSOH(?,?) }");
proc.registerOutParameter(1, java.sql.Types.INTEGER);
proc.setString(2, locationCode);
proc.setString(3, itemCode);
proc.execute();
n = proc.getInt(1);Edited by: Chicon on Jul 5, 2009 7:48 PM -
How to get the return values from a web page
Hi all :
how to get the return values from a web page ? I mean how pass values betwen webflow and web page ?
thank you very much
Edited by: jingying Sony on Apr 15, 2010 6:15 AM
Edited by: jingying Sony on Apr 15, 2010 6:18 AMHi,
What kind of web page do you have? Do you have possibility to for example make RFCs? Then you could trigger events (with parameters that could "return" the values) and the workflow could react to those events. For example your task can have terminating events.
Regards,
Karri
Maybe you are looking for
-
Dear support @Apple, I have tried to log in App Store with my Apple ID 3 times but never possible. I have tried to change password 2 times. It was successful.But soon after change of my password, I could not log in App store. It says always incorrect
-
How do I upload a form to my website using form central?
How do I upload a form to my website using form central?
-
Install problems with newest version of Mirgation Workbench
I have installed migration workbench both in its own home and in a 9.2 home. In both cases the workbench won't start (no error message). I have checked the omwb bat file and it points correctly to an existing JRE 1.3.1 on C:drive This behaviour is co
-
Corrections on legacy takeover value assets
Hello, I have posted a correction on a asset GL account related to the takeover values via FB50L is this ok or should I done that via OASV? So do i need to reverse the initial document and redo it via OASV? Thanks for advice
-
Any of the download would show the u201C PO numberu201D on the sales order.
Hi All, Please let me know if any of the download would show the u201C PO numberu201D on the sales order. Aditya