Body of stored procedure
How i can see the body of the Procedure and View, the original script from which it is created.
Thanks,
Harish
For the procedure you can look at USER_SOURCE or ALL_SOURCE (make sure order by line)
For views
set long 4000
select * from user_views; (or all_views)
Similar Messages
-
Mail sent from stored procedure: empty body
I've got a problem with a stored procedure. Its task is sending an email to some recipients passed from an another procedure. The problem is that the body of the email is empty and I don't know why!
Here's the script of this procedure:
Thank you very much in advance for your time!
CREATE OR REPLACE PROCEDURE ETL.LANCIA_EMAIL_PARAM
p_IN_FROM in VARCHAR2 default null,
p_IN_TO in VARCHAR2 default null,
p_IN_TO2 in VARCHAR2 default null,
p_IN_TO3 in VARCHAR2 default null,
p_IN_TO4 in VARCHAR2 default null,
p_IN_TO5 in VARCHAR2 default null,
p_IN_TO6 in VARCHAR2 default null,
p_IN_TO7 in VARCHAR2 default null,
p_IN_TO8 in VARCHAR2 default null,
p_IN_TO9 in VARCHAR2 default null,
p_IN_TO10 in VARCHAR2 default null,
p_IN_TO11 in VARCHAR2 default null,
p_IN_TO12 in VARCHAR2 default null,
p_IN_TO13 in VARCHAR2 default null,
p_IN_TO14 in VARCHAR2 default null,
p_IN_TO15 in VARCHAR2 default null,
p_IN_TO16 in VARCHAR2 default null,
p_IN_TO17 in VARCHAR2 default null,
p_IN_TO18 in VARCHAR2 default null,
p_IN_TO19 in VARCHAR2 default null,
p_IN_TO20 in VARCHAR2 default null,
p_IN_TO21 in VARCHAR2 default null,
p_IN_TO22 in VARCHAR2 default null,
p_IN_OGG in VARCHAR2 default null,
p_IN_MSGEMAIL in VARCHAR2 default null
IS
--mailhost VARCHAR2(30) := 'smtp.xxx.it';
mailhost VARCHAR2(30) := 'notesrelay.sd.xxx.it'; /* ripristinato il 29/11/2010 da LdP per controllo ODM*/
-- dichiarazione di una variabile di tipo utl_smtp.connection
-- a cui verr? assegnato l'SMTP ed il numero di porta (25)
conn utl_smtp.connection;
crlf VARCHAR2( 2 ):= CHR( 13 ) || CHR( 10 );
mesg VARCHAR2( 32767 );
DATA_START varchar2(20) := TO_CHAR(SYSDATE,'DD-MM-YYYY');
IN_FROM VARCHAR2(30) := p_IN_FROM;
IN_TO VARCHAR2(300) := p_IN_TO ;
IN_TO2 VARCHAR2(300) := p_IN_TO2 ;
IN_TO3 VARCHAR2(300) := p_IN_TO3 ;
IN_TO4 VARCHAR2(300) := p_IN_TO4 ;
IN_TO5 VARCHAR2(300) := p_IN_TO5 ;
IN_TO6 VARCHAR2(300) := p_IN_TO6 ;
IN_TO7 VARCHAR2(300) := p_IN_TO7 ;
IN_TO8 VARCHAR2(300) := p_IN_TO8 ;
IN_TO9 VARCHAR2(300) := p_IN_TO9 ;
IN_TO10 VARCHAR2(300) := p_IN_TO10;
IN_TO11 VARCHAR2(300) := p_IN_TO11;
IN_TO12 VARCHAR2(300) := p_IN_TO12;
IN_TO13 VARCHAR2(300) := p_IN_TO13;
IN_TO14 VARCHAR2(300) := p_IN_TO14;
IN_TO15 VARCHAR2(300) := p_IN_TO15;
IN_TO16 VARCHAR2(300) := p_IN_TO16;
IN_TO17 VARCHAR2(300) := p_IN_TO17;
IN_TO18 VARCHAR2(300) := p_IN_TO18;
IN_TO19 VARCHAR2(300) := p_IN_TO19;
IN_TO20 VARCHAR2(300) := p_IN_TO20;
IN_TO21 VARCHAR2(300) := p_IN_TO21;
IN_TO22 VARCHAR2(300) := p_IN_TO22;
IN_OGG VARCHAR2(300) := p_IN_OGG ;
IN_MSGEMAIL VARCHAR2(30000) := p_IN_MSGEMAIL;
BEGIN
-- Apertura di una connessione al server
conn := utl_smtp.open_connection (mailhost,25);
-- Assegnazione alla variabile mesg dell'intestazione della mail
mesg:='Date:'||TO_CHAR(SYSDATE,'dd mon yy hh24:mi:ss')||crlf||
'From:<'||IN_FROM||'>'||crlf||
'Subject:'||IN_OGG||crlf;
-- if IN_TO2 is not null then
-- mesg:=mesg||'To:'||IN_TO||','||IN_TO2||crlf||'';
-- else
-- mesg:=mesg||'To:'||IN_TO;
-- end if;
If IN_TO22 is not null then
mesg:=mesg||'To:'||IN_TO||','||IN_TO2 ||','||IN_TO3 ||','||IN_TO4 ||','||IN_TO5 ||','||IN_TO6 ||','||IN_TO7 ||','||IN_TO8 ||','||IN_TO9 ||','||IN_TO10||','||IN_TO11||','||IN_TO12||','||IN_TO13||','||IN_TO14||','||IN_TO15||','||IN_TO16||','||IN_TO17||','||IN_TO18||','||IN_TO19||','||IN_TO20||','||IN_TO21||','||IN_TO22||crlf||'';
elsif IN_TO21 is not null then
mesg:=mesg||'To:'||IN_TO||','||IN_TO2 ||','||IN_TO3 ||','||IN_TO4 ||','||IN_TO5 ||','||IN_TO6 ||','||IN_TO7 ||','||IN_TO8 ||','||IN_TO9 ||','||IN_TO10||','||IN_TO11||','||IN_TO12||','||IN_TO13||','||IN_TO14||','||IN_TO15||','||IN_TO16||','||IN_TO17||','||IN_TO18||','||IN_TO19||','||IN_TO20||','||IN_TO21||crlf||'';
elsif IN_TO20 is not null then
mesg:=mesg||'To:'||IN_TO||','||IN_TO2 ||','||IN_TO3 ||','||IN_TO4 ||','||IN_TO5 ||','||IN_TO6 ||','||IN_TO7 ||','||IN_TO8 ||','||IN_TO9 ||','||IN_TO10||','||IN_TO11||','||IN_TO12||','||IN_TO13||','||IN_TO14||','||IN_TO15||','||IN_TO16||','||IN_TO17||','||IN_TO18||','||IN_TO19||','||IN_TO20||crlf||'';
elsif IN_TO19 is not null then
mesg:=mesg||'To:'||IN_TO||','||IN_TO2 ||','||IN_TO3 ||','||IN_TO4 ||','||IN_TO5 ||','||IN_TO6 ||','||IN_TO7 ||','||IN_TO8 ||','||IN_TO9 ||','||IN_TO10||','||IN_TO11||','||IN_TO12||','||IN_TO13||','||IN_TO14||','||IN_TO15||','||IN_TO16||','||IN_TO17||','||IN_TO18||','||IN_TO19||crlf||'';
elsif IN_TO18 is not null then
mesg:=mesg||'To:'||IN_TO||','||IN_TO2 ||','||IN_TO3 ||','||IN_TO4 ||','||IN_TO5 ||','||IN_TO6 ||','||IN_TO7 ||','||IN_TO8 ||','||IN_TO9 ||','||IN_TO10||','||IN_TO11||','||IN_TO12||','||IN_TO13||','||IN_TO14||','||IN_TO15||','||IN_TO16||','||IN_TO17||','||IN_TO18||crlf||'';
elsif IN_TO17 is not null then
mesg:=mesg||'To:'||IN_TO||','||IN_TO2 ||','||IN_TO3 ||','||IN_TO4 ||','||IN_TO5 ||','||IN_TO6 ||','||IN_TO7 ||','||IN_TO8 ||','||IN_TO9 ||','||IN_TO10||','||IN_TO11||','||IN_TO12||','||IN_TO13||','||IN_TO14||','||IN_TO15||','||IN_TO16||','||IN_TO17||crlf||'';
elsif IN_TO16 is not null then
mesg:=mesg||'To:'||IN_TO||','||IN_TO2 ||','||IN_TO3 ||','||IN_TO4 ||','||IN_TO5 ||','||IN_TO6 ||','||IN_TO7 ||','||IN_TO8 ||','||IN_TO9 ||','||IN_TO10||','||IN_TO11||','||IN_TO12||','||IN_TO13||','||IN_TO14||','||IN_TO15||','||IN_TO16||crlf||'';
elsif IN_TO15 is not null then
mesg:=mesg||'To:'||IN_TO||','||IN_TO2 ||','||IN_TO3 ||','||IN_TO4 ||','||IN_TO5 ||','||IN_TO6 ||','||IN_TO7 ||','||IN_TO8 ||','||IN_TO9 ||','||IN_TO10||','||IN_TO11||','||IN_TO12||','||IN_TO13||','||IN_TO14||','||IN_TO15||crlf||'';
elsif IN_TO14 is not null then
mesg:=mesg||'To:'||IN_TO||','||IN_TO2 ||','||IN_TO3 ||','||IN_TO4 ||','||IN_TO5 ||','||IN_TO6 ||','||IN_TO7 ||','||IN_TO8 ||','||IN_TO9 ||','||IN_TO10||','||IN_TO11||','||IN_TO12||','||IN_TO13||','||IN_TO14||crlf||'';
elsif IN_TO13 is not null then
mesg:=mesg||'To:'||IN_TO||','||IN_TO2 ||','||IN_TO3 ||','||IN_TO4 ||','||IN_TO5 ||','||IN_TO6 ||','||IN_TO7 ||','||IN_TO8 ||','||IN_TO9 ||','||IN_TO10||','||IN_TO11||','||IN_TO12||','||IN_TO13||crlf||'';
elsif IN_TO12 is not null then
mesg:=mesg||'To:'||IN_TO||','||IN_TO2 ||','||IN_TO3 ||','||IN_TO4 ||','||IN_TO5 ||','||IN_TO6 ||','||IN_TO7 ||','||IN_TO8 ||','||IN_TO9 ||','||IN_TO10||','||IN_TO11||','||IN_TO12||crlf||'';
elsif IN_TO11 is not null then
mesg:=mesg||'To:'||IN_TO||','||IN_TO2 ||','||IN_TO3 ||','||IN_TO4 ||','||IN_TO5 ||','||IN_TO6 ||','||IN_TO7 ||','||IN_TO8 ||','||IN_TO9 ||','||IN_TO10||','||IN_TO11||crlf||'';
elsif IN_TO10 is not null then
mesg:=mesg||'To:'||IN_TO||','||IN_TO2 ||','||IN_TO3 ||','||IN_TO4 ||','||IN_TO5 ||','||IN_TO6 ||','||IN_TO7 ||','||IN_TO8 ||','||IN_TO9 ||','||IN_TO10||crlf||'';
elsif IN_TO9 is not null then
mesg:=mesg||'To:'||IN_TO||','||IN_TO2 ||','||IN_TO3 ||','||IN_TO4 ||','||IN_TO5 ||','||IN_TO6 ||','||IN_TO7 ||','||IN_TO8 ||','||IN_TO9 ||crlf||'';
elsif IN_TO8 is not null then
mesg:=mesg||'To:'||IN_TO||','||IN_TO2 ||','||IN_TO3 ||','||IN_TO4 ||','||IN_TO5 ||','||IN_TO6 ||','||IN_TO7 ||','||IN_TO8 ||crlf||'';
elsif IN_TO7 is not null then
mesg:=mesg||'To:'||IN_TO||','||IN_TO2||','||IN_TO3||','||IN_TO4||','||IN_TO5||','||IN_TO6||','||IN_TO7||crlf||'';
elsif IN_TO6 is not null then
mesg:=mesg||'To:'||IN_TO||','||IN_TO2||','||IN_TO3||','||IN_TO4||','||IN_TO5||','||IN_TO6||crlf||'';
elsif IN_TO5 is not null then
mesg:=mesg||'To:'||IN_TO||','||IN_TO2||','||IN_TO3||','||IN_TO4||','||IN_TO5||crlf||'';
elsif IN_TO4 is not null then
mesg:=mesg||'To:'||IN_TO||','||IN_TO2||','||IN_TO3||','||IN_TO4||crlf||'';
elsif IN_TO3 is not null then
mesg:=mesg||'To:'||IN_TO||','||IN_TO2||','||IN_TO3||crlf||'';
elsif IN_TO2 is not null then
mesg:=mesg||'To:'||IN_TO||','||IN_TO2||crlf||'';
else
mesg:=mesg||'To:'||IN_TO;
end if;
mesg:=mesg||crlf||IN_MSGEMAIL;
-- Apertura di un collegamento al server
utl_smtp.helo(conn, mailhost);
-- Inizio di una transazione di posta con il server passandogli il mittente
utl_smtp.mail(conn,IN_FROM);
-- il destinatario
utl_smtp.rcpt(conn,IN_TO);
if IN_TO2 is not null then utl_smtp.rcpt(conn,IN_TO2 ); end if;
if IN_TO3 is not null then utl_smtp.rcpt(conn,IN_TO3 ); end if;
if IN_TO4 is not null then utl_smtp.rcpt(conn,IN_TO4 ); end if;
if IN_TO5 is not null then utl_smtp.rcpt(conn,IN_TO5 ); end if;
if IN_TO6 is not null then utl_smtp.rcpt(conn,IN_TO6 ); end if;
if IN_TO7 is not null then utl_smtp.rcpt(conn,IN_TO7 ); end if;
if IN_TO8 is not null then utl_smtp.rcpt(conn,IN_TO8 ); end if;
if IN_TO9 is not null then utl_smtp.rcpt(conn,IN_TO9 ); end if;
if IN_TO10 is not null then utl_smtp.rcpt(conn,IN_TO10); end if;
if IN_TO11 is not null then utl_smtp.rcpt(conn,IN_TO11); end if;
if IN_TO12 is not null then utl_smtp.rcpt(conn,IN_TO12); end if;
if IN_TO13 is not null then utl_smtp.rcpt(conn,IN_TO13); end if;
if IN_TO14 is not null then utl_smtp.rcpt(conn,IN_TO14); end if;
if IN_TO15 is not null then utl_smtp.rcpt(conn,IN_TO15); end if;
if IN_TO16 is not null then utl_smtp.rcpt(conn,IN_TO16); end if;
if IN_TO17 is not null then utl_smtp.rcpt(conn,IN_TO17); end if;
if IN_TO18 is not null then utl_smtp.rcpt(conn,IN_TO18); end if;
if IN_TO19 is not null then utl_smtp.rcpt(conn,IN_TO19); end if;
if IN_TO20 is not null then utl_smtp.rcpt(conn,IN_TO20); end if;
if IN_TO21 is not null then utl_smtp.rcpt(conn,IN_TO21); end if;
if IN_TO22 is not null then utl_smtp.rcpt(conn,IN_TO22); end if;
-- ed il testo del messaggio
utl_smtp.data(conn, mesg);
-- Chiusura della connessione
DBMS_OUTPUT.PUT_LINE(mesg);
utl_smtp.quit(conn);
EXCEPTION
WHEN OTHERS THEN
dbms_output.put_line(SQLERRM);
END;
/Horrible code.
Fact: when you REPEAT a variable or source code statement again and again - IT IS WRONG. It is not modularised. It is not robust, flexible, readable or maintainable.
The code should look as follows:
// a string array type is needed for dealing with multiple recipients - this
// can be defined as a SQL or PL/SQL type
// SQL type is used in the example as it is usable in both SQL and PL/SQL
// engines
create or replace type TStrings is table of varchar2(4000);
// the parameter signature and code for the procedure:
create or replace procedure EmailMessage(
senderAddress varchar2 default '[email protected]', --// the sender
recipientList TStrings, --// array of recipients
subject varchar2, --// subject of the mail
message varchar2 --// e-mail body to send
) is
begin
--// to build the TO string for the e-mail header
for i in 1..recipientList.Count loop
mesgTo := msgTo || recipientList(i);
if i < recipientList.Count then
mesgTo := msgTo || ',';
end if;
end loop;
--// create the complete e-mail body
--// (I would prefer a template string variable and
--// and replacing tokens in it with the subject,
--// recipients, sender, and so on
mailBody := 'Mime-Version: 1.0 '||utl_tcp.CrLf||
'Content-Type: text/plain'||utl_tcp.CrLf||
'Subject: nvs-web server'||utl_tcp.CrLf||
'To: '||mesgTo||utl_tcp.CrLf||
'From: '||senderAddress||utl_tcp.CrLf||
utl_tcp.CrLf||
message;
--// to specify the recipients to the SMTP server
for i in 1..recipientList.Count loop
utl_smtp.rcpt( conn, recipientList(i) );
end loop;
end;You should also consider using UTL_MAIL as it serves fine for sending basic e-mails, and basic e-mails with a single attachment. -
Dynamic sql and block based on a stored procedure
Hi!
I'm triying to generate a block based on a stored procedure. I want the stored procedure to execute a dynamic sql, but I'm having getting the error "PLS-00455 cursor 'AULOCASLATE' cannot be used in dynamic SQL OPEN statement".
I have the following code:
CREATE OR REPLACE package pkg_f0015 is
type rClieInstSlate is record
(clie_id CMS_CLIENTS.ID%type
,client_nm varchar2(1000)
,cs_no CMS_CLIENTS.CS_NO%type
,dob CMS_CLIENT_NAMES.BIRTH_DT%type);
type tClieInstSlate is table of rClieInstSlate;
type uClieInstSlate is ref cursor return rClieInstSlate;
procedure prLocationSlateQry(
auLocaSlate in out uClieInstSlate, anCsNo in CMS_CLIENTS.CS_NO%type,
avClieNm in varchar2,
avSearchType in varchar2,
avLotyCd in CMS_LOCATION_TYPES.CD%type);
end pkg_f0015;
CREATE OR REPLACE PACKAGE BODY pkg_cms_f0015 is
procedure PRLocationSlateQry( auLocaSlate in out uClieInstSlate,
anCsNo in CMS_CLIENTS.CS_NO%type,
avClieNm in varchar2,
avSearchType in varchar2,
avLotyCd in CMS_LOCATION_TYPES.CD%type) IS
vSelect varchar2(5000);
vAddCond varchar2(1000);
vSupLevel varchar2(50);
begin
vSelect := 'select clie.ID,'||
' CLIENT_NAME,'||
' clie.CS_NO,'||
' clna.BIRTH_DT dob'
' from CMS_CLIENT_NAMES clna,'||
'CMS_CLIENTS clie'||
' where clna.CLIE_ID = clie.ID';
if avSearchType= 'C' then
vAddCond := ' and clie.CS_NO = nvl('||anCsNo||',clie.CS_NO)';
vSelect := vSelect || vAddCond;
open auLocaSlate for vSelect;
end if;
end PRLocationSlateQry;
end;
I wonder if what I want is possibleOK,
Now it works. Previously we had the parameter p_guid declared as RAW, which obviously is not any good. :)
Radovan
Edited by: biciste on Apr 28, 2009 4:57 PM -
Passing CLOB datatype to a stored procedure
Hi,
How do I pass a CLOB value to a stored procedure?
I am creating a stored procedure which appends a value to a CLOB datatype. The procedure has 2 in parameter (one CLOB and one CLOB). The procedure is compiled but I'm having problem executing it. Below is a simplified version of the procedure and the error given when the procedure is executed.
SQL> CREATE OR REPLACE PROCEDURE prUpdateContent (
2 p_contentId IN NUMBER,
3 p_body IN CLOB)
4 IS
5 v_id NUMBER;
6 v_orig CLOB;
7 v_add CLOB;
8
9 BEGIN
10 v_id := p_contentId;
11 v_add := p_body;
12
13 SELECT body INTO v_orig FROM test WHERE id=v_id FOR UPDATE;
14
15 DBMS_LOB.APPEND(v_orig, v_add);
16 commit;
17 END;
18 /
Procedure created.
SQL> exec prUpdateContent (1, 'testing');
BEGIN prUpdateContent (1, 'testing'); END;
ERROR at line 1:
ORA-06550: line 1, column 7:
PLS-00306: wrong number or types of arguments in call to 'PRUPDATECONTENT'
ORA-06550: line 1, column 7:
PL/SQL: Statement ignored
Any help or hints please.
nullsorry I made a mistake with the in parameter types - it's one NUMBER and one CLOB.
-
Need sample source code for calling stored procedure in Oracle
Hi.
I try to call stored procedure in oracle using JCA JDBC.
Anybody have sample source code for that ?
Regards, Arnold.Thank you very much for a very quick reply. It worked, but I have an extended problem for which I would like to have a solution. Thank you very much in advance for your help. The problem is described below.
I have the Procedure defined as below in the SFCS1 package body
Procedure Company_Selection(O_Cursor IN OUT T_Cursor)
BEGIN
Open O_Cursor FOR
SELECT CompanyId, CompanyName
FROM Company
WHERE CompanyProvince IN ('AL','AK');
END Company_Selection;
In the Oracle Forms, I have a datablock based on the above stored procedure. When I execute the form and from the menu if I click on Execute Query the data block gets filled up with data (The datablock is configured to display 10 items as a tabular form).
At this point in time, I want to automate the process of displaying the data, hence I created a button and from there I want to call this stored procedure. So, in the button trigger I have the following statements
DECLARE
A SFCS1.T_Cursor;
BEGIN
SFCS1.Company_Selection(A);
go_Block ('Block36');
The cursor goes to the corresponding block, but does not display any data. Can you tell me how to get the data displayed. In the future versions, I'm planning to put variables in the WHERE clause. -
Retruring Multiple rows from a Stored Procedure
The Oracle JDBC documentation shows how to return a cursor pointer through the parameter list of a stored procedure allowing a Java program to use the cursor like a normal result set. I've tried it (using the thin driver) and it works fine - however, I'm having trouble getting this to work running the program under a Weblogic server (using their own JDBC implementation). So, I have two questions:
1) Has anyone had this problem before and solved it ??
2) Are there any other techniques for getting multiple rows back from the database without having to fire "raw" sql at it ?Hi
You could return not resultset but array, for example:
PACKAGE TEST:
type string_table is table of varchar2(80)
index by binary_integer;
function get_something (
something1 out string_table,
arraylength in number
) return number;
PACKAGE'S BODY:
function get_something (
something1 out string_table,
arraylength in number /** length of the array **/
) return number as
cursor C is
select something1, ...
from test_table;
pos number := 1;
begin
for position in C loop
exit when (pos > arraylength);
something1(pos) := position.something1;
pos := pos + 1;
end loop;
return (pos - 1);
end;
Of course in this example you need to know length of your array
(arraylength parameter), but you can avoid such problem, for
example, by using DBMS_SQL package (or dynamic SQL feature in
the Oracle8i).
Andrew
Mladen Gogala (guest) wrote:
: Phil Hildebrand (guest) wrote:
: : Is there a way that I can return multiple rows from a stored
: : procedure for function ?
: : Something like:
: : CREATE FUNCTION sp_get_children (my_nip IN port.nip_num%
TYPE)
: : RETURN my_nip
: : IS
: : CURSOR child_cur IS
: : SELECT nip_num
: : FROM logical_port
: : WHERE port_num = my_nip;
: : child_rec child_cur%rowtype;
: : BEGIN
: : FOR child_rec IN child_cur
: : LOOP
: : RETURN my_nip;
: : END LOOP;
: : END tmp_sp_get_children;
: : I know how to do it in Informix ( RETURN WITH RESUME ), but
: I'm
: : not running Informix ;)
: : Thanks,
: : Phil
: In contrast with Informix, SQL Server and Sybase, Oracle
: can not return a result set. the only workaround is to
: return the cursor variable as such.
null -
Retrieve a number from a stored procedure
I need to retrieve the number of rows returned from a query in a stored procedure. This is what I currently have:
PACKAGE PART_DATA AS
FUNCTION GetPartDataRowCount(Company IN PART_DATA.PART1_CO_SITE%TYPE) RETURN NUMBER;
END;
PACKAGE BODY PART_DATA AS
FUNCTION GetPartDataRowCount
Company IN PART_DATA.PART1_CO_SITE%TYPE
RETURN NUMBER
IS
RecordCount NUMBER;
BEGIN
SELECT COUNT(*)
INTO RecordCount
FROM PART_DATA
WHERE PART1_CO_SITE = Company;
RETURN RecordCount;
END GetPartDataRowCount;
END;
And the .NET part:
Public Function GetPartDataRowCount(ByVal Company As String) As Integer
Dim con As New OracleConnection(MyConnectionString)
'Open the connection
con.Open()
'Set the command text, type and connection
Dim cmd As New OracleCommand("PART_DATA.GetPartDataRowCount", con)
cmd.CommandType = CommandType.StoredProcedure
'Create parameter objects
Dim returnValue As New OracleParameter
returnValue.Direction = ParameterDirection.ReturnValue
returnValue.DbType = DbType.Int32
cmd.Parameters.Add(returnValue)
Dim pCompany As New OracleParameter
pCompany.Direction = ParameterDirection.Input
pCompany.DbType = DbType.AnsiStringFixedLength
pCompany.Value = Company
cmd.Parameters.Add(pCompany)
'Execute the query
cmd.ExecuteNonQuery()
'Capture the returned value
Dim rowCount As Integer = Convert.ToInt32(returnValue.Value)
'Return the returned value
Return rowCount
'Clean up objects
returnValue.Dispose()
cmd.Dispose()
con.Dispose()
End Function
I am using this as the SelectCountMethod on an ObjectDataSource for custom paging a GridView. Everything is working but because I'm new to Oracle I can't help thinking that there is a better way to achieve what I need, also I am confused as to whether I should be using a Function or a Procedure in my Package for this.
I would be grateful if someone could either confirm that what I am doing is the best/correct method or show me what I should be doing instead.
Any help much appreciated.Thanks Eric, that is a big help and has made things clearer for me. However I cannot get this to work using a Procedure instead of a Function. Just for the sake of completeness I would also like to make it work with a Procedure.
Here is what I have:
PACKAGE PART_DATA AS
PROCEDURE GetPartDataRowCount(mtmsCompany IN PART_DATA.PART1_CO_SITE%TYPE,rowCount OUT NUMBER);
END;
PACKAGE BODY PART_DATA AS
PROCEDURE GetPartDataRowCount
mtmsCompany IN PART_DATA.PART1_CO_SITE%TYPE,
rowCount OUT NUMBER
IS
BEGIN
SELECT COUNT(*)
INTO rowCount
FROM PART_DATA
WHERE PART1_CO_SITE = mtmsCompany;
END GetPartDataRowCount;
END;
And the .NET code:
Public Function GetPartDataRowCount(ByVal Company As String) As Integer
'Open the connection
con.Open()
'Set the command text and type
Dim cmd As New OracleCommand("PART_DATA.GetPartDataRowCount", con)
cmd.CommandType = CommandType.StoredProcedure
cmd.BindByName = True
'Create parameter objects
Dim rowCount As New OracleParameter
rowCount.Direction = ParameterDirection.Output
rowCount.DbType = DbType.Int32
cmd.Parameters.Add(rowCount)
Dim mtmsCompany As New OracleParameter
mtmsCompany.Direction = ParameterDirection.Input
mtmsCompany.DbType = DbType.AnsiStringFixedLength
mtmsCompany.Value = Company
cmd.Parameters.Add(mtmsCompany)
(Exception handling is done in Global.asax hence no Try/Finally)
'Execute the query
cmd.ExecuteScalar()
'Capture the returned value
Dim returnValue As Integer = Convert.ToInt32(rowCount.Value)
'Return the returned value
Return returnValue
'Clean up objects
RowCount.Dispose()
cmd.Dispose()
con.Dispose()
End Function
The package compiles without errors, but when I run the app I get the following error:
Oracle.DataAccess.Client.OracleException: ORA-06550: line 1, column 39: PLS-00103: Encountered the symbol ">" when expecting one of the following:
It then gives a long list of things it was expecting. Do I also need to return a Ref Cursor?
Once again any help much appreciated. -
Table of records from a stored procedure
Hi
Where could I find an example or documentation about how to retrive a table of records from a Stored Procedure ??
ThanksTry:
CREATE OR REPLACE TYPE scott.MYRECORDTYPE as object
(a int, b varchar2(40), c date, d number(10));
CREATE OR REPLACE TYPE scott.MYTABLETYPE is table of myrecordtype;
CREATE OR REPLACE PACKAGE BODY scott.MYPACKAGE
as
type number_collection is table of number(38) index by binary_integer;
type varchar2_collection is table of varchar2(4000) index by binary_integer;
type date_collection is table of date index by binary_integer;
g_data myTableType;
empno_col number_collection;
ename_col varchar2_collection;
hiredate_col date_collection;
mgr_col number_collection;
function my_function return myTableType
is
begin
select empno, ename, hiredate, mgr
bulk collect into empno_col, ename_col, hiredate_col, mgr_col
from emp
order by empno; -- Get some data
g_data := myTableType(); -- Initialize
for i in empno_col.first .. empno_col.last loop
g_data.extend; -- Write something in the array
g_data(i) := myRecordtype(empno_col(i), ename_col(i), hiredate_col(i), mgr_col(i));
end loop;
return g_data;
end;
end;
-- Demonstration-View
CREATE OR REPLACE VIEW scott.myview
AS
select a,b,c,d
from table(cast(myPackage.my_function() as mytabletype)); -
SOAP Fault when returning null from a Native Web Service Stored Procedure
I have a stored procedure which I can successfully invoke via soapUI
However, if one of the Stored Procedure's OUT arguments is set to null the native web service returns the following fault :
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<soap:Fault>
<faultcode>soap:Client</faultcode>
<faultstring>Error processing input</faultstring>
<detail>
<OracleErrors xmlns="http://xmlns.oracle.com/orawsv/faults">
<OracleError>
<ErrorNumber>ORA-19202</ErrorNumber>
<Message>Error occurred in XML processing</Message>
</OracleError>
<OracleError>
<ErrorNumber>ORA-01405</ErrorNumber>
<Message>fetched column value is NULL</Message>
</OracleError>
</OracleErrors>
</detail>
</soap:Fault>
</soap:Body>
</soap:Envelope>I can see how to control the processing of null values when invoking orawsv (using the null_handling element).
Is there an equivalent for Stored Procedures ?
Thanks,
PD
versions as follows :
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
PL/SQL Release 11.2.0.1.0 - Production
"CORE 11.2.0.1.0 Production"
TNS for Linux: Version 11.2.0.1.0 - Production
NLSRTL Version 11.2.0.1.0 - ProductionWithout going into any technical discussion about the code, my first question is what JDK version was used to create this which was imported into the form? Understand that Forms 10 runs on JDK 1.4.2, so if you used any newer JDK version, likely there will be problems.
-
The ways to return data from a stored procedure.
Hi, I know there are three ways to pass out a value from a Microsoft SQL stored procedure, but I have no clear idea what Oracle SP can do, I know Oracle doesn't support multi-recordset(v8), can not return a recordset by a inner select query, but I do know there is a cursor object, which doesn't like its counterpart in Microsoft SQL server, is a choice under most situation. Here I wonder anyone who is good at Oracle can give a list of all ways to return data from a SP, including example is more better, thanks.
Here is a way to get return a record from a function and a procedure. You need to be familiar with Oracle packages as well as stored procedures and functions:
CREATE OR REPLACE PACKAGE EmpPkg AS
cursor cEmp(pEmpno in number) is
select empno, ename, job, hiredate, sal
from emp
where empno = pEmpno;
FUNCTION GetEmployee(pnEmpNo in number) RETURN cEmp%rowtype;
PROCEDURE GetEmployee(pnEmpNo in number, prEmp out cEmp%rowtype);
END;
CREATE OR REPLACE PACKAGE BODY EmpPkg AS
FUNCTION GetEmployee(pnEmpNo in number) RETURN cEmp%rowtype IS
rEmp cEmp%rowtype;
BEGIN
open cEmp(pnEmpNo);
fetch cEmp into rEmp;
close cEmp;
return rEmp;
END;
PROCEDURE GetEmployee(pnEmpNo in number, prEmp out cEmp%rowtype) IS
BEGIN
open cEmp(pnEmpNo);
fetch cEmp into prEmp;
close cEmp;
END;
END;
Here's how you use the package:
DECLARE
rEmp EmpPkg.cEmp%rowtype;
BEGIN
rEmp := EmpPkg.GetEmployee(7782);
dbms_output.put_line(rEmp.ename);
EmpPkg.GetEmployee(7902, rEmp);
dbms_output.put_line(rEmp.ename);
END;
Note that you can return any Oracle data type from a function. Likewise, you can specify any Oracle data type as an out parameter in a procedure. Also, you can make a parameter both an in and an out datatype like this:
PROCEDURE GetEmployee(pnEmpNo in out number);
I hope this puts you in the right direction.
null -
How to pass javascript variable to PLSQL stored procedure
Hi,
How can I pass a javascript variable to a database procedure. I have a form with a radio button group and would like to save the value of the selected radio button to a database table by passing the value to the stored procedure.
ThanksHi
You can use iframe to call the procedure. Here is an example used in dynamic page or pl/sql portlet. The pl/sql procedure is called myprocedure and resists in the schema myschema. This example passes 2 parameters, but I have not yet reased a limit.
First the call within a javascript function:
myiframe.location.href="myschema.myprocedure?p_myprameter1=" + vJvascriptparameter1 + "&p_myprameter2=" + vJvascriptparameter2;
Then the iframe:
<iframe id="myiframe" height="0" width="0" frameborder="0"></iframe>
You can let the pl/sql procedure print a value, that can be used i the portlet. You can get the value in a javascript this way:
myvalue=top.window.frames["myiframe"].document.body.innerHTML;
Best regards
Klaus -
Error while invoking Stored Procedure.
Hi,
I am trying to invoke a stored procedure which has one input parameter and 3 output parameters. In the procedure, I am selecting 3 columns from a table based on the input parameter. I have generated a WSDL from database, along with wsdl an xsd has been created. I have used this WSDL in creating partner link on the target side. For source side partner link, I have created WSDL based on the xsd which is created from database. I have deployed this BPEL process and when I try to debug the flow it is failing while invoking the stored procedure I am getting below soap fault.
{color:#3366ff}<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="{color}{color:#3366ff}" xmlns:xsd="{color}{color:#3366ff}" xmlns:xsi="{color}{color:#3366ff}" xsi:schemaLocation="{color}{color:#3366ff} {color}{color:#3366ff}">
<SOAP-ENV:Body>
<SOAP-ENV:Fault>
<faultcode xmlns="">SOAP-ENV:Server</faultcode>
<faultstring xmlns="">BPCOR-6135:A fault was not handled in the process scope; Fault Name is {http://www.sun.com/wsbpel/2.0/process/executable/SUNExtension/ErrorHandling}systemFault; Fault Data is <?xml version="1.0&;quot; encoding="UTF-8"?><jbi:message xmlns:sxeh="http://www.sun.com/wsbpel/2.0/process/executable/SUNExtension/ErrorHandling" type="sxeh:faultMessage" version="1.0&;quot; xmlns:jbi="http://java.sun.com/xml/ns/jbi/wsdl-11-wrapper"><jbi:part>Error occured while executing SQL.call GETRESULTS(?,?,?,?) Reason: Unable to convert normalized message content to Procedure, Error occured during populating Procedure.Reason: Parameter Type Conflict: sqlType=12 SQLState: null ErrorCode:17012</jbi:part></jbi:message>. Sending errors for the pending requests in the process scope before terminating the process instance</faultstring>
<faultactor xmlns="">sun-bpel-engine</faultactor>
<detail xmlns="">
<detailText>BPCOR-6135:A fault was not handled in the process scope; Fault Name is {http://www.sun.com/wsbpel/2.0/process/executable/SUNExtension/ErrorHandling}systemFault; Fault Data is <?xml version="1.0&;quot; encoding="UTF-8"?><jbi:message xmlns:sxeh="http://www.sun.com/wsbpel/2.0/process/executable/SUNExtension/ErrorHandling" type="sxeh:faultMessage" version="1.0&;quot; xmlns:jbi="http://java.sun.com/xml/ns/jbi/wsdl-11-wrapper"><jbi:part>Error occured while executing SQL.call GETRESULTS(?,?,?,?) Reason: Unable to convert normalized message content to Procedure, Error occured during populating Procedure.Reason: Parameter Type Conflict: sqlType=12 SQLState: null ErrorCode:17012</jbi:part></jbi:message>. Sending errors for the pending requests in the process scope before terminating the process instance
Caused by: BPCOR-6131:An Error status was received while doing an invoke (partnerLink=StoreProc, portType={http://j2ee.netbeans.org/wsdl/Storedproc}jdbcPortType, operation=execute)
BPCOR-6129:Line Number is 30
BPCOR-6130:Activity Name is Invoke1
Caused by: Error occured while executing SQL.call GETRESULTS(?,?,?,?) Reason: Unable to convert normalized message content to Procedure, Error occured during populating Procedure.Reason: Parameter Type Conflict: sqlType=12 SQLState: null ErrorCode:17012
Caused by: Unable to convert normalized message content to Procedure, Error occured during populating Procedure.Reason: Parameter Type Conflict: sqlType=12 SQLState: null ErrorCode:17012
Caused by: Parameter Type Conflict: sqlType=12</detailText>
</detail>
</SOAP-ENV:Fault>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
{color:#000000}Plz help me to fix this issue.
Thanks,
Srinivas{color}{color}First of all does this scenario occur again.
"Works first/second time. Later gives this error."
After you restart the SOA server are you able to reproduce this scenario?
As already pointed out and from the error message, database connection is reset.
If you find this error again, try this out.
em -> home / oc4j_soa -> Administration -> JDBC Resources
Use the "Test Connection" option for the Connection Pool that you are using for your database JNDI.
It comes back and say "Connection to "XYZCP" established successfully." it is good to use.
Run the BPEL process again and once you find the error, come back and test the connection.
If it comes back with Error, diagnose based on the error message received.
Cheers
Kalidass Mookkaiah
http://oraclebpelindepth.blogspot.com/ -
ORA-03115 error when calling a Stored Procedure
Hi All,
I'm in the process of porting a Pro/C app from NT to Linux. I've installed 8.1.5 on our Linux box and patched it up to 8.1.5.02.
It all kind of works ok, except that I'm sometimes getting ORA-03115 errors when the app calls a stored procedure. The call in question looks like this:
EXEC SQL BEGIN DECLARE SECTION;
VARCHAR resprows[50][3998];
int numret = 0;
int numrows= 50;
int done= 0;
unsigned long resp_id = 0;
EXEC SQL END DECLARE SECTION;
EXEC SQL AT DB_NAME EXECUTE
BEGIN pkg_something.getdata(
:resp_id, /* IN */
:numrows, /* IN */
:done, /* OUT */
:resprows, /* OUT */
:numret /* OUT */
END;
END-EXEC;
The stored procedure basically uses the resp_id value to select rows from a table;
in each row there is a VARCHAR2(4000) column which it copies into the hostarray resprows.
There may be anything from 1 to numrows returned from the SP.
Initially, the resprows rows were defined to be size [4000]. Unfortunately, this caused ORA-02005 errors - I then changed the size to [3998], which seemed to fix the 02005's (although I'm unclear as to the reasons why).
Now I'm getting the 03115 errors when calling the SP. The oracle manual is not very helpful on what this error means.
This all works chipper on NT.
Any ideas?
Thanks in advance,
Nigel.
PS: The database the app is talking to is still hosted on NT.
nullHiston FTM wrote:
ORA-04063: package body "LAZARUS.LAZARUS" has errors Above, obviously conflicts with the statement that follows:
>
The procedure and package have both compiled without errors and the statement on its own works fine in SQL*Plus.I suggest you take a look in the USER_ERRORS view to see, what the errors are.
And just checking:
You have schema called LAZARUS, which holds a package named LAZARUS, which holds a procedure called POPULATEGRIDPOSITIONS?
Edited by: Toon Koppelaars on Oct 1, 2009 5:55 PM -
Calling a stored procedure from a url
I am needing to call a stored procedure from a url string (or
anchor) understand that from training to be as follows:
http://host:port/pls/dad/package.procedure?query_string
With that in mind, I am getting an error as follows:
Not Found
The requested URL /pls/portal30/at_hrfm.checkshow.showcheck was
not found on this server.
Here is a sample of my url
http://servername:port/pls/portal30/at_hrfm.checkshow.showcheck
I can see servername:port/pls/portal30, it is just the
procedure I am having a problem with.
Here is a sample of my source code that is created under the
at_hrfm schema (I also tried under portal30 schema).
package body checkshow as
procedure showcheck as
begin
htp.htmlOpen;
htp.headOpen;
htp.title('My Check');
htp.comment ('This should be your Check');
htp.bodyOpen;
htp.header (1,'Check');
htp.print ('checkdate');
htp.bodyClose;
htp.headClose;
htp.htmlClose;
end;
end;I think I figured this out. I don't think the grant to ANONYMOUS is going to work with production XE and the online documentation is in need of an update. It appears that production XE has been locked down and you will need to specify the name of each stored procedure you wish to allow to be executed by adding it to the WWV_FLOW_EPG_INCLUDE_MOD_LOCAL function. This is spelled out in more technical detail here: http://download.oracle.com/docs/cd/B25329_01/doc/appdev.102/b25309/adm_wrkspc.htm#BEJCGJFJ
Another alternative that would work involves creating a separate DAD. Using the DAD approach with my schema made all of my stored procedures callable from a web browser, so I rejected this approach. To make this usable (secure) I would have needed to create and maintain a separate database user for the DAD and then only granted it execute for the stored procedures I wanted to be callable from a URL.
Finally I read about using an on-demand procedure and having it invoke the desired stored procedure. While I didn't try this out, it sounds like another good approach because it maintains session security. If it can be used to return an image I do not know.
- Jim -
Calling a stored procedure runs into an error
Hello,
We are testing the Database Adapter.
In our database we created the following
- Table tt
- Package ttpackage, with a procedure with 1 input and 1 output parameter which inserts a record in the tt table.
(see scripts at bottom of message)
We created a Database Adapter based upon this Package (Call a stored procedure or function) and register this Database Adapter with the Integration Server.
When we invoke this Database Adapter and enter the input, we can see in the database that 4 records are created. The Web Service returns after a minute with an error
How can we solve this problem?
Regards Leon Smiers
ERROR
<env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/"><env:Header/><env:Body><env:Fault xmlns:env="http://schemas.xmlsoap.org/soap/envelope/"><faultcode>env:Server</faultcode><faultstring>oracle.tip.esb.server.common.exceptions.BusinessEventRetriableException: An unhandled exception has been thrown in the ESB system. The exception reported is: "oracle.tip.esb.server.common.exceptions.BusinessEventRetriableException: An unhandled exception has been thrown in the ESB system. The exception reported is: "java.lang.ArrayIndexOutOfBoundsException: Array index out of range: 0
at java.util.Vector.get(Vector.java:710)
at oracle.tip.esb.server.common.wsif.WSIFInvoker.readResponseHeader(Unknown Source)
SCRIPT
drop table tt
drop sequence seq_tt;
drop package ttpackage;
create table tt
(field1 number(10) not null
,field2 varchar2(25) not null
,status varchar2(1) not null
,primary key (field1)
create sequence seq_tt;
create or replace package ttpackage is
procedure insert_tt(
pi_field2 in tt.field2%type,
po_status out klacht_data.status%type);
end;
show errors
create or replace package body ttpackage is
procedure insert_tt(
pi_field2 in tt.field2%type,
po_status out klacht_data.status%type) is
begin
po_status:='I';
insert into tt
(field1, field2,status)
values(seq_tt.nextval,pi_field2,po_status);
end insert_tt;
end;
show errors
/Hello Dave,
Thanks for the quick fix.
I've tested the fix. The 'Array index out of range: 0' disappeared.
I get, unfortunately, the following error. I already described the steps I take in the first message. Based upon the TTpackage I create a Database adapter, register it with the ESB and invoke the URL from the ESB.
Regards Leon
<env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/"><env:Header/><env:Body><env:Fault xmlns:env="http://schemas.xmlsoap.org/soap/envelope/"><faultcode>env:Server</faultcode><faultstring>oracle.tip.esb.server.common.exceptions.BusinessEventRetriableException: An unhandled exception has been thrown in the ESB system. The exception reported is: "oracle.xml.parser.v2.XMLDOMException: Ongeldige naamruimte http://xmlns.oracle.com/pcbpel/adapter/db/OCOP/TTPACKAGE/INSERT_TT/ voor prefix xmlns
at oracle.xml.parser.v2.XMLElement.setAttributeNS(XMLElement.java:1015)
at oracle.tip.esb.utils.DOMUtil.copyContentsTo(Unknown Source)
at oracle.tip.esb.server.service.impl.soap.EventOracleSoapProvider.raiseEvent(Unknown Source)
at oracle.tip.esb.server.service.impl.soap.EventOracleSoapProvider.processMessage(Unknown Source)
at oracle.j2ee.ws.server.provider.ProviderProcessor.doEndpointProcessing(ProviderProcessor.java:869)
at oracle.j2ee.ws.server.WebServiceProcessor.invokeEndpointImplementation(WebServiceProcessor.java:349)
at oracle.j2ee.ws.server.provider.ProviderProcessor.doRequestProcessing(ProviderProcessor.java:460)
at oracle.j2ee.ws.server.WebServiceProcessor.processRequest(WebServiceProcessor.java:114)
at oracle.j2ee.ws.server.WebServiceProcessor.doService(WebServiceProcessor.java:96)
at oracle.j2ee.ws.server.WebServiceServlet.doPost(WebServiceServlet.java:177)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:763)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
at com.evermind.server.http.ServletRequestDispatcher.invoke(ServletRequestDispatcher.java:711)
at com.evermind.server.http.ServletRequestDispatcher.forwardInternal(ServletRequestDispatcher.java:368)
at com.evermind.server.http.HttpRequestHandler.doProcessRequest(HttpRequestHandler.java:866)
at com.evermind.server.http.HttpRequestHandler.processRequest(HttpRequestHandler.java:448)
at com.evermind.server.http.HttpRequestHandler.serveOneRequest(HttpRequestHandler.java:216)
at com.evermind.server.http.HttpRequestHandler.run(HttpRequestHandler.java:117)
at com.evermind.server.http.HttpRequestHandler.run(HttpRequestHandler.java:110)
at oracle.oc4j.network.ServerSocketReadHandler$SafeRunnable.run(ServerSocketReadHandler.java:260)
at oracle.oc4j.network.ServerSocketAcceptHandler.procClientSocket(ServerSocketAcceptHandler.java:239)
at oracle.oc4j.network.ServerSocketAcceptHandler.access$700(ServerSocketAcceptHandler.java:34)
at oracle.oc4j.network.ServerSocketAcceptHandler$AcceptHandlerHorse.run(ServerSocketAcceptHandler.java:880)
at com.evermind.util.ReleasableResourcePooledExecutor$MyWorker.run(ReleasableResourcePooledExecutor.java:303)
at java.lang.Thread.run(Thread.java:595)
</faultstring><faultactor></faultactor></env:Fault></env:Body></env:Envelope>
Maybe you are looking for
-
Unable to connect the SQL database from servlet
Hi! My servlet connects with an SQL server on some other machine. I have create the servlet and deploy it on tomcat. I first create this servlet on eclipse that I deploy it on tomcat manually. While using it form eclipse it gave no error in connectin
-
Value binding not working with rendered attribute
In my jsf page i'm encountering problem with value binding it is not working for a h:inputText with rendered condition even when the rendered condition evaluates to true & the component is rendered.While trying to retrieve the value of the components
-
Problem with h:inputText
I have a data edit form which contains more than one fields and a submit button.I want to modify few fields and few not. Data are populating from database into that form and on clicking save button data r saving into database using following code. <h
-
As ABAP tasks in SAP Provisioning framework
Hi Experts, In HR provisioning , for a new hire when a new MX_PERSON is created in Identity store , User accounts need to be created in the SAP systems from IDM .For this I noticed "AS ABAP tasks " in SAP provisioning framework with create/delete use
-
How is SP 13 service pack Sender File Adapter View
Hi Xi Guru's In sap xi SP 13 Service Pack , what are new parameters added in File Content Conversion Parameters .