Please help to call oracle procedure with out paramter from shell script
Hi
I want to call a process with out parameter from shell script. I am calling process in shell script in below way
function Process_loads {
( echo 'set serveroutput on size 1000000 arraysize 1'
echo "set pagesize 0 term on verify off feedback off echo off"
echo "BEGIN"
echo " dbms_output.put_line('Before Calling The package'); "
echo " x ( '$1', '$2', '$2', '$4', '$5', '$error_code'); "
echo " dbms_output.put_line('After Calling The package'); "
echo "EXCEPTION "
echo " WHEN OTHERS THEN "
echo " dbms_output.put_line('BIN_LOAD_ERROR' || SQLERRM); "
echo " ROLLBACK;"
echo "END;"
echo "/" ) | sqlplus -s $USER/$PASSWORD@$SID
Here $error_code is out paramter. All varaibles passed in process are declared with export command.
When executing .sh it gives below error
"sh ERROR at line 3: ORA-06550: line 3, column 99: PLS-00363: expression '' cannot be used as an assignment target ORA-06550: line 3, column 3: PL/SQL: Statement ignored".
Please help to get rid from this error or please suggest how to call a oracle procedure with out paramter from unix shell script.
Thanks in advance
You can try this:
From sql*plus
SQL> ed
1 create or replace procedure my_proc(p_id in int, p_result out int)
2 as
3 begin
4 select 10 * p_id
5 into p_result
6 from dual;
7* end my_proc;
SQL> /
Procedure created.
SQL> set serveroutput on
SQL> declare
2 v_r int;
3 begin
4 my_proc(10,v_r);
5 dbms_output.put_line(v_r);
6 end;
7 /
100
PL/SQL procedure successfully completed.
from bash:
testproc.sh:
#!/bin/bash
(echo 'set serveroutput on';
echo 'declare';
echo 'v_r int;';
echo 'begin';
echo 'my_proc(10,v_r);';
echo 'dbms_output.put_line(v_r);'
echo 'end;';
echo '/';) | sqlplus -s u1/u1
Console:
oracle@mob-ubuntu:~$ chmod u+x testproc.sh
oracle@mob-ubuntu:~$ ./testproc.sh
100
PL/SQL procedure successfully completed.With kind regards
Krystian Zieja
Similar Messages
-
About JDBC CALL STORE PROCEDURE with out parameter is greater than 4000
Hi Guys,
I have a problem call store procedure with a large string.
as i know varchar2 can contain 32767 characters in pl/sql .
But when i used varchar2 as a out parameter in a store procedure, if the out parameter is greater than 4000 characters , it always give me error message as 'the buffer is too small'.
why it happened?
I read some article that says i need configure a property in data-source.xml , and jdbc 10g driver already solved this problem, but i used jdev 10.1.3.2 ,the driver should be fine.
How can i solve this problem?
Thanks in advance,
AppCatObject is Foundation, Execute Script
This is for a query, you can change to a stored procedure call. Pull the value back in the Java code then put into the process variable.
import javax.naming.InitialContext;
import javax.sql.DataSource;
import java.sql.*;
PreparedStatement stmt = null;
Connection conn = null;
ResultSet rs = null;
try {
InitialContext ctx = new InitialContext();
DataSource ds = (DataSource) ctx.lookup("java:IDP_DS");
conn = ds.getConnection();
stmt = conn.prepareStatement("select FUBAR from TB_PT_FUBAR where PROCESS_INSTANCE_ID=?");
stmt.setLong(1, patExecContext.getProcessDataLongValue("/process_data/@inputID"));
rs = stmt.executeQuery();
rs.next();
patExecContext.setProcessDataStringValue("/process_data/outData", rs.getString(1));
} finally {
try {
rs.close();
} catch (Exception rse) {}
try {
stmt.close();
} catch (Exception sse) {}
try {
conn.close();
} catch (Exception cse) {} -
Calling Oracle Stored procedure with OUT parameter from ODI
Hi,
I called an oracle stored procedure with following anonymous block in the ODI procedure.
Declare
Status varchar2(10);
Begin
OTM.DeleteTarget('E_KPI_TARGET_VALUE', Status);
End;
I want to capture the OUT parameter STATUS value in a project level variable.
And based on its va;lue I would like to choose between 2 interfaces in my package.
Please help me in doing this.Hi,
For that kind of situation I commoly use:
1) one step with:
create or replace package <%=odiRef.getSchemaName("W")%>.pck_var
Status varchar2(10);
end;
* transaction 9, for instance
2) step
Begin
OTM.DeleteTarget('E_KPI_TARGET_VALUE', <%=odiRef.getSchemaName("W")%>.pck_var.Status);
End;
* transaction 9
3) then, at an ODI variable, use a refresh like:
select <%=odiRef.getSchemaName("W")%>.pck_var.Status from dual
at same logical shema where the package was created.
Does it make sense to you? -
Calling Oracle procedure with two OUT parameters
Hi I am having an Oracle procedure which return ref cursor. I also want to result one more out parameter result. How Can I call the procedure in SQL. Below is the way I am calling my stored procedure with one parameter.
proc_Test (p_resultset=> My_cursor)
How can I call the procedure when I have one more OUT parameter. Second parameter returns 0 or 1.
Thanks in advYes its possible to use multiple parameter as OUT type in procedure.
SQL>set serveroutput on size 1000000;
SQL>CREATE OR REPLACE PROCEDURE myproc(p_cv OUT SYS_REFCURSOR, p_num OUT NUMBER) AS
2 BEGIN
3 OPEN p_cv FOR SELECT 'Hello Oracle' sayhello FROM DUAL ;
4 p_num := 1;
5 END;
6 /
Procedure created.
SQL>VAR cv REFCURSOR;
SQL>VAR num NUMBER;
SQL>EXEC myproc(:cv, :num);
PL/SQL procedure successfully completed.
SQL>PRINT cv;
SAYHELLO
Hello Oracle
SQL>PRINT num;
NUM
1
SQL>
{code} -
Call stored procedure with OUT parameter
Hello,
I have created a short-lived process. Within this process I am using the "FOUNDATION > JDBC > Call Stored Procedure" operation to call an Oracle procedure. This procedure has 3 parameters, 2 IN and 1 OUT parameter.
The procedure is being executed correctly. Both IN parameters receive the correct values but I am unable to get the OUT parameter's value in my process.
Rewriting the procedure as a function gives me an ORA-01460 since one of the parameters contains XML (>32K) so this is not option...
Has someone been able to call a stored procedure with an OUT parameter?
Regards,
NicoObject is Foundation, Execute Script
This is for a query, you can change to a stored procedure call. Pull the value back in the Java code then put into the process variable.
import javax.naming.InitialContext;
import javax.sql.DataSource;
import java.sql.*;
PreparedStatement stmt = null;
Connection conn = null;
ResultSet rs = null;
try {
InitialContext ctx = new InitialContext();
DataSource ds = (DataSource) ctx.lookup("java:IDP_DS");
conn = ds.getConnection();
stmt = conn.prepareStatement("select FUBAR from TB_PT_FUBAR where PROCESS_INSTANCE_ID=?");
stmt.setLong(1, patExecContext.getProcessDataLongValue("/process_data/@inputID"));
rs = stmt.executeQuery();
rs.next();
patExecContext.setProcessDataStringValue("/process_data/outData", rs.getString(1));
} finally {
try {
rs.close();
} catch (Exception rse) {}
try {
stmt.close();
} catch (Exception sse) {}
try {
conn.close();
} catch (Exception cse) {} -
I need to download Facebook YouTube and Google search on my screen with all the programs I have apple ID but when I ask to load it say that this apple ID is not known by Tunis store so please I open my ID with out Visa card so as to use Tunis store with out Visa card because I am poor to have Visa card please help me soon!!! Thanks for your kind immediately support !!!!
If you follow, exactly, the instructions on the HT2534 page that you posted from when creating a new account (the instructions won't work with existing accounts) then you will get the 'none' option - I tried it earlier today on both my computer's iTunes and iPhone and I got 'none' for new accounts on both. If you don't use those instructions then credit card details will need to be entered before the account can be used in the store.
using a computer : https://discussions.apple.com/message/24321860
using an iPhone : https://discussions.apple.com/message/24700173
If you want to try using the same email address on a new account then you will need to replace it on that one first e.g. via the Store > View Account menu option on your computer's iTunes or http://appleid.apple.com -
Problems calling stored procedure with out ref cursors
Hi,
I am calling an oracle stored procedure and having problems. This is the code:
ResultSet cursor1, cursor2, cursor3, cursor4,cursor5,cursor6;
String sql = "BEGIN SYSADM.PKG_SERVICE.SERV_MAIN(:1,:2,:3,:4,:5,:6,:7,:8,:9) \n; END;";
CallableStatement call = null;
try
call = conn.prepareCall(sql);
call.setString(1,blah1);
call.setString(2,blah2);
call.setString(3,blah3);
call.registerOutParameter(4,OracleTypes.CURSOR);
call.registerOutParameter(5,OracleTypes.CURSOR);
call.registerOutParameter(6,OracleTypes.CURSOR);
call.registerOutParameter(7,OracleTypes.CURSOR);
call.registerOutParameter(8,OracleTypes.CURSOR);
call.registerOutParameter(9,OracleTypes.CURSOR);
call.execute();
cursor1 = ((OracleCallableStatement) call).getCursor(4);
cursor2 = ((OracleCallableStatement) call).getCursor(5);
cursor3 = ((OracleCallableStatement) call).getCursor(6);
cursor4 = ((OracleCallableStatement) call).getCursor(7);
cursor5 = ((OracleCallableStatement) call).getCursor(8);
cursor6 = ((OracleCallableStatement) call).getCursor(9);
on the cursor1 = line I get this exception:
06/08/08 15:07:01 java.lang.ClassCastException: com.evermind.sql.FilterCallableStatement
this is a web service running in JDeveloper 10.1.2
DennisDennis,
There is only one "data-sources.xml" file in my JDeveloper 10.1.3. It is in the "\j2ee\home\config" subdirectory.
But the again, I have not used my JDeveloper to create any Web services.
I really think you should try the JDeveloper and ADF forum.
Also, there are several debug properties you can set for OC4J.
Since you say you are using 10.1.2, the following Web page may be helpful:
http://www.oracle.com/technology/tech/java/oc4j/htdocs/oc4j-logging-debugging-technote.html
Good Luck,
Avi. -
Call Oracle procedure with custom data type within Java and Hibernate
I have a custom date TYPE in Oracle
like
CREATE TYPE DATEARRAY AS TABLE OF DATE;
and I have a Oracle function also
like
CREATE OR REPLACE FUNCTION doesContain (list DATEARRAY, val VARCHAR2) RETURN NUMBER
IS
END doesContain;
In my Java class,
I have a collection which contain a list of java.util.Date objects
When I call Oracle function "doesContain", how to pass my java collection to this Oracle function ...
anyone can provide solutions?
Please !!!
Thanks,
PulikkottilVu,
First of all you need to define your types as database types, for example:
create or replace type T_ID as table of number(5)Then you need to use the "oracle.sql.ARRAY" class. You can search this forum's archives for the term "ARRAY" in order to find more details and you can also find some samples via the JDBC Web page at the OTN Web site.
Good Luck,
Avi. -
Help in calling stored procedure with parameter in JSP
I need to know how to call this stored procedure in JSP
here is my Stored procedure in oracle 9i:
CREATE OR REPLACE procedure broker_activity
(p_broker_id IN number,p_TotalValue out number,p_CrossValue out number, p_blockValue out number, p_MktWeight out number,p_BuyingVal out number, p_sellingVal out number, p_NetValue out number)
AS
begin
declare
-- buying value
cursor c_BuyingVal is select buyer_firm, sum(volume*price) value from last_sale where buyer_firm = p_broker_id group by buyer_firm;
-- selling value
cursor c_SellingVal is select seller_firm,sum(volume*price) value from last_sale where seller_firm = p_broker_id group by seller_firm;
v_BuyingCurVal c_buyingVal%rowtype;
v_SellingCurVal c_sellingVal%rowtype;
n_buy_val number :=0;
n_sell_val number :=0;
n_total_value number := 0;
begin
--buying value
open c_BuyingVal;
fetch c_BuyingVal into v_buyingCurVal;
n_buy_val := nvl(n_buy_val,0) + v_buyingCurVal.value;
--Exit when c_BuyingVal%NOTFOUND;
close c_buyingVal;
p_BuyingVal := n_buy_val;
--selling value
open c_SellingVal;
fetch c_SellingVal into v_SellingCurVal;
n_sell_val := nvl(n_sell_val,0) + v_SellingCurVal.value;
-- Exit when c_BuyingFirm%NOTFOUND;
close c_SellingVal;
p_SellingVal := n_sell_val;
--total value
p_TotalValue := n_buy_val + n_sell_val;
--cross val
select sum(volume*price) into p_CrossValue from last_sale where board = 'C' and (buyer_firm = p_broker_id or seller_firm = p_broker_id);
--block Sale
select sum(volume*price) into p_BlockValue from last_sale where board = 'B' and (buyer_firm = p_broker_id or seller_firm = p_broker_id);
--Net Value
p_NetValue := n_buy_val - n_sell_val;
--markte_weight
select (sum(volume*price) * 2)/100 into p_MktWeight from last_sale ;
end;
end;http://developer.java.sun.com/developer/onlineTraining/Database/JDBC20Intro/JDBC20.html
-
Calling a procedure from Oracle Forms with OUT parameter
HI,
Can anyone tell me in detail how to call a procedure with OUT parameters from Oracle Forms 6i ?
Thanks in advance.Hello,
Just provide the out parameter in the call:
Declare
amount number; -- OUT number argument populated by the procedure
Begin
-- call the X procedure --
x( amount ) ;
End;Francois -
Calling a Stored Procedure with output parameters from Query Templates
This is same problem which Shalaka Khandekar logged earlier. This new thread gives the complete description about our problem. Please go through this problem and suggest us a feasible solution.
We encountered a problem while calling a stored procedure from MII Query Template as follows-
1. Stored Procedure is defined in a package. Procedure takes the below inputs and outputs.
a) Input1 - CLOB
b) Input2 - CLOB
c) Input3 - CLOB
d) Output1 - CLOB
e) Output2 - CLOB
f) Output3 - Varchar2
2. There are two ways to get the output back.
a) Using a Stored Procedure by declaring necessary OUT parameters.
b) Using a Function which returns a single value.
3. Consider we are using method 2-a. To call a Stored Procedure with OUT parameters from the Query Template we need to declare variables of
corresponding types and pass them to the Stored Procedure along with the necessary input parameters.
4. This method is not a solution to get output because we cannot declare variables of some type(CLOB, Varchar2) in Query Template.
5. Even though we are successful (step 4) in declaring the OUT variables in Query Template and passed it successfully to the procedure, but our procedure contains outputs which are of type CLOB. It means we are going to get data which is more than VARCHAR2 length which query template cannot return(Limit is 32767
characters)
6. So the method 2-a is ruled out.
7. Now consider method 2-b. Function returns only one value, but we have 3 different OUT values. Assume that we have appended them using a separator. This value is going to be more than 32767 characters which is again a problem with the query template(refer to point 5). So option 2-b is also ruled out.
Apart from above mentioned methods there is a work around. It is to create a temporary table in the database with above 3 OUT parameters along with a session specific column. We insert the output which we got from the procedure to the temporary table and use it further. As soon the usage of the data is completed we delete the current session specific data. So indirectly we call the table as a Session Table. This solution increases unnecessary load on the database.
Thanks in Advance.
RajeshRajesh,
please check if this following proposal could serve you.
Define the Query with mode FixedQueryWithOutput. In the package define a ref cursor as IN OUT parameter. To get your 3 values back, open the cursor in your procedure like "Select val1, val2, val3 from dual". Then the values should get into your query.
Here is an example how this could be defined.
Package:
type return_cur IS ref CURSOR;
Procedure:
PROCEDURE myProc(myReturnCur IN OUT return_cur) ...
OPEN myReturnCur FOR SELECT val1, val2, val3 FROM dual;
Query:
DECLARE
MYRETURNCUR myPackage.return_cur;
BEGIN
myPackage.myProc(
MYRETURNCUR => ?
END;
Good luck.
Michael -
Oracle Stored Procedure with out parameter
Good morning,
Is it possible to use an Oracle stored procedure with out parameters in MII ?
If yes, what is the manipulation to see the values of parameters Out?
Thank youMichael,
This is the MII query template :
DECLARE
STRCOMPTERENDU NVARCHAR2(200);
BEGIN
STRCOMPTERENDU := NULL;
XMII.SP_VALIDATEPROCESSORDERSLIST2 ( STRCOMPTERENDU => [Param.1] );
COMMIT;
END;
and the stocked procedure code
CREATE OR REPLACE PROCEDURE XMII.SP_ValidateProcessOrdersList2(strCompteRendu OUT nVarchar2) IS
tmpVar NUMBER;
debugmode INT;
strClauseSql varchar(2048);
strListPOactif varchar(1024);
dtmTimeStamp DATE;
NAME: SP_ValidateProcessOrdersList
PURPOSE:
REVISIONS:
Ver Date Author Description
1.0 18/06/2008 1. Created this procedure.
NOTES:
Automatically available Auto Replace Keywords:
Object Name: SP_ValidateProcessOrdersList
Sysdate: 18/06/2008
Date and Time: 18/06/2008, 18:45:32, and 18/06/2008 18:45:32
Username: (set in TOAD Options, Procedure Editor)
Table Name: (set in the "New PL/SQL Object" dialog)
BEGIN
tmpVar := 0;
debugmode := 0;
-- lecture date systeme pour time stamp
select sysdate into dtmTimeStamp from dual;
if debugmode = 1 then
DBMS_OUTPUT.put_line('SP_ValidateProcessOrdersList');
end if;
-- insertion du bloc dans le log
insert into LOG_ORDER
(DATE_ORDER,BLOCK_ORDER,ID_LOG_ORDER)
values
(dtmTimeStamp,'SP_ValidateProcessOrdersList',ID_LOG_ORDER.nextval);
Commit;
if debugmode = 1 then
DBMS_OUTPUT.put_line('insertion LOG OK');
end if;
strCompteRendu := '0123456-896;0123456-897';
commit;
EXCEPTION
WHEN NO_DATA_FOUND THEN
NULL;
WHEN OTHERS THEN
ROLLBACK;
-- insertion du bloc dans le log
insert into LOG_ORDER
(DATE_ORDER,BLOCK_ORDER,ID_LOG_ORDER)
values
(dtmTimeStamp,' ',ID_LOG_ORDER.nextval);
COMMIT;
-- Consider logging the error and then re-raise
RAISE;
END SP_ValidateProcessOrdersList2;
Thanks for your help
Alexandre -
Call procedure with MS SQL from linked Oracle server
I have a procedure on a remote server that I can call from SQL*PLUS
set serveroutput on
declare rez varchar2(99); msg varchar2(99); begin radar.test('AL25',rez,msg); dbms_output.put_line('Rez='||rez);
dbms_output.put_line('Msg='||msg);
end;
it gives me the neccessary result.
But I need to call the same procedure with MS SQL from a linked Oracle server, I'm trying to do it through openquery for a while, but no success yet.
Can someone tell me what is the right syntax for that query in OPENQUERY?Have you tried configuring Oracle Heterogenous Services/ Transparent Gateway? This would let you link Oracle to SQL Server via a database link which should solve your problem.
Justin
Distributed Database Consulting, Inc.
www.ddbcinc.com -
Problem in calling oracle procedure from java
Oracle procedure with the following parameters.
CREATE OR REPLACE PROCEDURE CREDITED_TO_STORE_INSERT (P_CUST# IN NUMBER,
P_INV_DATE IN DATE,
P_MEMO# IN NUMBER,
P_SESS_ID IN VARCHAR2 ) IS
BEGIN
/*.........Procedure Body with select and insert statements there no OUT or return variable/value......*/
END;
Now i am calling this procedure with the java code in java.
public boolean execProcedure(String storeNo, String invoiceDate, String claimNo, String sessionID) throws SQLException {
CallableStatement cstmt = null;
java.sql.Date invicDate = this.StringToDate(invoiceDate);
try
cstmt = conn.prepareCall("{call WEBUSER.CREDITED_TO_STORE_INSERT(?,?,?,?,?,?)}");
cstmt.setInt(1, Integer.parseInt(storeNo));
cstmt.setDate(2, invicDate);
cstmt.setInt(3, Integer.parseInt(claimNo));
cstmt.setString(4, sessionID);
cstmt.execute();
catch (Exception e)
System.out.println (e);
} // catch (Exception e)
finally
try
cstmt.close();
catch (Exception ex)
} // catch (Exception ex)
} // finally
return true;
But it will return the following exception.
[STDOUT] java.sql.SQLException: Missing IN or OUT parameter at index:: 5
i don't know why :( please help me ...your procedure has 4 parameters but in the prepared statement you define 6 placeholders
-
Problem to call stored procedure with several IN pars and single REF Cursor
Hi,
Oracle 9.2.0.1
Ole DB Provider I've got with ODP 9.2.0.4
First I try to call packaged procedure with single
REF CURSOR - it works fine(PROCEDURE getDep(dep OUT DEPART.refcur) IS ...).
When I try to call procedure with additional IN parameter, I get an error ORA-01008: not all variables bound.
Packaged procedure: PROCEDURE getDep(dep OUT DEPART.refcur, i1 IN number) IS .... and so on.
Try to call from C#:
cmd.CommandText = "{call depart.getDep(?)}";
OleDbParameter par0 = cmd.CreateParameter();
par0.Value = some value;
par0.DbType = DbType.Int16;
par0.OleDbType = OleDbType.Integer;
par0.Direction = ParameterDirection.Input;
OleDbDataAdapter da = new OleDbDataAdapter(cmd.CommandText,con);
DataSet ds = new DataSet();
da.Fill(ds);
Connection string:
"Provider=OraOLEDB.Oracle;User Id=scott;Password=tiger;Data Source=ora92;OLEDB.NET=true;PLSQLRSet=true"
Please, HELP !
Thanks in advance,
VyacheslavHi,
Are you using OLEDB.NET driver (System.Data.Oledb) or ODP.NET driver (Oracle.DataAccess)?
If you are using ODP.NET, remember that you need to bind the refcursor output variable also (besides the numbder)
Arnold
Maybe you are looking for
-
Windows 8.1 won't recgonize Z10
Have BBZ10 and recently purchased a new computer (Dell XPS 15). I tried to connect the phone to the computer and it will not recognize it despite trying various techniques on simular posts. My device connects to my other machine that runs 8.1 but t
-
Has anyone tried marble yet? FREE Navigation soft...
i just loaded it and tried it briefly...looks good for anyone that is looking for a replacement nav software! note: i am in no way affiliated with this software however it looks to be a good fit for the betterment of nokia n900 users. Linux Journal
-
FA Dependency on Payment Accounting
Hi Experts, As per the understanding that I have FA DW brings Payment Amounts only for Posted Invoices(Details are fetched from AP_PAYMENT_HISTS_DIST). This has dependency on accounting hence no payment amounts will appear in DW till the Accouting of
-
Windows 7 doesn't awaken with Ipod Nano 5G connected
Brand new HP computer w/Windows 7 and brand new Ipod Nano 5G. Left ipod connected to computer to charge. After computer powered down it would not restart. HP figured out that the Ipod was blocking the restart. If I unplug Ipod computer restarts fine.
-
Migration FOREX deals from Non-SAP system
Hi, has someone experience with migrating Treasury deals? > how did you migrate? > what tool/ transaction did you use? > what number of deals should there be to have automated update? > what problems could arise? > are there specific settings require