Oracle Store procedure Docu. Ex throws error ?!!!!
The following are the Oracle Docu. Contents on Store Procedures.
I could create same Function and added the same java codes to a JSP but it throws error as
java.sql.SQLException: Malformed SQL92 string at position: 5. Expecting "call"
Code is as follows
JDBC and SQLJ allow you to call PL/SQL stored functions and procedures. For example, suppose you want to call the following stored function, which returns the balance of a specified bank account:
FUNCTION balance (acct_id NUMBER) RETURN NUMBER IS
acct_bal NUMBER;
BEGIN
SELECT bal INTO acct_bal FROM accts
WHERE acct_no = acct_id;
RETURN acct_bal;
END;
From a JDBC program, your call to the function balance might look like this:
CallableStatement cstmt = conn.prepareCall("{? = CALL balance(?)}");
cstmt.registerOutParameter(1, Types.FLOAT);
cstmt.setInt(2, acctNo);
cstmt.executeUpdate();
float acctBal = cstmt.getFloat(1);
Can any one Advise
Abhiash
change line
CallableStatement cstmt = conn.prepareCall("{? = CALL
balance(?)}");
to
CallableStatement cstmt = conn.prepareCall("{? = call
balance(?)}");
i.e. lowercase 'call'
hope it solves
Similar Messages
-
Create oData service using oracle Store procedure
Hello Experts,
I need to create oData service from oracle store procedure,
what are the steps to do it.
We are using SMP Integration gateway.
Please Suggest.
Regards
ManishHello Experts,
Here is my code to join 2 tables , in debug it does not give error, but it gives on only one table output not merged output.
Please suggest.
function processRequestSQL(message) {
//Import statements
importPackage(com.sap.gateway.ip.core.customdev.util);
importPackage(java.util);
importPackage(org.apache.olingo.odata2.api.edm);
importPackage(com.sap.gateway.core.ip.component.commons);
importPackage(org.apache.olingo.odata2.api.uri);
importPackage(com.sap.gateway.ip.core.customdev.logging);
//Get the SQL statement contained in message body
var sqlStatement = message.getBody();
var uriInfo = message.getHeaders().get(ODataExchangeHeaderProperty.UriInfo.toString());
var map = new HashMap();
map = uriInfo.getCustomQueryOptions();
//Create the query and sub query
var JOIN_WO_WHERE = "INNER JOIN ZONE ON AREA.AREA_ID = ZONE.AREA_ID ";
var WHERE = " WHERE ";
var JOIN = " INNER JOIN ZONE ON AREA.AREA_ID = ZONE.AREA_ID ";
//Modify the SQL statement
var modifiedSqlStatement = "";
var entitySet = uriInfo.getStartEntitySet();
var odataMethod = message.getHeaders().get(ODataExchangeHeaderProperty.ODataMethod.toString());
modifiedSqlStatement += sqlStatement;
if (odataMethod.toString() == "GET_FEED") {
entitySetName = entitySet.getName();
if (entitySetName == "AREA") {
if (sqlStatement.indexOf("WHERE") != -1
|| sqlStatement.indexOf("where") != -1) {
modifiedSqlStatement += JOIN_WO_WHERE;
} else {
// modifiedSqlStatement += WHERE;
modifiedSqlStatement += JOIN;
//Set the message body back with the modified SQL statement
message.setBody(modifiedSqlStatement);
//Logger
log.logErrors(LogMessage.TechnicalError, "This is first log");
//Set the message body back with the modified SQL statement
message.setBody(modifiedSqlStatement);
//Logger
log.logErrors(LogMessage.TechnicalError, "This is first log");
-------------------End Sample Implementation---------------------------------------
return message; -
Calling Oracle store procedure from Crystal 11 command
I need to call Oracle store procedure from Crystal Command. The Store proc has ref cursor. Is it possible. Can you post few examples?
Also, is it possible to have multiple sql statements in a Crystal Command, when working with Oracle 10g?
It is working for SQL server.Please re-post if this is still an issue to the Data Connectivity - Crystal Reports Forum or purchase a case and have a dedicated support engineer work with you directly.
-
To use cursor as an OUTPUT paramete in Oracle Store Procedure
I want to return a ref cursor from an oracle store procedure. Is is possible? How? Syntax?
yes I think it is possible its syntax is
CREATE OR REPLACE
PROCEDURE GetEmpRS1 (p_recordset1 OUT SYS_REFCURSOR,
p_recordset2 OUT SYS_REFCURSOR,
PARAM IN STRING) AS
BEGIN
OPEN p_recordset1 FOR
SELECT RET1
FROM MYTABLE
WHERE LOOKUPVALUE > PARAM;
OPEN p_recordset2 FOR
SELECT RET2
FROM MYTABLE
WHERE LOOKUPVALUE >= PARAM;
END GetEmpRS1; -
How to pass values to Oracle store procedure in Crystal Report
Hi all,
I am newbie on passing values to stored procedure parameters. I created a Crystal Report using the Crystal Report wiward with PULL method and data come from Oracle stored procedure. In an ASP.NET page, I have stored two values in Session and need to pass them as input parameters to Oracle stored procedure to print the report. In Crystal reports 2010 once you connect to a stored-procedure as data source, it automatically creates the parameter fields with Crytal Report Viewer. Please show me how I pass values to store procedure at runtime automatically.
'Set the parametter value
myReport.SetParameterValue("@P_COURSE", "CoursetNo")
myReport.SetParameterValue("@P_CLASS", "ClassNo")
End Sub
I tried to apply above codes from Brian Bischof book but display the error from the following lines:
myReport.SetParameterValue("@P_COURSE", "CoursetNo")
myReport.SetParameterValue("@P_CLASS", "ClassNo")
I also enclosed my code. Any experts, please let me know anything wrongs on my code . I tried several methods that searching via google, but did not solve my issues. Thanks.
Edited by: avt2K7 on Mar 15, 2011 7:02 AMHi,
Thank you for your response. Here are the detailed code and error as following:
Please show what I am missing in my below VB.NET codes:
===========================================================================================
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
LogonToTables("username", "password", "servername", "")
End Sub
Private Sub LogonToTables(ByVal myUserId As String, ByVal myPassword As String, ByVal myServerName As String, ByVal myDataBaseName As String)
Dim Course, Class As String
Course = Session.Item("CourseNumber"))
Class = Session.Item("ClassNumber"))
Dim myReport As New CrystalDecisions.CrystalReports.Engine.ReportDocument
myReport.Load(Server.MapPath("CrystalReport1.rpt"))
Dim myTableLogonInfo As CrystalDecisions.Shared.TableLogOnInfo
'Set the database properties and security credentials
Dim myConnectionInfo As New CrystalDecisions.Shared.ConnectionInfo
myConnectionInfo.ServerName = "servername"
myConnectionInfo.DatabaseName = ""
myConnectionInfo.UserID = "username"
myConnectionInfo.Password = "password"
'Apply the ConnectionInfo to the report tables
Dim myTables = myReport.Database.Tables
For Each myTable As CrystalDecisions.CrystalReports.Engine.Table In myTables
myTableLogonInfo = myTable.LogOnInfo
myTableLogonInfo.ConnectionInfo = myConnectionInfo
myTable.ApplyLogOnInfo(myTableLogonInfo)
Next
'Set the parametter value to Crystal Report parameter named P_COURSE and P_CLASS
myReport.SetParameterValue("@P_COURSE", "Course")
myReport.SetParameterValue("@P_CLASS", "Class")
End Sub
=================================================================================
I put a break point to debug but display the error at the following lines:
myReport.SetParameterValue("@P_COURSE", "Course")
myReport.SetParameterValue("@P_CLASS", "Class")
Eventhough, if I set a specific value to Course=1000 and Class = math and still receive the error:
Invalid index. (Exception from HRESULT: 0x8002000B (DISP_E_BADINDEX))
I tried several sources from Google search but it is not working. I really appreciate any detailed code either in C# or VB.NET to solve my issues. Thanks in advance. -
Calling ORACLE Store Procedure with parameters in user define function
Hi everybody,
We have a scenario connecting Oracle DB thru JDBC adapter.
We have to call store procedure with input parameter and output parameter to retrieve data from DB. The implementation was made using JDBC adapter by building the correct XML message with EXECUTE action, and it works fine.
Now we need to use DB lookup within mapping. I wrote users define function with SELECT statement (using the JDBC adapter) and it works fine but I need to call store procedure in ORACLE instead of SELECT statement.
I found lot of examples concerning DB lookup but none of them explained how to write UDF calling store procedure in ORACLE with input and output parameters.
I am looking for an example.
Thanks in advance,
GigiI agree with you, but issue is we have lots of existing store procedure, which we need to call where damn required. I am sure those will be few but still i need to find out.
If you think you are going to get existing MS Stored Procedures or Oracle Packages that had nothing to do with the ORM previously to work that are not geared to do simple CRUD operations with the ORM and the database tables, you have a rude awakening
coming that's for sure. You had better look into using ADO.NET and Oracle Command objects and call those Oracle Packages by those means and use a datareader.
You could use the EF backdoor, call Oracle Command object and use the Packages, if that's even possible, just like you can use MS SQL Server Stored Procedures or in-line T-SQL via the EF backdoor.
That's about your best shot.
http://blogs.msdn.com/b/alexj/archive/2009/11/07/tip-41-how-to-execute-t-sql-directly-against-the-database.aspx -
Store Business document - online (scanner) - error
Hi ,
I am getting the following error when i double click the document type....( In tcode mb03 )
MBO3->Store Business document option->
Error calling application via OLE
SCANIFACE.CLSSTOREDOC
Thanks with regards
GirishCould you let know how are you managing this currently? For automatic scanning and storing of docs,SAP Archive link is the recommended solution.SAP Archive link scans, stores and links incoming and outgoing documents related to business processes to associated SAP R/3 objects. For more information, refer
http://help.sap.com/saphelp_nw04/helpdata/en/5e/566039b85f9443e10000000a114084/frameset.htm
Regards,
Pradeepkumar Haragoldavar -
How to get a recordset in vb to access a oracle store procedure.
I have a store procedure(sproc) that needs to be called from a VB Application. I was being told that I would have to create a PL/SQL table in my store procedure for the VB Developer to access information from my store procedure. This is beacasue he wants it as a record set. Is that the way to get info for a VB front end. My sproc is a very basic one
My sproc looks like
create or replace PROCEDURE SP_TBLINFO
(ID out TBLINFO.id%type,
ACCOUNT_NUMBER out TBLINFO.account_number%type)
AS
CURSOR TBLINFO_CURSOR IS
SELECT * FROM TBLINFO;
V_TBLINFO_CURSOR TBLINFO_CURSOR%ROWTYPE;
BEGIN
OPEN TBLINFO_CURSOR ;
Loop
FETCH TBLINFO_CURSOR INTO V_TBLINFO_CURSOR;
EXIT WHEN TBLINFO_CURSOR %NOTFOUND;
ID := V_TBLINFO_CURSOR.id;
ACCOUNT_NUMBER:= V_TBLINFO_CURSOR.account_number;
END LOOP;
CLOSE TBLINFO_CURSOR ;
END SP_TBLINFO;
Thanks.Use a REF_CURSOR, something like the following:
create or replace package SP_TBLINFO as
CURSOR TBLINFO_CURSOR IS SELECT * FROM TBLINFO;
create type TBLINFO_CURSOR_TYPE is TBLINFO_CURSOR%ROWTYPE;
procedure PROC_TBLINFO(Info out TBLINFO_CURSOR_TYPE);
end;
create or replace package body SP_TBLINFO as
PROCEDURE PROC_TBLINFO
(Info out TBLINFO_CURSOR_TYPE)
AS
BEGIN
OPEN ACCOUNT_NUMBER as SELECT * FROM TBLINFO ;
END SP_TBLINFO;
END;
Then bind it in OO4O as ORATYPE_CURSOR. -
Execute ORACLE STORE PROCEDURE from DATABASE
Hi Everyone...
i have a store procedure, it has a 5 params, 3 are IN parameters and 2 left are OUT parameters, I need execute this store procedure using a SQL Intruction like this
DECLARE integracion_sia_kac PROCEDURE FOR KACTUS.SP_SIAKAC_NMDHODO
:ll_horario,
:ll_ide_doc,
:ls_con_kac,
@PINDREGI=:ls_ind_registro output, @PVALERRO=:ls_error_int output
USING gt_kactus;
i think this function is using from MSSQL Server, this has a three IN params but the declaration of the OUT params I don't understand.
HELP ME!!!!!.... I need know way to execute the SP
ThanksWell it is very simple!
example:
CREATE OR REPLACE PROCEDURE PROC1 (P1 IN NUMBER, P2 IN NUMBER, P3 OUT NUMBER) IS
BEGIN
P3 := P1 + P2;
END;
This is how to use PROC1 from, say, PROC2 :
CREATE OR REPLACE PROCEDURE SomeShema.PROC2 IS
Var1 NUMBER(15,2);
Var2 NUMBER(15,2);
ReturnParamFromPROC1 NUMBER(15,2);
BEGIN
Select SomeField INTO Var1 from Table1 where Table1.ID = 10;
Select SomeField INTO Var2 from Table2 where Table2.ID = 20;
PROC1(Var1, Var2, ReturnParamFromPROC1);
DBMS_OUTPUT.PUT_LINE('Returned value from PROC1 is : '||ReturnParamFromPROC1);
END; -
After upgradation from Oracle 9i to Oracle 10g,one proc is throwing error
recently upgraded from Oracle 9i to Oracle 10g. We have some Oracle procedures which are not working in Oracle 10g.
A section of code from one of the procedures looks somewhat like the code below:
Declare
Cursor c_matched_records (…..) is
Select a.field 1, b.field2
From table1 a, table2 b
Where a.field3=b.field1
FOR UPDATE;
BEGIN
For records in c_matched_records
LOOP
-- Continue processing
-- Update records
COMMIT;
END LOOP;
END;This section of the code throws out the following error in Oracle 10g
ORA-01002: fetch out of sequence during PUT outputFile file
However this code was working fine in Oracle 9i.
please help me with this?
ThanksI believe you are lucky that the pl/sql is okay in Oracle 9i. How about remove the commit statement? Why do you need it in the loop. I look up metalink. You may refer to article ID 257914.1
-
Oracle Store Procedure communicate with ADO
I am writing an application for OLTP. The application also need to let user search for data and display in grid.
I want to store the queries in Package. I am using ADO 2.5 and VB6.
Having tested putting things and Stored Proc and return a Cursor as output parameter in Oracle, I used ADO's command object to call the stored proc. But the performance of recordset.Open(ADOCommand, ..) is much worser than directly calling the recordset.Open(connection, SQL) to get the recordset.
I tried query for 12000 records with only few fields, using stored proc populated the recordset (client side, static) in 12 sec. Using direct SQL query do it in 6 sec. The most problem is that with ADOCommand, it fill up my 100MB memory (so strange!!!), while direct SQL query only used 2MB...
I wonder whether it's the fault of my calling method or not.
My stored proc is like below
procedure MySP(p1 varchar2, p2 varchar2, p3 varchar2, pcur OUT T_REF_CUR) is
begin
open pcur for
select field1, field2, field3 from MyTable;
end;
My VB program retrieve data like below
dim objcmd as new adodb.command
dim objrst as new adodb.recordset
set objcmd.activeconnection = MyGlobalPresistantConn
objcmd.text = " call MySP{?,?,?} " 'the syntax may not be correct here, because I type it in a free text editor only
objcmd.parameters.append p1 'p1,2,3 are parameters object
objcmd.parameters.append p2
objcmd.parameters.append p3
objrst.open(objcmd, , adStaticCursor)here's a couple of ideas :
- tuneup your PL/SQL code, make sure it runs fast from SQL * Plus itself. Maybe consider putting hint like
SELECT /*+ FIRST_ROWS +/ FIELD1, FIELD2 ...
- In VB 6 using objects good idea is to create them like:
Dim objcmd as adodb.command
Dim objrst as adodb.recordset
Set objcmd = New adodb.command
Set objrst = New adodb.recordset
Not like :
Dim objcmd as New adodb.command
Dim objrst as New adodb.recordset
when you done, close objects, connections
and then destroy it :
Set objcmd = Nothing
Set objrst = Nothing
(this has to do something with memory handling, etc.)
- try to use 'adForwardOnly' constant as seems to be the fastest option ...
- If nothing works look online for good code samples for exactly your case in PL/SQL ref-cursors and VB 6, ADO 2.5 -
Make Interactive report from Oracle Store Procedure returning SQL
I have the following type of Report Region:
Report Region Type:
SQL Query (PL/SQL function body returning SQL query)
Region Source:
DECLARE
q varchar2(4000);
BEGIN
GetMySQLString(:P22715_SID, q);
return q;
END;
function GetMySQLString() return varchar2 is
begin
return 'select * from myTable';
end GetMySQLString;
For some reason though I can't figure out how to get it to work with an Interactive Report.... Basically I want the report to use the SQL returned by the Oracle Stored Function....
Any thoughts?Should have searched better!
Guess this should help: Calling Procedure or Function from Interative Report
Edited by: tward on Sep 3, 2010 8:55 AM -
Passing Nested table or Vararray from Java to Oracle store procedure
I have some CSV file with arround 50,000 lines. I need to pass read those lines from Java to Oracle as a collection object.
Pro & cons of both the options.
Need some suggestions...
Regards,
LokanathHi,
why not using External tables. Then you can in Oracle work it out by just using it as a normal table with all the profits.
Herald ten Dam
http://htendam.wordpress.com -
Getting error while Calling Oracle Stored Procedure with output Parameter
HI All,
From long days i am working on this but i unable to solve it.
Even i have studied so many forums in SAP but i didn't find the solution.
I am calling Oracle Store procedure with 3 inputs and 1 output without cursor.
Store Procedure:-
CREATE OR REPLACE PROCEDURE PDS.send_rm
IS
proc_name VARCHAR2(64) := 'send_rm';
destination_system VARCHAR2(32) := 'RAWMAT';
xml_message VARCHAR2(4000);
status_code INTEGER;
status_message VARCHAR2(128);
debug_message VARCHAR2(128);
p_ret INTEGER;
BEGIN
DBMS_OUTPUT.PUT_LINE( proc_name || ' started' );
xml_message := '<RAW_MATERIAL>'||
'<BAR_CODE>10000764601</BAR_CODE>'||
'<MATERIAL>1101448</MATERIAL>'||
'<VENDOR_CODE/>'||
'<PRODUCTION_DATE>0000-00-00</PRODUCTION_DATE>'||
'<EXPIRE_DATE>0000-00-00</EXPIRE_DATE>'||
'<BATCH/>'||
'<PO_NUM/>'||
'<MATERIAL_DESCRIPTION>POWER SUPPLY</MATERIAL_DESCRIPTION>'||
'<SPEC_NAME/>'||
'<STOCK_CODE>BSW-JH</STOCK_CODE>'||
'<INSPECTION_LOT>00</INSPECTION_LOT>'||
'<USAGE_DECISION_CODE/>'||
'<MATERIAL_GROUP>031</MATERIAL_GROUP>'||
'</RAW_MATERIAL>';
dbms_output.put_line('XML '||xml_message);
-- vp_interface.load_rawmat@cnprpt1_pds(SYSDATE, destination_system,
-- xml_message, p_ret);
vp_interface.load_rawmat(SYSDATE, destination_system,
xml_message, p_ret);
dbms_output.put_line('Return Code '||p_ret);
COMMIT;
EXCEPTION
WHEN OTHERS THEN
status_code := SQLCODE;
status_message := SUBSTR(SQLERRM, 1, 64);
-- Extract_Error_Logger(proc_name, 'LOCAL', SYSDATE, -999,
-- status_message, 0, debug_message);
ROLLBACK;
END send_rm;
And while i am calling this Store procedure in MII, I am facing error.
I have tried different ways but didnt solved
In SQL Query, i kept mode as: FixedQueryOutput
Can anyone tell me or send code for calling above store procedure
And onemore thing, While creating store procedure in Oracle for MII. Do we need to Create output parameter as cursor or normal.
Thanks,
Kind Regards,
Praveen Reddy MHi Praveen
Our wrapper was created because we could not modify the procedure we call (it was not returning a cursor).
CREATE OR REPLACE PROCEDURE CHECK_PUT_IN_USE
(STRCMPNAME in varchar2,
STRSCANLABEL in varchar2,
RCT1 out SYS_REFCURSOR
AS
charDispo Char(1);
charStatus Char(1);
intCatNo Integer;
charCatDispo Char(1);
strCatQual VarChar2(2);
strCatDesc VarChar2(30);
strMsg VarChar2(128);
BEGIN
qa.check_put_in_use@AR(STRCMPNAME,
STRSCANLABEL,
charDispo,
charStatus,
intCatNo,
charCatDispo,
strCatQual,
strCatDesc,
strMsg);
OPEN RCT1
FOR Select charDispo,charStatus,charDispo,charStatus,intCatNo,charCatDispo,strCatQual,strCatDesc,strMsg from Dual;
END;
Hope this helps
Regards
Amrik
then with a FixedQueryWithOutput
call mixar.qasap.wrapper_update_put_in_use('[Param.1]','[Param.2]',[Param.3],?)
Hope this helps. -
Using Oracle Stored Procedure in Interactive Reporting
Hello,
i'm trying to use Oracle Store procedure in Interactive reporting but all i get are errors.
My env:
Interactive Reporting 9.3.1
Oracle Database 10.2
I created OCE as ODBC/OBDC. Tables are returned and Stored Procedure entry is enabled.
If i use "microsoft ODBC for Oracle" i can see stored procedure list but i get this error:
SQL API: [SQLExecDirectW], SQL RETURN: [-1], SQL STATE: [42000], SQL NATIVE ERROR: [6550], SQL MESSAGE: [[Microsoft][ODBC driver for Oracle][Oracle]ORA-06550: line 1, column 7:
PLS-00306: wrong number or types of arguments in call to 'TEST_PDC_RECORDSET'
If i use Oracle's odbc i get: "Error in function sequence".
If i use Merants (5.2) odbc i cannot retreive stored procedure list. (list is empty)
Note.
My stored procedure works (tested via sqlplus).
thank u danieleReturning (or sending in) multiple rows directly from (or to) a stored procedure is not currently possible. I have been in contact with SAP on this subject earlier, and they suggest using a web service to do the job. I used this as a work around, calling the stored procedure from a web service. I send in VC tables to this web service, and this in turn contacts my stored procedure.
The problem is related to the connector framework in the J2EE environment.
I am on 7.0 sps 17
If you use stored procedure single value parameters of type varchar, number ... then VC has no problem communicating with your procedures.
Good luck
Henning Strand
Maybe you are looking for
-
Finding an error while calling an RFC
Hi, My requirement is as follows. The internal table(ITAB) which i am using has a field X of length 20 and the Internal table(RFCITAB) field Y found the RFC is of length 10. Here i am creating another 3rd internal table(ITAB1) with field Z of leng
-
Insufficient Bandwidth to maintain Video conference
Sometimes when I use the video ichat it says insufficient bandwidth and won't allow me to video chat. I have changed the server settings and everything to 443. Other times it will work perfectly fine. Any suggestions?
-
How do I open documents in already in ibooks with Reader?
How do I open documents already in ibooks in Reader?
-
Link contract with another PO line item condition
Hi Need some solution for the following issue: Explanation of the issue: First the contract is created for the freight and insurance for vendor say V1. Then the PO is created for the material for vendor V2. In the PO line item the freight and insuran
-
Best approach for backup and transport (NW BPC 7.5)
Hi, we are currently in a situation, where we have developed a prototype in a Q (quality) envoirnment. This has been a standalone system sofar. Now we have a Development->Quality->Production envoirnment - and I want to move my prototype from the Qual