How to get CLOB from stored procedure via StoredProcedureCall
hi all
I got "sp" on server : procedure get_text(p_in in varchar2, o_list out clob);
in code:
StoredProcedureCall call = new StoredProcedureCall();
call.setProcedureName("get_text");
call.addNamedArgumentValue("p_in", new String("MyList"));
call.addNamedOutputArgument("o_list"); // <- out CLOB
Vector v = (Vector)this.m_UnitOfWorkt.executeSelectingCall( call ); // <- here I got error
but if o_list is varchar is all ok
so how to get data from clob?
Please help
Regards
Krzysztof
Post Author: achaithanya
CA Forum: Data Connectivity and SQL
I'm connecting to database through stored procedure only.We have sybase installed on our local system so that we are given permissions only to access the stored procedures.When u see the fields in CR XI i.e Field explorer you are able to see only 1st result fileds.I connected to sybase and there i'm able to see the output of 1st & 2nd Result set.
Regards,
Chaithanya.
Similar Messages
-
JDBC - How to Get Data from Stored Procedure?
Gurus,
I am using Oracle Thin JDBC driver. A stored procedure has an IN parameter and an OUT parameter. The type of OUT parameter is TABLE of RECORD which is defined in the PL/SQL package in which the stored procedure is included. My question is if there is any way to call this stored procedure and process the data returned by the OUT parameter in my Java code.
Thanks.
Larrydefine in the pl/sql block as a cursor
register the out parameter as an oracle.cursor
on the java program get an object (from the statement), casting it to an resultset and then you can work on it -
How to get BOOLEAN from STORED FUNCTION
We are calling legacy PLSQL stored procedures and functions via named queries. This has worked fine so far, but there are some functions which return the type 'BOOLEAN'. e.g.
FUNCTION some_function( some_argument IN NUMBER) RETURN BOOLEAN;
Where the return type is BOOLEAN calling the named query fails with
Local Exception Stack:
Exception [TOPLINK-4002] (Oracle TopLink - 10g Release 3 (10.1.3.0.0) (Build 060118)): oracle.toplink.exceptions.DatabaseException
Internal Exception: java.sql.SQLException: ORA-06550: line 1, column 13:
PLS-00382: expression is of wrong type
ORA-06550: line 1, column 7:
PL/SQL: Statement ignored
Error Code: 6550
A couple of threads have hinted that what we are trying to do is not possible:
How to get BOOLEAN from STORED PROCEDURES
Re: Creating Named Query: from OracleCallableStatement
This would possibly be due to 'restriction in the OCI layer'. Can anyone help? Is there really now way to call a valid PLSQL stored function via a named query when the return type is BOOLEAN?
thanksI can't comment on possible issues you might have with the driver, but if it can be done in JDBC, it should be possible in TopLink.
TopLink has the StoredFunctionCall which extends the StoredProcedureCall but adds an unnamed ouput parameter in the first spot of its parameter list. You will need to get the databasefield and set its type to BOOLEAN ie:
DatabaseField returnField = (DatabaseField)yourStoredFunctionCall.getParameters().firstElement();
returnField.setName(name);
returnField.setSqlType(Type.BOOLEAN);Be sure not to use the setType() method, as I believe TopLink will try to use the Type.BIT when a boolean class is used as the classtype.
Best Regards,
Chris -
How to get resultset from oracle procedure use ejb3
how to get resultset from oracle procedure use ejb3
i know oracle procedure should like this
Create or replace PROCEDURE resultset_test(
aaa IN NUMBER,
bbb OUT sys_refcursor) ....
but what s the ejb3 scripts looks like? please give me an example or link~
ths- there are no EJB3 scripts, only compiled application code
- the part of the EJB spec that deals with databases is called the Java Persistence API, but likely you are just looking for the JDBC API.
Now you should know what to Google to get your "example script": "java jdbc oracle procedure" -
How to output value from stored procedure
Hi folks, I need to output the OrderFK from a stored procedure not really sure how to achieve this any help or tips much appreciated.
Sql code below
USE [TyreSanner]
GO
/****** Object: StoredProcedure [dbo].[AddCustomerDetails] Script Date: 11/12/2014 20:56:34 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER PROCEDURE [dbo].[AddCustomerDetails]
/***********************Declare variables ***********************/
/******tblCustomer******/
@Forename nvarchar(50),
@Surname nvarchar(50),
@HouseNo nvarchar(50),
@CustAddress nvarchar(50),
@Town nvarchar(50),
@Postcode nvarchar(50),
@ContactNo nvarchar(50),
@EmailAddress nvarchar(50),
/******tblLink_OrderProduct******/
@ProductQuantity int,
@TotalProductSaleCost decimal,
@ProductFK int,
@FittingDate date,
@FittingTime Time
As
DECLARE @CustomerFK int;
DECLARE @OrderFK int;
Begin TRANSACTION
SET NOCOUNT ON
INSERT INTO [TyreSanner].[dbo].[Customer](Forename, Surname, HouseNo, CustAddress, Town, Postcode, ContactNo, EmailAddress)
VALUES (@Forename,@Surname,@HouseNo,@CustAddress,@Town,@Postcode,@ContactNo,@EmailAddress)
Set @CustomerFK = SCOPE_IDENTITY()
INSERT INTO [TyreSanner].[dbo].[Order] (CustomerFK)
VALUES (@CustomerFK)
SET @OrderFK = SCOPE_IDENTITY()
INSERT INTO [TyreSanner].[dbo].[Link_OrderProduct](OrderFK, ProductFK, ProductQuantity, TotalProductSaleCost, FittingDate, FittingTime)
VALUES
(@OrderFK, @ProductFK, @ProductQuantity, @TotalProductSaleCost, @FittingDate, @FittingTime)
COMMIT TRANSACTIONHi brucey54,
There’re several ways to capture the value from a Stored Procedure. In you scenario, I would suggest 2 options, by an output parameter or by a table variable.
By an output Parameter, you need to make a little bit modification on your code as below:
USE [TyreSanner]
GO
ALTER PROCEDURE [dbo].[AddCustomerDetails]
@Forename nvarchar(50),
@FittingDate date,
@FittingTime Time,
@OrderFK int output
As
DECLARE @CustomerFK int;
--DECLARE @OrderFK int;
Run the following code, Then @OrderFKvalue holds the value you’d like.
DECLARE @OrderFKvalue int;
EXEC AddCustomerDetails(your parameters,@OrderFKvalue output)
Anyway if you don’t like to add one more parameter, you can get the value by a table variable as well. Please append “SELECT @OrderFK;” to your Procedure as below:
USE [TyreSanner]
GO
ALTER PROCEDURE [dbo].[AddCustomerDetails]
SET @OrderFK = SCOPE_IDENTITY()
INSERT INTO [TyreSanner].[dbo].[Link_OrderProduct](OrderFK, ProductFK, ProductQuantity, TotalProductSaleCost, FittingDate, FittingTime)
VALUES
(@OrderFK, @ProductFK, @ProductQuantity, @TotalProductSaleCost, @FittingDate, @FittingTime);
SELECT @OrderFK;
Then you can call the Stored Procedure as below:
DECLARE @T TABLE (OrderFK INT);
INSERT @T EXEC AddCustomerDetails(your parameters) ;
SELECT OrderFK FROM @T;
There’re more options to achieve your requirement, please see the below link:
How to Share Data between Stored Procedures
If you have any question, feel free to let me know.
Best Regards,
Eric Zhang -
How to get the correct stored procedure in oracle
Hi sir,
i am having one stored procedure which i converted from sql it's compiled successfully.
create or replace
PROCEDURE Spvalidateholiday1
v_pidate1 IN Date DEFAULT NULL ,
v_piEmpid IN VARCHAR2 DEFAULT NULL ,
v_pidate2 IN Date DEFAULT NULL ,
v_poRetVal OUT Number
--RETURN NUMBER
AS
v_date3 VARCHAR2(20);
v_date4 VARCHAR2(20);
v_date5 VARCHAR2(40);
v_date6 VARCHAR2(40);
v_scode VARCHAR2(10);
v_dayoff1 VARCHAR2(20);
v_dayoff2 VARCHAR2(20);
BEGIN
v_date5 := To_Char(To_Date(v_pidate1,'YYYY-MM-DD','D'));
v_date6 := To_Char(To_Date(v_pidate2,'YYYY-MM-DD','D')) ;
SELECT Shift_Code
INTO v_scode
FROM Employee
WHERE Emp_ID = v_piEmpid;
SELECT WeeklyOff1
INTO v_dayoff1
FROM Shift
WHERE Shift_Code = v_scode;
SELECT WeeklyOff2
INTO v_dayoff2
FROM Shift
WHERE Shift_Code = v_scode;
SELECT dayid
INTO v_date3
FROM Weekly
WHERE dayss = v_dayoff1;
SELECT dayid
INTO v_date4
FROM Weekly
WHERE dayss = v_dayoff2;
--select @date3=dayid from Weekly w join Site_Param s on w.dayss=s.WeeklyOff1
--select @date4=dayid from Weekly w join Site_Param s on w.dayss=s.WeeklyOff2
IF ( v_date5 = v_date3
OR v_date6 = v_date4
OR v_date4 = v_date5
OR v_date3 = v_date6 ) THEN
BEGIN
v_poRetVal := 0 ;
END;
ELSE
BEGIN
v_poRetVal := 1 ;
END;
END IF;
RETURN; --v_poRetVal;
END;
but getting error:
ORA-06550: line 1, column 7: PLS-00306: wrong number or types of arguments in call to 'SPVALIDATEHOLIDAY1' ORA-06550: line 1, column 7: PL/SQL: Statement
could u check the stored procedure?
thanksHi sir,
i am calling it my application
that is used like this
Dim hshParam As New Hashtable
hshParam.Add("Empid", '00000002')
hshParam.Add("date1", '2012-10-25')
hshParam.Add("date2", '2012-10-27')
intRetProc = objDataTier.ExecuteStoredProcedureWithReturnT("Spvalidateholiday1", hshParam)
and here is this method written:
Public Function ExecuteStoredProcedureWithReturnT(ByVal sStroredProcedureName As String, ByVal phshTbl As Hashtable) As Integer
Dim cmdCommand As OracleCommand
Dim prmParmOutput As OracleParameter
Dim pParam As IDictionaryEnumerator = phshTbl.GetEnumerator
Dim sKey As String, sValue As String
Try
ExecuteStoredProcedureWithReturnT = True
OpenDbConnection()
cmdCommand = New OracleCommand(sStroredProcedureName, conConnection)
cmdCommand.CommandType = CommandType.StoredProcedure
cmdCommand.CommandTimeout = 0
While pParam.MoveNext
sKey = "v_pi" & pParam.Key
sValue = pParam.Value
cmdCommand.Parameters.Add(New OracleParameter(sKey, sValue))
End While
prmParmOutput = New OracleParameter
cmdCommand.Parameters.Add(New OracleParameter("v_poRetVal", SqlDbType.Int)).Direction = ParameterDirection.Output
' If
cmdCommand.ExecuteNonQuery()
ExecuteStoredProcedureWithReturnT = CInt(cmdCommand.Parameters("v_poRetVal").Value)
Catch ex As Exception
ExecuteStoredProcedureWithReturnT = 2
Throw ex
End Try
End Function
now tell me is it correct? -
How to retrieve exception in stored procedure via JDBC?
Hi all,
In many cases, my JDBC call to stored procedure returns sucessfully without any SQLException, but the operations failed due to exception within the stored procedure (eg multiple rows returned for SELECT INTO).
I can see these exception when running interactive in SQLPlus, but JDBC doesn't throw them.
So does anyone know how to track these exception in stored procedure?
Many thanks.Is your stored procedure catching these exceptions? If so, it may be failing to re-throw them.
Justin -
Getting resultset from stored procedures..
hi all,
i have got some very fundamental doubts regarding Oracle Stored Procedures and calling it from java.. i want the resultset to be returned from sp and for that i used to following sp and java code.
package
====
CREATE OR REPLACE package
curs_types as
type EmpCurType is REF CURSOR RETURN emp%ROWTYPE;
end curs_types;
procedure
======
procedure
single_cursor(curs1 IN OUT curs_types.EmpCurType)
AS
BEGIN
OPEN curs1 FOR SELECT * FROM emp;
END single_cursor;
java code for calling sp
=========
String sql = "{call single_cursor(?)}";
CallableStatement cstmt1 = con.prepareCall(sql);
cstmt1.registerOutParameter(1, OracleTypes.CURSOR);
cstmt1.execute();
rs = (ResultSet)cstmt1.getObject(1);
while(rs.next())
{ String empno=(String)rs.getString(1);
and it worked properly but the problem is i dont want all the fields from the table emp..i mean, if i change the query inside the sp from "select * from emp" to "select ename,empno from emp" then that sp is showing compilation errors.. is it possile to return a cursor from sp that contains specific fields ??
wat is the procedure to return a cursor that contain datas from multiple tables ???
can any1 help me with this ??? plz mail me on [email protected]
thanks in advance
raj.>
and it worked properly but the problem is i dont want
all the fields from the table emp..i mean, if i
change the query inside the sp from "select * from
emp" to "select ename,empno from emp" then that sp is
showing compilation errors.. You have a cursor with specific fields, so you have to fill all of them in.
is it possile to return
a cursor from sp that contains specific fields ??
Yes. See your Oracle docs.
wat is the procedure to return a cursor that contain
datas from multiple tables ???Yes. Same as a select from multiple tables. -
How to get pictures from a usb via a bluetooth keyboard
I have a bluetooth keyboard that has a USB slot but when I plug a USB stick in I cant work out how to upload pictures. I have tried everything and Im thinking I need an app?
Can someone please help me?
xI sincerely doubt that'll work. TO make it work you'd need some sort of file manager on the iPad.
Now if you had the camera connection kit, and the USB was one of the ones that work - I've had about a 50/50 success rate getting USB's to work, and the USB was formatted correctly you might be able to pull a photo off the USB into your device. In theory it works, there's just a lot of 'ifs' -
How to list all tables/stored procedures used by the report
All the reports i create are getting data from stored procedure(s). Is there a way to obtaining a listing of all the stored procedures without having to open report by report and check under Database > Set Datasource Location > Properties > Table Name?
Finding this info it would be extremely valuable, as it would help me to judge the impact of any changes that i might be considering to one or more of the stored proc.
So far i maintained a manual listing but it is not up-to-date and reliable. I would rather prefer to get an updated listing every time i want to change/drop a stored procedure.
Thanks so much for your help.
RickDell can you be a little bit more specific about the SDK solution. I could ask one of the developers to help me but i need to gather more details.
I took a look .rpt inspector Pro but it does not do what i need. All i need is the the listing of all the database tables (in my case stored procs) used in my reports. No need to replace or change anything. I need to scan the directory where i have all the reports for the different applications and get report names and table/stored procs used. i can export the txt file to excel and that's all. -
Can you get values back from a stored procedure via OUTPUT parameters?
Can you get values back from calling a stored procedure via OUTPUT parameters/variables? I call the SP via a SQL statement from a script either in a WF or DF.
I thought I read some reference that DI could not get the values from OUTPUT parameters but I could not find it again (don't know if it is in any of the documentation or referred to in a forum.
I did try a couple of tests but it did not reutrn any values via OUTPUT. But before I give up I thought I'd see if you could and maybe I needed to change something.This isn't exactly an answer to your question, but I'll point out that, given that you're resorting to a SQL script in the first place, there's no reason you can't also turn the output parameters into a regular result or record set. (The following uses T-SQL, although I think it's pretty generic.)
declare @param1 int, param2 varchar(100), @return int;
exec @return = proc @param1 = @param1 output, @param2 = @param2 output;
select @param1 as param1, @param2 as param2;
That is, to get from output parameters to a "regular" output from the SQL script isn't much of a leap...
Jeff Prenevost
BI Consultant
Ann Arbor, MI -
How in ColdFusion with in variables get a Oracle stored procedure to return values?
How in ColdFusion with in variables get a Oracle stored procedure to return values?
We have tried several things, we can get a stored procedure to return a result set if we are not passing in variables but we cannot get them when we are passing in variables.
We know how to do it calling MS SQL.
Thanks for any help,
Nathan Sr
P.S. we have heard this may not be possible with the current Oracle Driver is there a different Oracle driver?I can only barely understand what you're asking here (not from a technical perspective, but from understanding your written English), but I suspect you're wanting to know how to pass back values other than recordsets from Oracle?
You should be able to pass them back via a type=out proc param, shouldn't you?
If you could reword your post so it's a bit more coherent, and possibly post some code, that might help.
Adam -
How can I print from my ipad2 via my Canon Pixmar MP620 wireless printer? I get a message stating "no airprinter found".
Welcome to Apple Support Communities.
If you have a Mac running OS X, try AirPrint Activator.
http://netputing.com/airprintactivator/airprint-activator-v2-0/
It's "donation-ware."
Free to download and try. If it works and you like it, the developers do appreciate a donation, but the app continues to function, even without a donation. -
How to generate a report from stored procedure
I would like to generate a report from stored procedure.
I used to work on sql server. this can be done as easy as put a select statement at the end of stored procedure.
The resule can be displayed on the development IDE, like sql developer or consume by Java JDBC client.
is there equivalent way to do this in Oracle stored procedure?Hi,
What type of report you are looking..for.. ??
As you said that "I used to work on sql server. this can be done as easy as put a select statement at the end of stored procedure. "
When you execute it will return the result set and you will display directly on the FrontEnd.. Is my Understanding is correct Up to here.
See, In oracle you have call some custom stored procedures as you did in SQL Sever, but you have return the Results Sets, with help of Out put paramter, Either Cursors or Varrays..
or Else you can generate the Html reports based on your requirement, HTML can be used in the stored procedures of Oracle which will generate for your, you need to code it.
I could not able get the relevant link for your reference.
I will get back to you on this.
- Pavan Kumar N -
How to get hostname from targetlist in custom deployment procedure?
When I make a simple procedure with a phase that will loop through a procedure hostname list
and a hostcmd or directive inside that will use the hostname ex change a configuration file. How to get hostname from the hostname targetlist?
I would rather not use $(hostname) or similar function if I can get the hostname from the target list.
Edited by: user476601 on 2012-09-06 05:59I have tried that and cannot get it to work.
I have tried to make a procedure with:
parameter
- parallel fase
- step directive with hostname parm based on simple sh script (echo $hostname)
- map hostname setvalue %TargetName%
In a hostcmd step you cannot access %TargetName% directly
it doesn't work. Please come with an example if you have tried it.
/René
Maybe you are looking for
-
Go wireless with my printer?
I am not very computer savy however I am very good at following directions. I am looking to be able to print from mywireless laptops without having to plug into my printer. First do I need a new printer or is it possible to use an older one? If it
-
After I download a 256 kbps song from the cloud using ITunes Match, how do I get it to play on my computer once I turn ITunes Match off again? I have been using ITunes Match for awhile now to increase the bit rate on songs to 256 kbps. Once I downlo
-
I feel there must be a way to put the same data to multiple/batch images. e.g. code a batch of images yellow or put the same keywords. Help would be very much appreciated. Thanks, jp.
-
Hotel management software for mac - need assistance PLEASE read..
hello everyone! thanks for taking the time to read this. I am managing hotels and they requested going via computer compared to hands-on. what programs do you recommend for the hotel management software when one does a reservation online to send a no
-
Error code 28 LabVIEW Null menu
The error cluster of my VI indicate that the error 28 : LabVIEW Null menu occur in it, but when I open the block diagram of this VI to see which subVI cause the error, the error doesn't reappears anymore and everything is OK. Afterward, if I close m