How send mail from Oracle stored procedure?
Hi,
I need send mail using Oracle stored procedure. Can anybody helpme with any recomendation about that, sample code or so?.
[email protected]
null
Hi Raul Martinez
utl_smtp package is available since oracle 8.1.6.
If U have a older version then U can not.
Thank U.
edwin
Similar Messages
-
Email from oracle stored procedure
Can any one provide sample code for sending email from oracle stored procedure please.
What do you mean "clicked on my link" and "login
page"? It sounds like you're describing a web based
interface, which would imply that you were using the
HTTP protocol, not SMTP, and connecting on port 80
(or 443 if you're using HTTPS). If you want to send
an email from Oracle, you're going to need access to
an SMTP server, not a HTTP server.
JustinSorry. I was trying different things to test it. I put that link in an email just to test if it was valid. I am using the util_smtp package. Have you gotten this to work? -
How to connect to UNIX OS from oracle stored procedure
Hi,
I need to connect to UNIX OS from oracle stored procedure.
Curently working in Oracle9i.
I tried in google but I could'nt get any.
Can you send me pointers on how to do this.
Thanks,
Kavitha.Can use Java Stored Proc, or an External Proc.
Java method:
create or replace and compile Java Source named "OSCommand" as
-- java: OS COMMAND
-- descr: Executes an Operating System Command using the JAVA RTS
-- IN parameter: os command to execute (including fully qualified path names)
-- OUT parameter: returncode [\nstring]
-- where string a max of 32000 chars of the output of the command
-- (note that \n is used as separators in the string)
-- returncode=-1 Java RTS error occurred (e.g. command does not exist)
-- returncode=255 o/s command failed (e.g. invalid command params)
import java.io.*;
import java.lang.*;
public class OSCommand{
public static String Run(String Command){
Runtime rt = Runtime.getRuntime();
int rc = -1;
try{
Process p = rt.exec( Command );
int bufSize = 32000;
int len = 0;
byte buffer[] = new byte[bufSize];
String s = null;
BufferedInputStream bis = new BufferedInputStream( p.getInputStream(), bufSize );
len = bis.read( buffer, 0, bufSize );
rc = p.waitFor();
if ( len != -1 ){
s = new String( buffer, 0, len );
return( s );
return( rc+"" );
catch (Exception e){
e.printStackTrace();
return( "-1\ncommand[" + Command + "]\n" + e.getMessage() );
show errors
create or replace function osexec( cCommand IN string ) return varchar2 is
-- function: OS EXEC
-- descr: Executes an Operating System Command
language JAVA
name 'OSCommand.Run(java.lang.String) return java.lang.String';
show errors===
This can then be used from PL/SQL and even SQL. e.g.
SQL> select osexec( '/bin/date' ) from dual;
OSEXEC('/BIN/DATE')
Wed Nov 9 13:30:13 SAST 2005
SQL>Note the Java permissions required - replace FOO with the name of applicable Oracle schema
==begin
dbms_java.grant_permission(
'FOO',
'SYS:java.io.FilePermission',
'<<ALL FILES>>',
'execute'
dbms_java.grant_permission(
'FOO',
'SYS:java.lang.RuntimePermission',
'writeFileDescriptor',
dbms_java.grant_permission(
'FOO',
'SYS:java.lang.RuntimePermission',
'readFileDescriptor',
commit;
end;
/==
Last thing... note that opens a potential giant size security hole into the Oracle Server Platform. So implement it properly using a proper Oracle security model. -
Sending mail from oracle procedure
Hi Experts,
I want to send mail from oracle Procedure. Anybody please help me out.
Thanks.BEGIN
UTL_MAIL.send(sender => '[email protected]',
recipients => '[email protected],[email protected]',
cc => '[email protected]',
bcc => '[email protected]',
subject => 'UTL_MAIL Test',
message => 'If you get this message it worked!');END; -
Calling OLE API from Oracle Stored Procedure
An application that I need to intergate with exposes only the OLE API. How can I invoke these OLE APIs from Oracle stored procedure? Do I need any special/ additional Oracle components? Can you please help. Any links to examples would be very helpful. Thanks.
If what you mean by Oracle stored procedures is pl/sql then yes.
You can create a "wrapper" this way:
CREATE OR REPLACE FUNCTION xmlXform
in_mapUrl IN VARCHAR2,
in_inputUrl IN VARCHAR2
RETURN VARCHAR2
AS
LANGUAGE JAVA NAME
'com.yourcompany.xml2any.xform(java.lang.String,java.lang.String)
RETURN java.lang.String';
Then load the java as:
loadjava -user youruser/youruserpasswd -resolve -verbose lib/xmlparserv2.jar classes/com/yourcompany/xform.class classes/com/yourcompany/xml2any.class
The java, given the correct permissions, can do anything java can do including communicate with outside applications.
Is this the "best" way... depends on what you are trying to accomplish. -
Passing data from Oracle stored procedures to Java
We're going to write a new web interface for a big system based on Oracle database. All business rules are already coded in PL/SQL stored procedures and we'd like to reuse as much code as possible. We'll write some new stored procedures that will combine the existing business rules and return the final result dataset.
We want to do this on the database level to avoid java-db round trips. The interface layer will be written in Java (we'd like to use GWT), so we need a way of passing data from Oracle stored procedures to Java service side. The data can be e.g. a set of properties of a specific item or a list of items fulfilling certain criteria. Would anyone recommend a preferable way of doing this?
We're considering one of the 2 following scenarios:
passing objects and lists of objects (DB object types defined on the schema level)
passing a sys_refcursor
We verified that both approaches are "doable", the question is more about design decision, best practice, possible maintenance problems, flexibility, etc.
I'd appreciate any hints.user1754151 wrote:
We're going to write a new web interface for a big system based on Oracle database. All business rules are already coded in PL/SQL stored procedures and we'd like to reuse as much code as possible. We'll write some new stored procedures that will combine the existing business rules and return the final result dataset.
We want to do this on the database level to avoid java-db round trips. The interface layer will be written in Java (we'd like to use GWT), so we need a way of passing data from Oracle stored procedures to Java service side. The data can be e.g. a set of properties of a specific item or a list of items fulfilling certain criteria. Would anyone recommend a preferable way of doing this?
We're considering one of the 2 following scenarios:
passing objects and lists of objects (DB object types defined on the schema level)
passing a sys_refcursor
We verified that both approaches are "doable", the question is more about design decision, best practice, possible maintenance problems, flexibility, etc.
I'd appreciate any hints.If logic is already written in DB, and the only concern is of passing the result to java service side, and also from point of maintenance problem and flexibility i would suggest to use the sys_refcursor.
The reason if Down the line any thing changes then you only need to change the arguments of sys_refcursor in DB and as well as java side, and it is much easier and less efforts compare to using and changes required for Types and Objects on DB and java side.
The design and best practise keeps changing based on our requirement and exisiting design. But by looking at your current senario and design, i personally suggest to go with sys_refcursor. -
Arabic characters from Oracle Stored Procedure
Hi,
I am having a problem displaying arabic fields from Oracle Stored Procedure. When viewing the arabic field on the web page, i get the following:
ÙƒØكد Øاكد غبد اÙلب٠اÙاربش
I have checked with our Oracle DBAs and we seem to be using the AR8ISO8859P6 (ISO-8859-6). I tried to set the return string encoding to UTF-16 and ISO-8859-6 but still no use.
What should be done to display it?Bashar Abdullah wrote:
Hi,
I am having a problem displaying arabic fields from Oracle Stored Procedure. When viewing the arabic field on the web page, i get the following:
I have checked with our Oracle DBAs and we seem to be using the AR8ISO8859P6 (ISO-8859-6). I tried to set the return string encoding to UTF-16 and ISO-8859-6 but still no use.
What should be done to display it?The first place I'd ask is the Oracle JDBC forum:
http://forums.oracle.com/forums/forum.jspa?forumID=99
Joe -
How to send mails from Oracle database
Hi All,
I want to send a mail from my oracle database once my store
procedure runs successfully or fails.
How can i do this.
what are the preliminary modules of Oracle which need to be
active for me to do so.
If any once can also mention about any links that give
information about the same it will be very helpful for me.
Thanks and Regards
Srinivas CheboluCREATE OR REPLACE PROCEDURE SEND_MAIL_TCP(
msg_from varchar2 := '[email protected]',
msg_to varchar2,
msg_subject varchar2 := 'E-Mail message from your database',
msg_text varchar2 := '' )
IS
c utl_tcp.connection;
rc integer;
BEGIN
c := utl_tcp.open_connection('1.17.0.218', 25); -- open the SMTP
port 25 on local machine
dbms_output.put_line(utl_tcp.get_line(c, TRUE));
rc := utl_tcp.write_line(c, 'HELO localhost');
dbms_output.put_line(utl_tcp.get_line(c, TRUE));
rc := utl_tcp.write_line(c, 'MAIL FROM: '||msg_from);
dbms_output.put_line(utl_tcp.get_line(c, TRUE));
rc := utl_tcp.write_line(c, 'RCPT TO: '||msg_to);
dbms_output.put_line(utl_tcp.get_line(c, TRUE));
rc := utl_tcp.write_line(c, 'DATA'); -- Start message body
dbms_output.put_line(utl_tcp.get_line(c, TRUE));
rc := utl_tcp.write_line(c, 'Subject: '||msg_subject);
rc := utl_tcp.write_line(c, '');
rc := utl_tcp.write_line(c, msg_text);
rc := utl_tcp.write_line(c, '.'); -- End of message body
dbms_output.put_line(utl_tcp.get_line(c, TRUE));
rc := utl_tcp.write_line(c, 'QUIT');
dbms_output.put_line(utl_tcp.get_line(c, TRUE));
utl_tcp.close_connection(c); -- Close the connection
EXCEPTION
when others then
raise_application_error(-20000,'Unable to send e-mail message
from pl/sql');
END;
show errors
exec send_mail(msg_to =>'[email protected]');
exec send_mail(msg_to
=>[email protected]',msg_text=>'Look Yaar, I can send
mail from plsql'); -
Send mail from oracle database 10g
Hi ,
I need to send a test mail from oracle database 10g to my gmail account through a stored procedure .
I will pass the list of recipents , subject and text of the mail through parameters .
Can anyone give me the code of the storerd procedure please ,
Thank you .hi, for example
DECLARE
mail_conn UTL_SMTP.connection;
smtp_relay VARCHAR2(32) := '172.16.x.x';
recipient_address VARCHAR2(64) := '[email protected]';
sender_address VARCHAR2(64) := '[email protected]';
mail_port NUMBER := 25;
msg VARCHAR2(200);
BEGIN
mail_conn := UTL_SMTP.open_connection(smtp_relay,mail_port);
UTL_SMTP.HELO(mail_conn, smtp_relay);
UTL_SMTP.MAIL(mail_conn, sender_address);
UTL_SMTP.RCPT(mail_conn, recipient_address);
UTL_SMTP.DATA(mail_conn, 'Payment request iniated');
UTL_SMTP.QUIT(mail_conn);
end; -
Need Example on calling a unix shell script from oracle stored procedure
Hi
Can anybody give example on how to call unix shell script from an Oracle stored procedure. Please give a small example on how to do this .I need this urgently please.
Have a nice time.
Thanks & Regards
JogeshIf you are on 10g you can also use DBMS_SCHEDULER. See Re: Excute Unix command Using PL SQL
-
How to select from a stored procedure?
Lets say I have a simple stored procedures
Create Procedure stp_test
As
Begin
Select * from tbl1
End
Go
I would like to be able to do this in SSMS (actually, I want to do this from ADODB)
Select top 10 * from ...stp_test... Order By rowID
It looks like I want to use OpenQuery on the stored Procedure, but I have not been able to do it correctly. How can I query my stored procedure?
Rich PIt looks like I want to use OpenQuery on the stored Procedure, but I have not been able to do it correctly. How can I query my stored procedure?
If you want to use the OPENQUERY method , use the following.. follow this link...
http://stackoverflow.com/questions/209383/select-columns-from-result-set-of-stored-procedure
Please mark as answer, if this has helped you solve the issue.
Good Luck :) visit www.sqlsaga.com for more t-sql code snippets and BI related how to articles. -
Not able to retrive the recordset from oracle stored procedure in VC++
Hi,
I am trying to retrieve the records from the reference cursor which is an out parameter for an oracle 9i store procedure in VC++ application. But it is giving the record count as -1 always. Meanwhile i am able to get the required output in VB application from the same oracle 9i store procedure .
Find the code below which i used.
Thanks,
Shenba
//// Oracle Stored Procedure
<PRE lang=sql>CREATE OR REPLACE
PROCEDURE GetEmpRS1 (p_recordset1 OUT SYS_REFCURSOR,
p_recordset2 OUT SYS_REFCURSOR,
PARAM IN STRING) AS
BEGIN
OPEN p_recordset1 FOR
SELECT RET1
FROM MYTABLE
WHERE LOOKUPVALUE > PARAM;
OPEN p_recordset2 FOR
SELECT RET2
FROM MYTABLE
WHERE LOOKUPVALUE >= PARAM;
END GetEmpRS1;</PRE>
///// VC++ code
<PRE lang=c++ id=pre1 style="MARGIN-TOP: 0px">ConnectionPtr mpConn;
_RecordsetPtr pRecordset;
_CommandPtr pCommand;
_ParameterPtr pParam1;
//We will use pParam1 for the sole input parameter.
//NOTE: We must not append (hence need not create)
//the REF CURSOR parameters. If your stored proc has
//normal OUT parameters that are not REF CURSORS, you need
//to create and append them too. But not the REF CURSOR ones!
//Hardcoding the value of i/p paramter in this example...
variantt vt;
vt.SetString("2");
m_pConn.CreateInstance (__uuidof (Connection));
pCommand.CreateInstance (__uuidof (Command));
//NOTE the "PLSQLRSet=1" part in
//the connection string. You can either
//do that or can set the property separately using
//pCommand->Properties->GetItem("PLSQLRSet")->Value = true;
//But beware if you are not working with ORACLE, trying to GetItem()
//a property that does not exist
//will throw the adErrItemNotFound exception.
m_pConn->Open (
bstrt ("Provider=OraOLEDB.Oracle;PLSQLRSet=1;Data Source=XXX"),
bstrt ("CP"), bstrt ("CP"), adModeUnknown);
pCommand->ActiveConnection = m_pConn;
pParam1 = pCommand->CreateParameter( bstrt ("pParam1"),
adSmallInt,adParamInput, sizeof(int),( VARIANT ) vt);
pCommand->Parameters->Append(pParam1);
pRecordset.CreateInstance (__uuidof (Recordset));
//NOTE: We need to specify the stored procedure name as COMMANDTEXT
//with proper ODBC escape sequence.
//If we assign COMMANDTYPE to adCmdStoredProc and COMMANDTEXT
//to stored procedure name, it will not work in this case.
//NOTE that in the escape sequence, the number '?'-s correspond to the
//number of parameters that are NOT REF CURSORS.
pCommand->CommandText = "{CALL GetEmpRS1(?)}";
//NOTE the options set for Execute. It did not work with most other
//combinations. Note that we are using a _RecordsetPtr object
//to trap the return value of Execute call. That single _RecordsetPtr
//object will contain ALL the REF CURSOR outputs as adjacent recordsets.
pRecordset = pCommand->Execute(NULL, NULL,
adCmdStoredProc | adCmdUnspecified );
//After this, traverse the pRecordset object to retrieve all
//the adjacent recordsets. They will be in the order of the
//REF CURSOR parameters of the stored procedure. In this example,
//there will be 2 recordsets, as there were 2 REF CURSOR OUT params.
while( pRecordset !=NULL ) )
while( !pRecordset->GetadoEOF() )
//traverse through all the records of current recordset...
long lngRec = 0;
pRecordset = pRecordset->NextRecordset((VARIANT *)lngRec);
//Error handling and cleanup code (like closing recordset/ connection)
//etc are not shown here.</PRE>It can be linked to internal conversion. In some case, the value of internal or extranal value is not the same.
When you run SE16 (or transaction N), you have in option mode the possibility to use the exit conversion or not.
Christophe -
Hi,
i havea requirement where in i should be able to call my shell script through oracle stored procedure.i tried the following way..but iam unable to get the result.please find the details below.
new.sh - my shell script - lctfile (LCTFILE) is the input pa
v_config_file=`find $FND_TOP -name LCTFILE
FNDLOAD apps/s0ccer@$dxbs1 0 Y DOWNLOAD $v_config_file /home/bir4163/RPT33/bin/menu.ldt MENU MENU_NAME='AR_NAVIGATE_GUI'
if [ $? != 0 ];then
echo "$DATE $0 FNDLOAD DOWNLOAD Failed!" | tee -a $LOG_FILE
else
echo "SUCCESS" | tee -a $LOG_FILE
fi
CREATE OR REPLACE PROCEDURE test_dbms_scheduler
AS
v_text VARCHAR2 (255) := 'AR_NAVIGATE_GUI';
BEGIN
DBMS_OUTPUT.put_line ('I am in Procedure');
DBMS_SCHEDULER.create_job (
job_name => 'test_dbms_scheduler',
job_action => '/home/bir4163/RPT33/bin/new.sh',
number_of_arguments => 1,
job_type => 'executable',
start_date => SYSDATE,
repeat_interval => 'FREQ=SECONDLY; INTERVAL=1',
enabled => FALSE,
auto_drop => FALSE,
comments => 'run shell script'
DBMS_SCHEDULER.set_job_argument_value (job_name => 'test_dbms_scheduler',
argument_position => 1,
argument_value => v_text);
DBMS_SCHEDULER.enable ('test_dbms_scheduler');
DBMS_OUTPUT.put_line ('I am back in Procedure');
EXCEPTION
WHEN OTHERS
THEN
DBMS_OUTPUT.put_line (SQLCODE || SQLERRM);
END;
But iam unable to test it as i do not have permissions to access dbms_scheduler.can anybody tell me how to solve this using DBMS_PIPE with a sample code.
please do help its very urgent
thanks
ramyaHi,
Register your Shell Script as a concurrent program, Executable execution method "Host", then use fnd_request.submit_request to submit the program.
Regards,
Andries -
SOS..How to execute an Oracle Stored procedure
Please help me.
I need to execute an oracle stored procedure from a JSP.
I'M using Jakarta Tomcat and I dont have the Oracle Jbo tags and no BC4j tags.
Anyone have an example using standar tags or directives???.
This an emergency call..!!!!!!To execute a stored procedure (Oracle or other), you must create a CallableStatement.
Here is the link to the API description:
http://java.sun.com/products/jdk/1.2/docs/api/java/sql/CallableStatement.html
You use it like a query but the the syntax is:
{call <procedure-name>[<arg1>,<arg2>, ...]} -
Extraction SQL statement from oracle stored procedure stored in file
Hi,
I am newbie to oracle stored procedure. I need to extract the list of sqls present in oracle stored procedure. Besides that I also want to parse these sql statements to get the list of tables and columns used. Is there any tool which can help me in doing thats.
thanks,
govindwhy don't check on user_dependencies table instead?
select referenced_name,referenced_type
from user_dependencies
where name='<your stored procedure name in upper case>'
and referenced_type = 'TABLE'HTH,
Prazy
Maybe you are looking for
-
How to extract required data from a column to a flat file
my ssis package is working OK. However, I want to refine one of the column extraction. when data is extracted to the flat file, I just want to the initials, firstname, lastname e.g. FZ = Ben Smith, Add1, add1, etc the only bit that i want is Ben Smi
-
I have a 755p and as far as I know, it is set-up properly, however, everytime I send or respond to an email from my 755P, the"sender" email address shows-up as my phone number with my email address in <>. I would like to simply have my actual email
-
I have a brand new imac, 1 month old. Only thing I installed on it was Firefox but didn't really like it so I'm using Safari 4. However, on certain sites (i.e. Time Mag, PCWorld) it will randomly crash. Others it will work fine (i.e. ESPN, Amazon, We
-
Windows computers on the network disappeared from the browser
I own a macbook pro 10.6.4 and in the office we have an imac and 7 windows 7 pc. Till last week I could able to see all the computers on the network under "Shared" and able to connect them. Office printer is shared via one of the pc thats why I canno
-
Why such long render times with SD footage?
I'm putting together a three-minute video for my FSAE racing team. Footage is standard-def video from three different cameras we had on-car. I have the videos set up as a multiclip for about two minutes in the timeline; FCP says the render will take