MSSQL Stored Procedure has duplicate OUT parameter
Hi All;
I am using the WLS MSSQL jdbc driver (mssqlserver4v70rel510sp8) for wls
5.1 sp 12. The following code generates a duplicate OUT parameter.
Parameters 4 and 5 are duplicated. I went over the stored procedure in
ISQL, and the problem is not occurring there. Has anyone seen this sort of
problem? I noticed this problem does not occur when I have the "?=" in
front.
stmt = con.prepareCall("{ ?= call webactivate..ValidatePromoCode(?, ?,
stmt.registerOutParameter(1, java.sql.Types.INTEGER);
stmt.setString(2, marketingCode);
stmt.setString(3, activationData.getRawServiceNumber());
stmt.registerOutParameter(4, java.sql.Types.VARCHAR);
stmt.registerOutParameter(5, java.sql.Types.INTEGER);
stmt.registerOutParameter(6, java.sql.Types.INTEGER);
stmt.execute();
Log.putDebug("#1="+stmt.getString(1));
Log.putDebug("#4="+stmt.getString(4));
Log.putDebug("#5="+stmt.getString(5));
Log.putDebug("#6="+stmt.getString(6));
Paul Rowe
Thanks Joseph. I was hoping you would get back to me on this. You are the
king of this newsgroup. Here's what I got, which indicates some type of
problem on my end:
Update count = 1
Update count = 1
Update count = 1
Update count = 1
Update count = 1
Output status: 4
Output param 1: 4
Output param 2: marketingCode activationData.getRawServiceNumber()
Output param 3: 2
"Joseph Weinstein" <[email protected]> wrote in message
news:[email protected]...
Paul Rowe wrote:
Hi All;
I am using the WLS MSSQL jdbc driver (mssqlserver4v70rel510sp8) for
wls
5.1 sp 12. The following code generates a duplicate OUT parameter.
Parameters 4 and 5 are duplicated. I went over the stored procedure in
ISQL, and the problem is not occurring there. Has anyone seen this sortof
problem? I noticed this problem does not occur when I have the "?=" in
front.Hi Paul. Please run this sample program below with the driver you have,and
let me know the output. it works with the latest driver I have. I get:
C:\joe\70bugs>java foo
Update count = 1
Output status: 4
Output param 1: marketingCode activationData.getRawServiceNumber()
Output param 2: 2
Output param 3: 3
The code:
import java.sql.*;
import java.util.*;
class foo {
public static void main(String[] args) throws Exception
Properties props = new Properties();
props.put("user", "sa");
props.put("password", "");
props.put("server", "natoma");
try {
Driver myDriver = (Driver)
Class.forName("weblogic.jdbc.mssqlserver4.Driver").newInstance();
Connection con = myDriver.connect("jdbc:weblogic:mssqlserver4",props);
>
String proc = "create proc foojoe @bar varchar(60), @qwevarchar(60), "
+ " @asd varchar(60) output, @zxc int output, @ert intoutput "
+ " as select @asd = @bar + @qwe select @zxc = 2 select@ert = 3 "
+ " return 4";
Statement s = con.createStatement();
try { s.executeUpdate("drop proc foojoe"); } catch (Exceptionignore){}
s.executeUpdate(proc);
CallableStatement stmt = con.prepareCall("{ ?= callfoojoe(?,?,?,?,?) }");
stmt.registerOutParameter(1, java.sql.Types.INTEGER);
stmt.setString(2, "marketingCode");
stmt.setString(3, " activationData.getRawServiceNumber()");
stmt.registerOutParameter(4, java.sql.Types.VARCHAR);
stmt.registerOutParameter(5, java.sql.Types.INTEGER);
stmt.registerOutParameter(6, java.sql.Types.INTEGER);
stmt.execute();
while (true) // how to handle any callable statement...
ResultSet rs = stmt.getResultSet();
int updateCount = stmt.getUpdateCount();
// If there are no more results or counts, we're done.
if (rs == null && updateCount == -1)
break;
// Check to see if there is a ResultSet
if (rs != null) {
while (rs.next()) {
System.out.println("Get first resultset col by id:" +rs.getString(1));
rs.close();
} // Otherwise, there will be an update count
else {
System.out.println("Update count = " + updateCount);
stmt.getMoreResults();
// Best to retrieve status and output parameters
// after all result sets and update counts have been retrieved.
System.out.println( "Output status: " + stmt.getInt(1));
System.out.println( "Output param 1: " + stmt.getString(4));
System.out.println( "Output param 2: " + stmt.getString(5));
System.out.println( "Output param 3: " + stmt.getString(6));
catch(Exception e) { e.printStackTrace(); }
Similar Messages
-
How to execute a stored procedure with an out parameter ?
Guys I am struggling with executing a stored procedure from sql plus.I mean my stored procedure has 2 input parameter and 1 out put parameter (status of the execution).
MY_PROCEDURE(p_name in varchar2,p_age in number,p_status out varchar2)
end my_procedure;
When I say
EXECUTE MY_PROCEDURE('manohar','Shetty');
i get insufficient parameters errors.
please help.EXECUTE isn't a valid PL/SQL construct. It's a SQL*Plus command. You don't want to put any SQL*Plus commands in a PL/SQL block.
You can always execute a stored procedure purely through PL/SQL
begin
my_stored_procedure( x, y, z );
end;SQL*Plus happens to give you the execute command so you can avoid the begin and end statements.
Justin -
ORABPEL-11809 - call a stored procedure - error in OUT parameter
Hi all.
I have a problem in a BPEL process that calls a stored procedure.
I create a Partner Link that calls a stored procedure in the database. That procedure returns a type that is a table (is defined as a type of the database).
When I deploy the process I have the following error:
<messages>
- <input>
- <WC01_Pesquisa_Ut_InputVariable>
- <part xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" name="InputParameters">
- <InputParameters xmlns="http://xmlns.oracle.com/pcbpel/adapter/db/IGIF/WC01/PESQUISA_UT/">
<P_NIR xmlns="">
165968274
</P_NIR>
<P_NOME_COMPLETO xmlns="">
carla diogo
</P_NOME_COMPLETO>
<P_SEXO xmlns="">
Feminino
</P_SEXO>
<P_DATA_NASC xmlns="">
2007-03-01
</P_DATA_NASC>
<P_NATURALIDADE xmlns=""/>
</InputParameters>
</part>
</WC01_Pesquisa_Ut_InputVariable>
</input>
- <fault>
- <remoteFault xmlns="http://schemas.oracle.com/bpel/extension">
- <part name="code">
<code>
17002
</code>
</part>
- <part name="summary">
<summary>
file:/oracle/product/10.1.3/SOA/Integration10131/bpel/domains/default/tmp/.bpel_SaudeIdentificarCidadao_5.0_e3768f57d137443e1ba52d4a6d809426.tmp/WC01_Pesquisa_Ut.wsdl [ WC01_Pesquisa_Ut_ptt::WC01_Pesquisa_Ut(InputParameters,OutputParameters) ] - WSIF JCA Execute of operation 'WC01_Pesquisa_Ut' failed due to: Error registering an out parameter.
An error occurred when registering parameter PESQUISA_UT as an out parameter of the IGIF.WC01.PESQUISA_UT API. Cause: java.sql.SQLException: Io exception: Connection reset [Caused by: Io exception: Connection reset]
; nested exception is:
ORABPEL-11809
Error registering an out parameter.
An error occurred when registering parameter PESQUISA_UT as an out parameter of the IGIF.WC01.PESQUISA_UT API. Cause: java.sql.SQLException: Io exception: Connection reset [Caused by: Io exception: Connection reset]
Check to ensure that the parameter is a valid IN/OUT or OUT parameter of the API. Contact oracle support if error is not fixable.
</summary>
</part>
- <part name="detail">
<detail>
Internal Exception: java.sql.SQLException: Io exception: Connection resetError Code: 17002
</detail>
</part>
</remoteFault>
</fault>
</messages>
The code of the XSD created when I create the partner link is:
<schema targetNamespace="http://xmlns.oracle.com/pcbpel/adapter/db/IGIF/WC01/PESQUISA_UT/" xmlns="http://www.w3.org/2001/XMLSchema" xmlns:db="http://xmlns.oracle.com/pcbpel/adapter/db/IGIF/WC01/PESQUISA_UT/"
elementFormDefault="unqualified" attributeFormDefault="unqualified">
<element name="InputParameters">
<complexType>
<sequence>
<element name="P_NIR" type="decimal" db:index="1" db:type="NUMBER" minOccurs="0" nillable="true"/>
<element name="P_NOME_COMPLETO" type="string" db:index="2" db:type="VARCHAR2" minOccurs="0" nillable="true"/>
<element name="P_SEXO" type="string" db:index="3" db:type="VARCHAR2" minOccurs="0" nillable="true"/>
<element name="P_DATA_NASC" type="dateTime" db:index="4" db:type="DATE" minOccurs="0" nillable="true"/>
<element name="P_NATURALIDADE" type="string" db:index="5" db:type="VARCHAR2" minOccurs="0" nillable="true"/>
</sequence>
</complexType>
</element>
<element name="OutputParameters">
<complexType>
<sequence>
<element name="PESQUISA_UT" type="db:TABELA_DE_IDS" db:index="0" db:type="Array" minOccurs="0" nillable="true"/>
</sequence>
</complexType>
</element>
<complexType name="TABELA_DE_IDS">
<sequence>
<element name="PESQUISA_UT_ITEM" type="decimal" db:type="NUMBER" minOccurs="0" maxOccurs="unbounded" nillable="true"/>
</sequence>
</complexType>
</schema>
Any ideia?
Thanks in advance.
CarlaI'd suggest that you turn on xml validation on the bpel boundaries to make sure that the xml being passed to the adapter is valid. You do this by logging in to bpel console, go to Manage Domain, at the bottom of the Configuration tab, set validateXml to true.
Then see if it is an xml validation issue - in which case you will have to fix your maps to make sure it is valid indeed.
Assuming your XML is valid and you are still seeing this error, couple of follow up questions:
- are you using synonyms ?
-- note that synonyms are not supported completely by the adapter at this time.
- could you spell out where your types/sp-pkg resides and what are you connecting as at runtime ?
-- just to keep things simple enough to debug, i'd do everything as just one user and slowly go to a scheme that you desire.
HTH -
Stored Procedure with in out parameter of table of records type
Hi
I am tring to create a strore procedure inside a package like this:
procedure name_p(root in table.column%type, tab in out table_of_records_type);
I get the error:
PLS-00306: Wrong number or types of arguments in call to 'name_p'
I am working with oracle 8.1.7.
I dont really understand why this is happening.
Can anyone suggest anything.
Thnx
EdAn example :
TEST@db102 SQL> select ename, job from emp
2 where empno = 7902;
ENAME JOB
FORD ANALYST
TEST@db102 SQL> create or replace procedure show_emp (
2 v_empno in number,
3 v_ename out varchar2,
4 v_job out varchar2 )
5 is
6 begin
7 select ename, job into v_ename, v_job
8 from emp
9 where empno = v_empno;
10 end;
TEST@db102 SQL> /
Procedure created.
TEST@db102 SQL> exit
Disconnected from Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options
[ora102 work db102]$ IN=7902
[ora102 work db102]$ set `sqlplus -s test/test@db102 << !
var out1 varchar2(30);
var out2 varchar2(30);
set pages 0
set feed off
exec show_emp($IN,:out1,:out2);
print
exit
`[ora102 work db102]$ echo $1 $2
FORD ANALYST
[ora102 work db102]$ -
Calling a stored procedure with an XmlType parameter.
I am attempting to execute a stored function via a named query. The stored procedure has a single parameter of Oracles 'xmltype', and also returns an xmltype. For example this dummy function
function testXML(xml_in xmltype) return xmltype is
begin
return xml_in;
end;
Is it possible to make the named query call with an oracle.xdb.XMLType or oracle.xdb.dom.XDBDocument? I cannot find any examples of this being done. I also want the returning xmltype to be converted into a Java class.
Another question - will I need to work with a conversion manager to achieve this?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: Invalid column typeError Code: 17004
Call:BEGIN ? := TestPackage.testXML(XML_IN=>?); END;
bind => [=> RESULT, oracle.xml.parser.v2.XMLDocument@1a64732 => XML_IN]
Query:DataReadQuery()
at oracle.toplink.exceptions.DatabaseException.sqlException(DatabaseException.java:290)
at oracle.toplink.internal.databaseaccess.DatabaseAccessor.basicExecuteCall(DatabaseAccessor.java:570)
at oracle.toplink.internal.databaseaccess.DatabaseAccessor.executeCall(DatabaseAccessor.java:442)
at oracle.toplink.threetier.ServerSession.executeCall(ServerSession.java:453)
at oracle.toplink.internal.queryframework.DatasourceCallQueryMechanism.executeCall(DatasourceCallQueryMechanism.java:117)
at oracle.toplink.internal.queryframework.DatasourceCallQueryMechanism.executeCall(DatasourceCallQueryMechanism.java:103)
at oracle.toplink.internal.queryframework.DatasourceCallQueryMechanism.executeSelectCall(DatasourceCallQueryMechanism.java:174)
at oracle.toplink.internal.queryframework.DatasourceCallQueryMechanism.executeSelect(DatasourceCallQueryMechanism.java:156)
at oracle.toplink.queryframework.DataReadQuery.executeNonCursor(DataReadQuery.java:118)
at oracle.toplink.queryframework.DataReadQuery.executeDatabaseQuery(DataReadQuery.java:110)
at oracle.toplink.queryframework.DatabaseQuery.execute(DatabaseQuery.java:603) -
Stored Procedure w/ binary data parameter problems in Visual Basic
Howdy all.
I am having a problem calling stored procedures with a BLOB parameter. I have tried changing the paramater other data types to see if it would work, but with no success. I am calling the stored procedure from Visual Basic using ADO. I am using the Oracle ODBC Driver, Release 9.2.0.4.0. I have tried changing the setup of the ODBC a good bit because that has fixed several problems for me in the past; however, it did not fix my current problem.
Here is what I am trying to do. I have a function like the folowing:
<BEGIN --------------------------------------->
CREATE OR REPLACE FUNCTION PAGEFORMATSINSERT(
p_ObjectFormatCode_ID IN RAW DEFAULT NULL,
p_PA_ID IN RAW DEFAULT NULL,
p_Name IN VARCHAR2 DEFAULT NULL,
p_FormatData IN BLOB DEFAULT NULL,
p_PF_ID IN OUT RAW )
RETURN INTEGER
AS
BEGIN
INSERT INTO PAGEFORMATS (PF_ID, ObjectFormatCode_ID, PA_ID, Name, FormatData) /* <---- this FormatData column is a BLOB column */
VALUES (p_PF_ID, p_ObjectFormatCode_ID, p_PA_ID, p_Name, p_FormatData)
END PAGEFORMATSINSERT;
<END ----------------------------------------->
The FormatData parameter has a data type of BLOB. In my Visual Basic, I have my ADODB.Command object. I am setting the CommandText of the Command object to "{? = call PageFormatsInsert(?, ?, ?, ?, ?)}". In order to set the parameter value for the BLOB data type, I am calling the AppendChunk function of the Command object - passing it a Byte array.
I am getting the folling error:
ERROR: -2147467259 [Oracle][ODBC][Ora]ORA-06550: line 1, column 13:
PLS-00306: wrong number or types of arguments in call to 'PAGEFORMATSINSERT'
ORA-06550: line 1, column 7:
PL/SQL: Statement ignored
If I change the FormatData parameter to a LONG RAW parameter, I get the following error:
ERROR: -2147467259 [Oracle][ODBC][Ora]ORA-06502: PL/SQL: numeric or value error: hex to raw conversion error
ORA-06512: at line 1
I am at a loss as to how to get binary data into by Oracle database. I need to do it using stored procedures. How can I set up my stored procedure or table to do what I want it to do? Should I change my table definition? Are there some settings in the ODBC connection I can tweak? How can I get the stored procedure to accept my call from VB ADO?
Any help would be appreciated.
wallyThanks for the idea, but I don't get how I am supposed to get my binary data to the stored procedure using the stream. I have a binary array that I want to pass to a stored procedure. I want to be able to use the same Visual Basic front end with out MSSQL database as with our Oracle database.
I am using the ADODB Connection and Command and RecordSet objects. Currenlty our front end calls the ADODB.Command(ParamNumber).AppendChunk function passing it the binary array. Somehow, the SQL Server driver does the magic in order for the MSSQL stored procedure to work correctly. I need to know how to do one of the following:
1. Get the Oracle driver to do the same magic.
2. Set up the Oracle stored procedure so I don't have to change the VB front end.
3. Change the VB front end so that it works with both MSSQL and Oracle.
wally -
How to call a oracle procedure with in/out parameter frm unix shell script?
Hi,
I need to call an oracle stored procedure from unix script. The procedure has 1 input parameter and 2 output parameter. Please send me the syntax for the same. Based on the output values of procedure, I have to execute some more commands in unix script.
Thanks and regards
AAn example :
TEST@db102 SQL> select ename, job from emp
2 where empno = 7902;
ENAME JOB
FORD ANALYST
TEST@db102 SQL> create or replace procedure show_emp (
2 v_empno in number,
3 v_ename out varchar2,
4 v_job out varchar2 )
5 is
6 begin
7 select ename, job into v_ename, v_job
8 from emp
9 where empno = v_empno;
10 end;
TEST@db102 SQL> /
Procedure created.
TEST@db102 SQL> exit
Disconnected from Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options
[ora102 work db102]$ IN=7902
[ora102 work db102]$ set `sqlplus -s test/test@db102 << !
var out1 varchar2(30);
var out2 varchar2(30);
set pages 0
set feed off
exec show_emp($IN,:out1,:out2);
print
exit
`[ora102 work db102]$ echo $1 $2
FORD ANALYST
[ora102 work db102]$ -
MSSQL stored procedures to Oracle migration
I am working on a migration from MSSQL2K to Oracle 10g. I have used the Oracle Migration Workbench to do the initial conversion, and I am having to do a ton of by hand conversion. There are some stored procedures that the OMWB did not bring over at all, however.
Does anybody know of a utility that can take a single MSSQL stored procedure and convert it to a Oracle PL/SQL procedure or function? I am somewhat tired of doing entire procedures by hand. It is very tedious.
wallyWally, there is a process to this kind of migration. In a lot of instances the OMWB will not map some of your stored procedures and hence, at the end of the migration you will see them as missing. Go back to the Source model view and using the log window, filter so you just see the errrors. Comment out the offending statements and right click on the object to parse it again. If it is correct it will appear in the Oracle Model. Once it has appeared there it will be generated into your Oracle database. However, you may still need to verifiy that you have got equivilence by testing the procedure.
-
MSSQL Stored procedure : only one command executed
For a MSSQL Stored Procedure, We have used this
Solution1:
Just put SET NOCOUNT OFF in the end of the stored procedure. After that run the stored procedure in the Desktop Intelligence report.
Or
If the above doesnu2019t works then please try the following solution.
Solution2:
You have to add the given parameter in .sbo file -> save the file and run the stored Procedure.
This file should be located under <drive>\Business Objects\BusinessObjects Enterprise 11.5\dataAccess\RDBMS\connectionServer\odbc\odbc.sbo
<Defaults>
<Parameter Name="Force SQLExecute">Always</Parameter>
but it still does not work
What others?Hello
thank you for your answer but indicated procedure to test does not work too
the message is the same : u201CNo column and no data to fetchu201D
I return with more details :
to create a new report DesKi, I use this stored procedure
CREATE PROCEDURE dbo.test1 @matricule integer
AS
BEGIN
SET NOCOUNT OFF
delete from Temp_matr_boucle
execute absences_matricules_per_matr @matricule /* it is ok */
select MATRICULE ,NOM ,PRENOM ,CDDEP, NBR_PERIODE, NBR_JOURS , UNITE ,
DATE_MIN, DATE_MAX ,TYPE_ABSENCE, MATRICULE_CAR, NBR_JOURS_SERVICES
from Temp_matr_boucle as result /* not execute */
return
END
Launched directly from the database it work verry well.
Launched in Deski rapport, we get the same message
u201CNo column and no data to fatchu201D
The exec command works because the table "Temp_matr_boucle" is filled but is no longer running the select commande.
You have advisor to use one a two solutions (see replay from DWinkel)
1) SET NOCOUNT OFF
or
2) add the parameter:
<Defaults>
<Parameter Name="Force SQLExecute">Always</Parameter> in odbc.sbo file
Note that we use the OLEDB driver and not the odbc
We all tried both but the result is the same
thank you for your help
regards
Mariana -
How to convert MSSQL stored procedure to PostgreSQL
Hi,
Anyone can help me...?
How to convert MSSQL stored procedure to PostgreSQL function?
Is there any tool available to convert T-SQL from MSSQL to PostgreSQL?
Thanks in advanceHello
Here, I write one sample stored procedure of SQL Server which I need to convert into PostgreSQL. Please help me in this with PostgreSQL.
Thanks in advance.
Below is sample SQL Server stored procedure: require to convert into PostgreSQL stored procedure
CREATE PROCEDURE [dbo].[usp_GetData_ByTableName]
@TableName NVARCHAR(MAX)
,@IncludeKeepAlive BIT
,@RowsAffected BIGINT=0 OUTPUT
) AS
BEGIN
SET NOCOUNT ON
DECLARE @SQL VARCHAR(MAX)
Select data base on parameter.
SET @SQL =
SELECT *FROM '+@TableName+'
WHERE 1=1
+
CASE WHEN (@IncludeKeepAlive = 0)
THEN
AND [MessageTransactionID] <> 152
ELSE
END
EXECUTE SP_EXECUTESQL @SQL
RETURN 0 -
How to call MSSQL stored procedure from oracle database
MSSQL and Oracle databases are linked thru ODBC link using Oracle HSODBC.
I can query MSSQL table or view from Oracle Database using standard notation for acessing remote objects schema.object@dblink_name...
Can anybody give me syntax for calling MSSQL stored procedure thru ODBC database link?
I tried syntax exec schema.stored_procedure@dblink_name but it doesn't work...i'm getting schema.stored_procedure must be declared error...
Tnx,in advance!
Dejan BoticaOracle database 10gR2.
MSSQL2000 database.
For example query:
select * from dbo.Tbl_Test@kron@dw_jamnica; works fine...
...while for example exec dbo.Test@kron@dw_jamnica;
reports error:
ORA-06550: line 1, column 7:
PLS-00201: identifier 'DBO.TEST@KRON@DW_JAMNICA' must be declared
ORA-06550: line 1, column 7:
PL/SQL: Statement ignored
Table Tbl_Test and procedure Test exists in MSSQL instance.
Regards,
Dejan -
How to change stored procedure with Table Valued Parameter
I am not sure how to change the normal stored procedure with Table Value Parameter.Do I have to create a separate Table or do I have to create a datatype. Can you please help me with this
ALTER PROCEDURE [dbo].[uspInsertorUpdateINF]
@dp_id char(32),
@dv_id char(32),
@em_number char(12),
@email varchar(50),
@emergency_relation char(32),
@option1 char(16),
@status char(20),
@em_id char(35),
@em_title varchar(64),
@date_hired datetime
AS
BEGIN
SET NOCOUNT ON;
MERGE [dbo].[em] AS [Targ]
USING (VALUES (@dp_id, @dv_id , @em_number, @email, @emergency_relation, @option1, @status, @em_id, @em_title, @date_hired))
AS [Sourc] (dp_id, dv_id, em_number, email, emergency_relation, option1, status, em_id, em_title, date_hired)
ON [Targ].em_id = [Sourc].em_id
WHEN MATCHED THEN
UPDATE
SET dp_id = [Sourc].dp_id,
dv_id = [Sourc].dv_id,
em_number = [Sourc].em_number,
email = [Sourc].email,
emergency_relation = [Sourc].emergency_relation,
option1 = [Sourc].option1,
status = [Sourc].status,
em_title = [Sourc].em_title,
date_hired = [Sourc].date_hired
WHEN NOT MATCHED BY TARGET THEN
INSERT (dp_id, dv_id, em_number, email, emergency_relation, option1, status, em_id, em_title,date_hired)
VALUES ([Sourc].dp_id, [Sourc].dv_id, [Sourc].em_number, [Sourc].email, [Sourc].emergency_relation, [Sourc].option1, [Sourc].status, [Sourc].em_id, [Sourc].em_title, [Sourc].date_hired);
END;It's not clear how you would change the procedure. But assuming that you want to replace the existing scalar parameters with tabular input, this is how you would do it. You first create a table type:
CREATE TYPE Insertor_type AS TABLE
(dp_id char(32),
dv_id char(32),
em_number char(12),
email varchar(50),
emergency_relation char(32),
option1 char(16),
status char(20),
em_id char(35),
em_title varchar(64),
date_hired datetime)
Then you change the procedure header:
ALTER PROCEDURE [dbo].[uspInsertorUpdateINF] @tvp Insertor_type READONLY AS
And finally you change the USING clause:
USING (SELECT dp_id, dv_id , em_number, email, emergency_relation, option1, status, em_id, em_title, date_hired
FROM @tvp) AS [Sourc] ON [Targ].em_id = [Sourc].em_id
The rest is fine as it is.
Erland Sommarskog, SQL Server MVP, [email protected] -
Get more the one records in procedure by using out parameter
Hi good evening every body,
how to get more the one records in procedure by using out parameter ,
give me one example of it.
regards
subbaLike this ?
SQL> set serverout on
SQL> declare
2 v_empno dbms_sql.Number_Table;
3 v_ename dbms_sql.Varchar2_Table;
4 PROCEDURE P1(p_in_deptno IN emp.deptno%TYPE,
5 p1_out OUT dbms_sql.Number_Table,
6 p2_out OUT dbms_sql.Varchar2_Table) IS
7 BEGIN
8 SELECT empno, ename BULK COLLECT
9 INTO p1_out, p2_out
10 FROM emp
11 WHERE deptno = p_in_deptno;
12 END;
13 BEGIN
14 P1(20, v_empno, v_ename);
15 FOR i in 1 .. v_ename.COUNT LOOP
16 dbms_output.put_line(v_empno(i) || '--' || v_ename(i));
17 END LOOP;
18 END;
19 /
7369--SMITH
7566--JONES
7788--SCOTT
7876--ADAMS
7902--FORD
7941--ABCDEFGHIJKLMNOPQRSTUVWXYZAAAAAA
7942--MY#@ ' "ABC
PL/SQL procedure successfully completed.
{code} -
Calling Stored Procedure with Boolean Output Parameter
Hi all,
I'm running into an issue (or is it a BUG) when calling a Database Stored Procedure that has an output parameter of the boolean type.
procedure proc(p_text in varchar2, p_result out boolean)
is
.....I use the following 'standard' code (developer guide 36-19 36-20) to invoke this procedure from my application module.
try {
// 1. Define the PL/SQL block for the statement to invoke
String stmt = "begin proc(?,?); end;";
// 2. Create the CallableStatement for the PL/SQL block
st = getDBTransaction().createCallableStatement(stmt, 0);
// 3. Register the positions and types of the OUT parameters
st.registerOutParameter(2, Types.BOOLEAN);
// 4. Set the bind values of the IN parameters
st.setObject(1, "Some text");
// 5. Execute the statement
st.executeUpdate();
..............................As soon as 'st.registerOutParameter(2, Types.BOOLEAN);' is invoked I run into a SQLexception. "Invalid ColumnType: 16". Obviously 16 refers to Types.BOOLEAN.
[edit by Luc]
SOLUTION / WORKAROUND
To answer my own question.
It looks like BOOLEAN output parameters are not supported. I just Read "Appendix D Troubleshooting" of the Oracle® Database JDBC Developer's Guide and Reference 10g Release 2 (10.2).
I found that JDBC drivers do not support the passing of BOOLEAN parameters to PL/SQL stored procedures. If a PL/SQL procedure contains BOOLEAN values, you can work around the restriction by wrapping the PL/SQL procedure with a second PL/SQL procedure that accepts the argument as an INT and passes it to the first stored procedure. When the second procedure is called, the server performs the conversion from INT to BOOLEAN.
I'm not very happy with this but I guess I've no choice.
Regards Luc
Edited by: lucbors on Nov 30, 2010 10:37 AMfyi
Related to the solution/workaround posted by Luc.
see "Do Oracle's JDBC drivers support PL/SQL tables/result sets/records/booleans? "
at http://www.oracle.com/technetwork/database/enterprise-edition/jdbc-faq-090281.html#34_05
regards
Jan Vervecken -
Stored Procedure with Input & output parameter as XML
Hi
I have a requirement wherein i need to have a stored procedure with accepts huge XML from Java and the SP has to process all the records in the XML and return XML output with some messages in it.
Currenty, I have a stored procedure to process the xml stored in Oracle Database.
I am using the following SQL statement to read the data from the XML column.
select xmltest1.id,xmltest1.name
from xmltest,
XMLTABLE(
XMLNamespaces(default 'syncpsna/schemas'),
'/XMLTestRequest/insert/row'
PASSING xmltest.data_xml
COLUMNS
"ID" number(10) PATH 'id',
"NAME" varchar2(50) PATH 'name') xmltest1
where xmltest.id = 2;I want to execute similary queries to fetch data from the XML Passed as an input parameter from JAVA.
if i could get some examples of reading the XML and sending the xml back to the calling program.
RegardsHi,
if i could get some examples of reading the XML and sending the xml back to the calling program.What kind of process do you want to perform on the input XML?
You said "reading", but for what purpose? Storing data in the database, or just transform the XML into another form?
Anyway, you'll probably need a function, something like :
create or replace function processXML (inputXML in xmltype)
return xmltype
is
outputXML xmltype;
begin
-- process inputXML here, and construct outputXML
return outputXML;
end;Back in Java, you can use the oracle.xdb.XMLType class to map the XMLType SQL datatype to a Java object and manipulate it.
Maybe you are looking for
-
Hi all , i want to save a text file on user local sytem without user interaction usiing file Refrence class in flash , how it could be do that ,please help me out frm this probelm,any suggestion will be thankful for me ..)
-
I phone6 cannot see photo in icould
I just bought iphone 6 and i have iapd2 I cannot see my photo on i phone6 but in ipad 2 no problem when i take a photo from iphone 6 i can see in ipad2 but for i phone 6 i cannot see photo from iclound or photo stream now in iphone6 i can see history
-
Reference data from another sheet
Hey everybody, I am sorry to post here if it has been previously posted. I am looking to use a conditional format a cell with a value less than 84 to be changed to red. I am using the iPad. I also need to reference data from another worksheet. Thank
-
Hi everyone, When I edit the Interactive form (adobe), I do not see the designer. What should I do ? Thanks.
-
Flash player not playing with embeded video on blog
the youtube video is not able to play in my blog Interventional Radiology Medical Coding when the html code in inserted in blog post please help