Stored proc parameters referencing in code
Hi,
Quick question ...
I want my stored proc to accept two parameters : a source table name and a destination table name. The stored proc's goal is to update the destingation table with data in the source table.
Here is my code :
CREATE OR REPLACE PROCEDURE UPDATE_FPSYNTHESE (
sourcetable IN VARCHAR2,
targettable IN VARCHAR2
IS
BEGIN
INSERT INTO targettable (SELECT * FROM sourcetable WHERE id NOT IN (SELECT id FROM targettable));
UPDATE targettable SET name = (select name from sourcetable where targettable.id = sourcetable.id);
END;
Here's when I want to create it :
Errors for PROCEDURE UPDATE_FPSYNTHESE:
LINE/COL ERROR
10/1 PL/SQL: SQL Statement ignored
10/40 PL/SQL: ORA-00942: table or view does not exist
11/1 PL/SQL: SQL Statement ignored
11/8 PL/SQL: ORA-00942: table or view does not exist
Warning: Procedure created with compilation errors.
It doesn't seem to dereference the parameters ...
what am I doing wrong ?
Thanks in advance,
Best regards,
Steve
If the source and target tables must be dynamic, you would have to use dynamic SQL
CREATE OR REPLACE PROCEDURE update_fpsynthese (
sourcetable IN VARCHAR2,
targettable IN VARCHAR2 )
AS
sqlStmt VARCHAR2(4000);
BEGIN
sqlStmt := 'INSERT INTO ' || targettable ||
' (SELECT * ' ||
' FROM ' || sourcetable ||
' WHERE id NOT IN (SELECT id ' ||
' FROM ' || targettable || '))';
EXECUTE IMMEDIATE sqlStmt;
END;Since you are building up strings and executing them, you'll also have to worry about things like SQL injection attacks. You also lose compile-time syntax checking and generally complicate your life from a development & maintenance perspective. Are there really that many tables that you need to do this procedure with?
Justin
Distributed Database Consulting, Inc.
http://www.ddbcinc.com/askDDBC
Similar Messages
-
BPC5.1 - Data manager package to Stored proc with custom return codes
Hi all,
Does anyone have experience passing the return codes from a stored procedure back into the eData "view status" package progress or event log details?
When my stored procedure throws errors, the offending SQL code shows up in the pacakge details, which is helpful. But what I'd really like is to structure my stored proc with return codes
0 = everything's wonderful
1 = invalid category / time combination
2 = unauthorized
3 = no data to process
And then handle these codes as either "completed" "warning" or "error" in the package progress.
And ideally, I'd like to put some meaningful message about the warnings & errors, directly into the log details, so the user can fix the problem themselves rather than ask the IT guy to trouble-shoot.
Any tips? I've started playing with using the on-complete, on-success, on-failure routing of different tasks within the DTSX package (SQL 2005), but I'm just working on a trial-and-error basis right now. (With # of errors = # of trials.)
Thanks,
TimIn case anyone's interested, I've solved this by tracking my return codes as a package variable.
Within the package, I have conditional logic moving from task to task, evaluating the return code to check for various conditions, and selecting which tasks to perform accordingly.
In the last task, I run a final stored procedure which posts some data (completion time & status) to a custom transaction log table, and then if the return code is not zero, I script and execute some SQL which I know will throw a "fake" error. The SQL statement itself includes the key information I want the end user to see. For example
Select InvalidEntitySelection [USEast1],TransactionID [12340] from ThisTableDoesntExist
Select UnauthorizedUser [Tim], TransactionID [12345] from ThisTableDoesntExist
Select WorkStatusIsLocked [USEast1 Actual 2008], TransactionID [12345] from ThisTableDoesntExist
It's not exactly elegant, but it gets the message across, which is all that I need. In this way, the end user sees that the package failed with an error, and when they look at the package details, they can see the problem. They can pass on the transaction ID to an administrator to look into the details, if they can't figure it out on their own.
Sorin, I never managed to figure out how to use a VB task to send the information back to the user, plus force the package to end in an error. I'm sure there's a way to do so, but this seems to work for my requirement.
I'm not entirely happy with the "fake error" approach, but I don't know if BPC has any support for "intentional" programming of errors in the DTS scripting toolset.
Thanks,
Tim -
Stored proc parameters not getting populated via code in prod environment
Hi,
I have a report created in Crystal developer 2008 SP1. The reportt uses a stored procedure as data source. The stored procedure expects a paramater, @Company, to only return data for that specific company. The report then further has a dynamic parameter which allows to filter by location. This dynamic parameter will therefore only display a list of locations for that specific company to choose from.
I have a website where users from different companies can log in and view reports based on their company. I use VS2005 to set the @Company parameter programatically (depending on the company of the logged in user). And then the user manually selects the location.
My problem is all of this works 100% on my dev machine (Win XP SP3, Crystal Developer 2008 SP1, VS2005, IIS5) but as soon as i deploy to the server (Windows Server 2003, Crystal 2008 SP2 Runtime installed, IIS6) the stored procedure's parameter, @Company, are no longer auto populated. It keeps giving a parameter box asking for the @Company value.
Also it is only for parameters of stored procedures or SQL commands that this happens.
I have no idea why this happens. Any ideas? I've tried on 2 different production machines (both running Win2003, IIS6). And also on two XP dev machines. On dev it works 100%, but on prod - no luck.
ThanxI've actually solved this. But it's weird.
I had to install the Crystal Reports designer onto the server. Then everything works fine.
So it seems the the issue comes in with running the full version / redist version SDK files....
Is this supposed to happen? -
Clearing Oracle Parameters to call diferent stored procs
Sub Main
Do While i < 3
make_excel(i)
i = i + 1
Loop
end Sub
Sub make_excel(ByVal array As Integer)
objCmd.Parameters.Add(New OracleParameter("p_cursor", OracleType.Cursor)).Direction = ParameterDirection.Output
end Sub
objCmd.Parameters.Clear()
objCmd.Parameters.Remove("p_cursor")I agree with you. I was looking into mod_plsql, but it turns out that their development standards include not using Oracle HTTP server. The whole reason why they want to be able to execute a stored proc based on what is specified in an XML doc is that they want to avoid having to change their middle-tier configurations anytime a new stored proc or a change in stored proc parameters is made. I'm not familiar with what all is involved with .NET and the middle-tier, but supposedly this way, they can specify any stored procedure name and its parameters in an XML file. The XML is then suppose to be passed on to an Oracle stored procedure which will parse the XML and dynamically execute the stored procedure that was specified in the XML.
Here is an example of the XML:
'<Root>
<PackageName>TEST_PKG</PackageName>
<ProcedureName>TEST_PROC</ProcedureName>
<Parameters>
<Parameter>
<Name>EmpID</Name>
<Value>12345</Value>
</Parameter>
<Parameter>
<Name>Org</Name>
<Value>ABC</Value>
</Parameter>
</Parameters>
</Root>I basically need to parse out the pkg/proc names:
SELECT t.COLUMN_VALUE.extract('//PackageName/text()').getstringval() PkgName,
t.COLUMN_VALUE.extract('//ProcedureName/text()').getstringval() ProcName
INTO v_pkg_name, v_proc_name
FROM TABLE(xmlsequence(XMLTYPE(v_XML_input) .extract('/Root'))) t;...and then execute the procedure:
EXECUTE IMMEDIATE 'BEGIN '||v_pkg_name||'.'||v_proc_name||'(:a, :b, :c); END;'
using in v_in_param1, v_in_param2, out v_XML_output;The problem is that this approach is very complicated since there can be any number of IN/OUT parameters and of various datatypes. I would have to create all kinds of possible bind variables! -
Handling result form Stored Proc in java program
Folks, I have a question on how to handle results from Stored Procedures with the java.sql API. I execute a stored proc from a java program using the statement:
statement.execute();
where 'statement' is of type Statement. Then I get the results:
ResultSet rs = query.getResultSet();
The above returns me a ResultSet object. Now, my stored proc is such that it will return an integer in case of errors (as error code), and, if no error,it'll return the result set. Because I wouldn't know if the stored proc is returning an integer or a result set, how do I get the result of the stored proc in the java program? 'query.getResultSet()' would get me only an object of type ResultSet. What if the stored proc is returning an integer (i.e. when an error occurs)?
Thanks.GSP wrote:
Thanks to all for your replies. I do not have access to modify the stored procedure. I can just use it in my java program. The stored proc first validates its input parameters. If it finds them invalid, then it returns an appropriate error code (which is an integer) depending on which input param is found invalid. If all the input parameters are found valid, then it fetches the rows from the DB tables & returns them as result set. Now my question is: say if I give a statement as this in my java program:
ResultSet rs = query.getResultSet();
what if the stored proc returns an error code (Since the above statement gets only ResultSet object, how will it handle if the stored proc returns an int)? Is there any alternative?
Ok, so there is a piece of missing data.
Store procs, conceptuatlly can return data in a variety of ways.
So the first step is to determine how the data is being returned.
Unless you know that there is no way to determine how to use it in java. -
Calling stored proc from java using ref cursor
Hi All,
We have a requirement to display all the records from a table on a JAVA screen. Due to some constraints, we have to write the query in the stored proc. We are trying to return a result set from the stored proc to the java code by using a ref cursor. Please refer to the code below.
Following is the PL/SQL proc �
procedure sp_user_course2(v1 OUT ref_cursor, persid in varchar2) as
begin
open v1 for
SELECT lrn_exp_id, crs_name FROM emp_crs
WHERE personid = persid;
end;
Here ref_cursor is of TYPE REF CURSOR declared in the package specification.
The java code is �
Callable stmt = conn.prepareCall("call sp_user_course2(?,?)");
stmt.registerOutParameter(1,OracleTypes.CURSOR);
stmt.setString(2,emplId);
stmt.execute();
OracleCallableStatement tstmt = (OracleCallableStatement) stmt;
ResultSet rs = tstmt.getCursor (1);
When I run the program, I get the following error (at stmt.execute()):
[Oracle][ODBC][Ora]ORA-06553: PLS-306: wrong number or types of arguments in call to 'SP_USER_COURSE2' 6553
Can anyone tell me what could be the problem with this code? I have read somewhere that REF CURSOR feature is available from Oracle 9i onwards. If so, then, is there any workaround for mapping REF CURSOR to Resultsets in Oracle 8i?These may help
http://www.google.co.uk/search?q=jdbc+OracleTypes.CURSOR+tutorial -
Calling stored proc from java to return ref cursor
Hi All,
We have a requirement to display all the records from a table on a JAVA screen. Due to some constraints, we have to write the query in the stored proc. We are trying to return a result set from the stored proc to the java code by using a ref cursor. Please refer to the code below.
Following is the PL/SQL proc ?
procedure sp_user_course2(v1 OUT ref_cursor, persid in varchar2) as
begin
open v1 for
SELECT lrn_exp_id, crs_name FROM emp_crs
WHERE personid = persid;
end;
Here ref_cursor is of TYPE REF CURSOR declared in the package specification.
The java code is ?
Callable stmt = conn.prepareCall("call sp_user_course2(?,?)");
stmt.registerOutParameter(1,OracleTypes.CURSOR);
stmt.setString(2,emplId);
stmt.execute();
OracleCallableStatement tstmt = (OracleCallableStatement) stmt;
ResultSet rs = tstmt.getCursor (1);
When I run the program, I get the following error (at stmt.execute()):
[Oracle][ODBC][Ora]ORA-06553: PLS-306: wrong number or types of arguments in call to 'SP_USER_COURSE2' 6553
Can anyone tell me what could be the problem with this code? I have read somewhere that REF CURSOR feature is available from Oracle 9i onwards. If so, then, is there any workaround for mapping REF CURSOR to Resultsets in Oracle 8i?These may help
http://www.google.co.uk/search?q=jdbc+OracleTypes.CURSOR+tutorial -
Is there a way to call a stored proc from the web in Oracle 10g?
I've found an article about Native Oracle XML DB Web Services in 11g, but it appears to be a new feature. Is there any way of accomplishing something similar in 10g? I would like to be able to process XML documents that contain the name and parameters of the stored proc/function to execute.
Link to 11g article:
http://download.oracle.com/docs/cd/B28359_01/appdev.111/b28369/xdb_web_services.htmI agree with you. I was looking into mod_plsql, but it turns out that their development standards include not using Oracle HTTP server. The whole reason why they want to be able to execute a stored proc based on what is specified in an XML doc is that they want to avoid having to change their middle-tier configurations anytime a new stored proc or a change in stored proc parameters is made. I'm not familiar with what all is involved with .NET and the middle-tier, but supposedly this way, they can specify any stored procedure name and its parameters in an XML file. The XML is then suppose to be passed on to an Oracle stored procedure which will parse the XML and dynamically execute the stored procedure that was specified in the XML.
Here is an example of the XML:
'<Root>
<PackageName>TEST_PKG</PackageName>
<ProcedureName>TEST_PROC</ProcedureName>
<Parameters>
<Parameter>
<Name>EmpID</Name>
<Value>12345</Value>
</Parameter>
<Parameter>
<Name>Org</Name>
<Value>ABC</Value>
</Parameter>
</Parameters>
</Root>I basically need to parse out the pkg/proc names:
SELECT t.COLUMN_VALUE.extract('//PackageName/text()').getstringval() PkgName,
t.COLUMN_VALUE.extract('//ProcedureName/text()').getstringval() ProcName
INTO v_pkg_name, v_proc_name
FROM TABLE(xmlsequence(XMLTYPE(v_XML_input) .extract('/Root'))) t;...and then execute the procedure:
EXECUTE IMMEDIATE 'BEGIN '||v_pkg_name||'.'||v_proc_name||'(:a, :b, :c); END;'
using in v_in_param1, v_in_param2, out v_XML_output;The problem is that this approach is very complicated since there can be any number of IN/OUT parameters and of various datatypes. I would have to create all kinds of possible bind variables! -
How do I get the Parameters of a Stored Procedure from my Java Code?
I want to get the parameters in my Java code. How do I do this with Jdbc?
In ADO it was: myCmd.Parameters.Refresh();
Any idea what it is in Jdbc?no, what I want is to know what parameters are required by my stored proc. So basically I tell it, "My Stored Proc is name 'SomeName'. What are the parameters I need to fill for this proc?" Then it puts those in for me, and then I fill the values. That's what Cmd.Parameters.Refresh() does in VB/C++. So if I had a proc name "MyProc" with:
@Something int,
@Another varchar(25)
Then if I did cmd.StoredProc = "MyProc" (and told it where to find the DB), and then did cmd.Parameters.Refresh(), the cmd would then have those parameters with null values, so i could do:
cmd.Parameters(0) = 5
cmd.Parameters(1) = "hello"
Any idea how to do that in Java/Jdbc? -
Best place in VOimpl java code to call a stored proc to populate results
Hello all,
Using JDev 11g, ADF BC and Trinidad.
I am building an application that is primarily used for searching large amounts of data. We already have stored procedures on the database that perform the searches and dump the results into a holding table (together with a "search id"). I have easilly built a prototype of this application: my view object is simply "select a, b, c from results where search_id = :bv" - I have a service method in the AM that runs the stored procedure, obtains the search ID, binds it to the :bv in the VO and executes the VO's query - it's all working really nicely. Range paging is effective, the VO itself performs well, and I am able to control how long the stored proc runs via setting a timeout value.
Now, I'd like to generalize this. My thinking is this:
1). I'll add a custom property to my VO that is the SQL statement needed to call the stored procedure.
2). I'll add some bind variables to the VO to represent all the query parameters that can be passed to the stored proc. I'll also use custom properties to indicate these are "fake" bvs, and not in the SQL query itself.
3). The VO's SQL will remain simply "select a, b, c from results where search_id = :bv"
4). I will (have already tested) override bindParametersForCollection so that the "fake" bind variables aren't bound into the SQL.
Now, the question: I want to override some method in the VO's java code to call the stored procedure. The stored proc needs to be called before the actual query for the VO is run, and also before the method getQueryHitCount is called (so that the count is correct). What is the method that would be the "best" place to do this? My current thinking is that I would put the call in an over-ridden executeQueryForCollection call. As far as my analysis has gone, it seems to be always called before getQueryHitCount, but I have no way of knowing if this is completely safe.
Any thoughts from the BC experts out there?
Best regards,
JohnJohn,
from your description I understand that you essentially program the VO yourself. So I suggest that you read chapter 35.9 of the 'Fusion Developer’s Guide for Oracle Application Development Framework' (I guess you know where to find it). Since you still call the actual SQL not all of the chapter apply, but you get the idea how it works.
And yes you analyzed the behavior correct. executeQueryForCollection() is allways called bevore getQueryHitCount().
Timo -
Arrays as IN/OUT parameters to stored procs
I need the ability to pass Java arrays as input parameters and receive arrays as output parameters from stored procedures. I searched this forum for "array stored procedure" and came up with 9 posts dating back to April 30, 1999. In every one of these posts, people have asked how this can be done, and as yet there has not been any real solution provided. One messy solution is to add another stored proc that takes the array items as scalars and builds a PL/SQL table to pass to the original stored proc.
I am getting the impression that using arrays for IN/OUT parameters to/from stored procedures is not possible with JDK 1.1. Can it be done with JDK 1.2?
Isn't there anyone from Oracle that can provide an answer or solution?I've searched for a way of passing a rowtype to a stored
procedure or passing an array to a stored procedure.
The following example may have some pertinence. It was posted at
http://www.classicity.com/oracle/htdocs/forums/ClsyForumID124/6.h
tml#
I also think that it would be useful to know how best to pas a
ResultSet or equivalent to a Stored Procedure, if someone has
more information. The idea is to have symmetry between the way
data is retrieved from SP's (CURSORS) and supplied to SP's (???
ARRAY/CURSOR) ?
"[Example]Example of using JDBC with VARRAYS and REF CURSORs"
This example shows how to use JDBC with VARRAYS and REF
CURSORs.
It also shows use of the PreparedStatement and CallableStatement
methods.
The example does the follows:
1. selects from a table of VARRAYs
2. inserts into a table of VARRAYs
3. selects from a table of VARRAYs
4. calls stored procedure -- parameters <ref cursor, varray>
In order to test it, you will need to do two things first:
1) Create related tables and types first. The screipt is given
below.
2) Create a package that gets called from JAVA code. The script
is given below.
======================= Step 1 create tables etc. cute here
==================
-- Run this through SQL*PLUS
drop TABLE varray_table;
drop TYPE num_varray;
drop TABLE sec;
-- create the type
create TYPE num_varray as VARRAY(10) OF NUMBER(12, 2);
-- create the table
create TABLE varray_table (col1 num_varray);
-- create the sec table
create table sec (sec_id number(8) not null, sec_grp_id number
(8) not null,
company_id number(8) not null);
insert into sec values (1,200,11);
insert into sec values (2,1100,22);
insert into sec values (3,1300,33);
insert into sec values (4,1800,44);
==================== End of step
1===========================================
================== Step 2 create package
====================================
-- Run it through sql*plus
CREATE OR REPLACE PACKAGE packageA AS
type sctype is ref cursor return SEC%ROWTYPE;
procedure get_port_consensus(sc IN OUT sctype, arr IN
num_varray);
procedure test_port_consensus(sc IN OUT sctype);
END packageA;
CREATE OR REPLACE PACKAGE BODY packageA AS
procedure test_port_consensus(sc IN OUT sctype)
IS
testArr num_varray := num_varray(200, 1100, 1300, 1800);
BEGIN
get_port_consensus(sc, testArr);
END test_port_consensus;
procedure get_port_consensus(sc IN OUT sctype, arr IN num_varray)
IS
BEGIN
open sc for select * from sec
where sec_grp_id = arr(1)
or sec_grp_id = arr(2)
or sec_grp_id = arr(3)
or sec_grp_id = arr(4);
END get_port_consensus;
END packageA;
===================== End of step 2
===================================
============ JAVA code to test the whole thing
========================
import java.sql.*;
import oracle.sql.*;
import oracle.jdbc.oracore.Util;
import oracle.jdbc.driver.*;
import java.math.BigDecimal;
public class ArrayExample
public static void main (String args<>)
DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver
// Connect to the database
// You need to put your database name after the @ sign in
// the connection URL.
// The example retrieves an varray of type "NUM_VARRAY",
// materializes the object as an object of type ARRAY.
// A new ARRAY is then inserted into the database.
Connection conn =
DriverManager.getConnection ("jdbc:oracle:oci8:@v81",
"scott", "tiger");
// It's faster when auto commit is off
conn.setAutoCommit (false);
// Create a Statement
Statement stmt = conn.createStatement ();
System.out.println("Querying varray_table");
ResultSet rs = stmt.executeQuery("SELECT * FROM varray_table");
showResultSet (rs);
// now insert a new row
// create a new ARRAY object
int elements<> = { 200, 1100, 1300, 1800 };
ArrayDescriptor desc = ArrayDescriptor.createDescriptor
("NUM_VARRAY",conn);
ARRAY newArray = new ARRAY(desc, conn, elements);
// prepare statement to be inserted and bind the num_varray type
System.out.println("PreparedStatement: Inserting into
varray_table");
PreparedStatement ps =
conn.prepareStatement ("insert into varray_table values (?)");
((OraclePreparedStatement)ps).setARRAY (1, newArray);
ps.execute ();
// query to view our newly inserted row
System.out.println("Querying varray_table again");
rs = stmt.executeQuery("SELECT * FROM varray_table");
showResultSet (rs);
// prepare a callable statement -- call the stored procedure
// passing <ref cursor in out, varray in>
System.out.println("CallableStatement: Calling Stored
Procedure");
OracleCallableStatement oraStmt1 =
(OracleCallableStatement)conn.prepareCall("{ call
packageA.get_port_consensus(?, ?) }");
oraStmt1.registerOutParameter(1, OracleTypes.CURSOR);
oraStmt1.setARRAY(2, newArray);
oraStmt1.execute();
rs = (ResultSet)oraStmt1.getObject(1);
// loop through the result set of the ref cursor and display
while (rs.next()) {
System.out.println(rs.getString("sec_grp_id"));
// Close all the resources
rs.close();
ps.close();
stmt.close();
oraStmt1.close();
conn.close();
public static void showResultSet (ResultSet rs)
throws SQLException
int line = 0;
while (rs.next())
line++;
System.out.println("Row "+line+" : ");
ARRAY array = ((OracleResultSet)rs).getARRAY (1);
System.out.println ("Array is of type "+array.getSQLTypeName());
System.out.println ("Array element is of type
code "+array.getBaseType());
System.out.println ("Array is of length "+array.length());
// get Array elements
BigDecimal<> values = (BigDecimal<>) array.getArray();
for (int i=0; i<values.length; i++)
BigDecimal value = (BigDecimal) values;
System.out.println(">> index "+i+" = "+value.intValue()); -
Should I do this with Java Code or Stored Procs ? (for best performance)
Hi All,
I need to decide where should I implement my business logic, in Java code or Stored procs.
Here is the requirement :
- One Order has 70 products (Order_Table )
- Can be duplicate products, so I have to do summarize / grouping by product
- For every product, I have to check, if it is entitled for a Bonus product, then I have to Insert one to Bonus_Table.
- This is done when/after the transaction is SAVED (COMMIT)
The question is, which one has better PERFORMANCE :
(1) Create a rowsetIterator on the Order details (70 products) and call a stored procedure to do the logic for every single product (so that the Insert to Bonus_Table done in stored proc). means the stored proc will be called 70 times.
OR
(2) After the transaction is COMMITted, call the stored procs ONCE to do the logic for all the products at once.
OR
(3) I do all the logic with Java Code within ADF
Given the requirement above, which approach is most efficient / best performance ?
Thank you very much,
xtantoProblem with this is that you ask 100 people and you probably get 100 different answers. ;o)
Many would say that you push as much business logic into the database with your data; others might say you only put data in your database and your business logic is kept on the application server.
In reality your would probably have a mix of both and your decision would probably be influenced by your own background ...
Can't be more precise than that.
Grant -
Stored proc to accept parameters at prompt
How do you create a stored proc in SQL so that when run in desk you can input parameters?
I have a simple stored proc but when I create in deski always get an error saying that it expects '@DateStart'.
here is the sproc ive used:
CREATE Procedure [dbo].[sp_redempt](@DateStart Datetime,@DateEnd Datetime) AS SELECT *
FROM redempt
WHERE planners.office = 'abc'
AND ProcessDate >= @DateStart and ProcessDate <= @DateEnd
-- running it in SQL ent mgr
exec dbo.sp_NCLredempt '01 february 2011', '28 february 2011';
can you help with the syntax I use or specify a simple stored proc using the adventure works DB that will prompt for a parameter in deski?
BO Edge XI 3.0
App server: MS Win2003 Server Standard SP2
DB server: MS Win2003 Server Standard SP2
DB on DB server: SQL 2005Hi,
this is not the best place to post this but you may try the SQL Server forums from Microsoft.
Might be an issue in your parameter type definition. What you can do is in
SQL Server Management Studio, go to the stored procedures (programability) under AdventureWorks database, and Right click -> Script Stored Procedure As -> CREATE to -> New Query Editor Window. Then there you will able to see the syntax how it's used.
You can run one sample procedure in Deski. In Designer create a secure connection to AdventureWorks database. Then create a Deski report based on the "uspGetManagerEmployees" procedure and you can use MnagerID 6 when you run it. You will get results. -
How to pass XMLType as parameters to Java stored procs ?
How to pass XMLType as parameters to Java stored procs ?
ORA-00932: inconsistent datatypes: expected an IN argument at position 1 that is an instance of an Oracle type convertible to an instance of a user defined Java class got an Oracle type that could not be converted to a java class
Java stored proc -->
CREATE or replace FUNCTION testJavaStoredProcMerge( entity xmltype,event xmltype ) RETURN VARCHAR2 AS LANGUAGE JAVA
NAME 'XDBMergeOp.merge(org.w3c.dom.Document,org.w3c.dom.Document) return java.lang.String';
PL/SQL -->
declare
theQuote VARCHAR2(50);
entity xmltype;
event xmltype;
begin
entity := xmltype('<Quote><Fields><Field1>f1</Field1></Fields></Quote>');
event := xmltype('<Quote><Fields><Field2>f2</Field2></Fields></Quote>');
theQuote := testJavaStoredProcMerge(entity,event);
dbms_output.put_line(theQuote);
end;
Java class -->
public class XDBMergeOp {
public static String merge(Document entity, Document event) throws Exception {
return ...
Thanks in advance.I think you'll need to use XMLType and then extract the DOM inside java..
create or replace package SAXLOADER
as
procedure LOAD(P_PARAMETERS XMLTYPE, P_DATASOURCE BFILE);
end;
create or replace package body SAXLOADER
as
procedure LOAD(P_PARAMETERS XMLTYPE, P_DATASOURCE BFILE)
AS
LANGUAGE JAVA
NAME 'com.oracle.st.xmldb.pm.saxLoader.SaxProcessor.saxLoader ( oracle.xdb.XMLType, oracle.sql.BFILE)';
end;
public static void saxLoader(XMLType parameterSettings, BFILE dataSource)
throws Exception {
Document parameters = parameterSettings.getDocument();
SaxProcessor app = new SaxProcessor(parameters);
app.processXMLFile(dataSource);
Edited by: mdrake on Apr 6, 2009 11:28 AM -
Viewing stored proc source code
Ok, now how do I view the source of a stored proc in SQL Developer?
I have tried:
select source from user_sources
select source from all_sources
select * from dba_sources
ALL are coming back with table or view does not exist.
If I try this:
select procedure_name from dba_procedures;
I get all the procedures but how can I view the source code for any one of them?
Sorry, again, I have been away from oracle for over 4 years. I am trying to re-acquaint myself with oracle again starting with the most basic stuff.
Thanks in advancehi,
Sorry, I don't understand your question.
I can see the package or procedure name but it doesn't show the source code.
I know that in sql* plus, if you say:
select source from all_source, it displays the source code but I want to see if that is possible in sql developer environment.
Maybe you are looking for
-
how do I wipe my iphone4S as I've followed the suggested support papers up to number 5, but it's not working. I have forgotten my passcode and I know I will be to wipe the iphone but I can't find any instructions that actually work. PLEASE HELP
-
Can we change the look and feel of the screen layout
Dear All, I am new to ABAP WebDynpro, and would like to know the following with respect to ABAP WebDynpro : 1. To what extent can we change the look and feel of the screen layout ? 2. Is it possible to change the background color of the layout? 3. Is
-
I have a new Nokia 5300, before it i use a SOny Ericcson W600i fully compatible with Mac Os X and iSync never had problem and the compatibility is awesom easy to use. Now in This case with Nokia 5300 i can't find software to make it compatible in a a
-
Incoming email configurations, what is missing?
I have configured incoming email settings in CA (System > Incoming email) and created SMTP service in Server Manager. I have also checked settings in IIS Manager > SMTP Virtual Server and set Properties > Access > Relay: Granted Access for IP address
-
Having trouble deciding on a point and shoot camera.
I have been searching for a point and shoot camera and I have narrowed it down to two cameras. The cameras that I'm looking at are the Cannon Powershot SX510 HS 12.1mp with a 30x optical zoom and the other one is the Fujifilm FinePix S8200 16.2mp wi