SELECT * FROM employees
WHERE employee_id IN
(SELECT employee_id FROM
(SELECT employee_id, SYS.DBMS_RANDOM.RANDOM FROM employees ORDER BY 2)
WHERE rownum <= 1 );
SELECT * FROM employees
WHERE employee_id IN
(SELECT employee_id FROM
(SELECT employee_id, SYS.DBMS_RANDOM.RANDOM FROM employees ORDER BY 2)
WHERE rownum <= 1 );
declare
l_file UTL_FILE.file_type;
fileHandler UTL_FILE.FILE_TYPE;
l_location VARCHAR2(100) := '
l_text VARCHAR2(32767);
mesaj VARCHAR2(32767);
l_filename VARCHAR2(100) := '
l_filename_output VARCHAR2(100) := '
asd VARCHAR2(32767);
begin
mesaj:=' ';
l_file := UTL_FILE.fopen(l_location, l_filename, 'r', 32767);
UTL_FILE.get_line(l_file, l_text, 32767);
--DBMS_OUTPUT.PUT_LINE(l_text);
--mesaj:=mesaj||l_text||', '', '||chr(13) || chr(10)||' ';
END
UTL_FILE.fclose(l_file);
fileHandler := UTL_FILE.FOPEN(l_location,l_filename_output, 'w');
UTL_FILE.PUTF(fileHandler, mesaj);
UTL_FILE.FCLOSE(fileHandler);
EXCEPTION
WHEN OTHERS THEN
NULL;
end;
declare
CRLF CONSTANT varchar2(10) := utl_tcp.CRLF;
BOUNDARY CONSTANT varchar2(256) := '-----7D81B75CCC90D2974F7A1CBD';
FIRST_BOUNDARY CONSTANT varchar2(256) := '--'||BOUNDARY||CRLF;
LAST_BOUNDARY CONSTANT varchar2(256) := '--'||BOUNDARY||'--'||CRLF;
MULTIPART_MIME_TYPE CONSTANT varchar2(256) := 'multipart/mixed; boundary="'||BOUNDARY||'"';
mail_conn utl_smtp.connection;
sender VARCHAR2(200);
mhost VARCHAR2(30);
inRecipient VARCHAR2(100);
inMessage VARCHAR2(100);
mime_type varchar2(255) := 'text/html';
attachment_file_name varchar2(255) := 'abc.txt';
--attachment_file_name varchar2(255) := 'abc.txt';
PROCEDURE send_header(name IN VARCHAR2, header IN VARCHAR2) AS
BEGIN
utl_smtp.write_data(mail_conn, name || ': ' || header || utl_tcp.CRLF);
END;
procedure send_receive_header(name in varchar2, header in varchar2) is
begin
utl_smtp.write_data(mail_conn, name||': '||header||CRLF);
end;
BEGIN
inMessage :='DENEME1';
inRecipient:='ctahtaci@yfas.com.tr';
mhost:='193.193.193.96';
mail_conn := utl_smtp.open_connection(mhost, 25);
sender :='ct_deneme_attach@yfas.com.tr';
utl_smtp.helo(mail_conn, mhost);
utl_smtp.mail(mail_conn, sender);
utl_smtp.rcpt(mail_conn, inRecipient);
utl_smtp.open_data(mail_conn);
send_header('From', 'xxxxx');
send_header('To', '"Recipient"
send_header('Subject', 'Hello1');
send_header('Content-Type',MULTIPART_MIME_TYPE);
--utl_smtp.write_data(c, utl_tcp.CRLF || 'Hello, world!');
-- utl_smtp.data(mail_conn, inMessage);
----------------------------------------
-- Send the main message text
----------------------------------------
-- mime header
utl_smtp.write_data(mail_conn, FIRST_BOUNDARY);
send_receive_header('Content-Type',mime_type);
utl_smtp.write_data(mail_conn, CRLF);
utl_smtp.write_data(mail_conn, 'see attachment');
utl_smtp.write_data(mail_conn, CRLF);
-- add the attachment
utl_smtp.write_data(mail_conn, FIRST_BOUNDARY);
send_receive_header('Content-Type',mime_type);
send_receive_header('Content-Disposition','attachment; filename= '||attachment_file_name);
utl_smtp.write_data(mail_conn, CRLF);
utl_smtp.write_data(mail_conn, 'This is the attachment and this text is written in add attachement section');
utl_smtp.write_data(mail_conn, CRLF);
-- Close the message
utl_smtp.write_data(mail_conn, LAST_BOUNDARY);
utl_smtp.close_data(mail_conn);
utl_smtp.quit(mail_conn);
EXCEPTION
WHEN OTHERS THEN
null;
END;