Sending sql output to email body with conditional subject line


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Sending sql output to email body with conditional subject line
# 8  
Old 03-14-2017
Quote:
Originally Posted by itzkashi
... i am able to get the desired output but only issue is with the formatting below since the source_name length varies .
...
First of all - why aren't you using the "code" tags? The Moderator has reminded you two times and is doing the work that you should be doing.
Please have a look at the video in Post #2 and use "code" tags whenever you post your code.

Now about your formatting - the source_name length could vary, but it can never exceed the size of the (I guess) VARCHAR2 datatype. So you could use the RPAD function to pad blank spaces to all the columns. Unfortunately, this will have to be hard-coded as per your table structure.

Another option could be to use an appropriate value for the "colsep" sqlplus variable. By default, it is a blank space (" "). Set it something like "|" and then remove the concatenation operators from your query.

Post your attempted code with "code" tags if you get stuck.
# 9  
Old 03-14-2017
Sorry i am new to his forum , will take care of CODE tag next time..

i tried below query using 'colsep' and got the correct formatting in the commandline but when i receive the same out put in email body the last column got jumbled again.

Code:
SET COLSEP "|"
SELECT 'LOAD_DATE SOURCE_NAME COUNTS_MATCHING'
FROM dual
    UNION ALL
SELECT load_date,source_name,(CASE WHEN table_row_count = input_record_cnt THEN 'Yes' ELSE 'No' END)
FROM t1
 WHERE insert_date = TRUNC(SYSDATE);

email body output
-------------------
Code:
20170314|SRC_OMNI           |No
20170314|SRC_CUST_EMAIL      |Yes
20170314|SRC_CONTACT_HIST         |Yes
20170314|SRC_RESPONSE_HIST         |Yes
20170314|SRC_USERNAME_ACCT_  |Yes


Moderator's Comments:
Mod Comment Thanks for trying to use CODE tags; mistaken ICODE tags corrected.

Last edited by RudiC; 03-14-2017 at 04:57 PM.. Reason: Changed ICODE to CODE tags.
# 10  
Old 03-14-2017
Quote:
Originally Posted by itzkashi
...
i tried below query using 'colsep' and got the correct formatting in the commandline but when i receive the same out put in email body the last column got jumbled again.
...
Your command-line has a monospaced font - maybe "Terminal" or Raster Fonts. Each character uses up the same amount of horizontal space, so the character "i" and "w" will be of equal width. Due to such fixed-width font, you see the output formatted properly.

Your email client, most likely, has a variable width font like, say, "Arial" or "Times New Roman". The character "i" will use up less space than the character "w". Hence the formatting gets disrupted.

If you select the text in your email client and set the font to, say, "Courier New" or "Consolas" or "Terminal" etc. then you will be able to see it properly formatted in your email body. Check the top menu items of your email program to see how the font of selected text can be changed.
This User Gave Thanks to durden_tyler For This Post:
# 11  
Old 03-15-2017
Code:
 If you select the text in your email client and set the font to, say, "Courier New" or "Consolas" or "Terminal" etc. then you will be able to see it properly formatted in your email body. Check the top menu items of your email program to see how the font of selected text can be changed.

.

Thanks for your valuable time.. i will look into this..i think it should work..

i have another query related to the same work flow..probably i will open a new thread for this..

thanks
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Red Hat

Sending email with message body and attachment

Hello experts!! I am trying to send an email with message body and attachment.but i am getting any one like message body or attachment. I tried below command: (echo "subject:test";echo "MIME-Version: 1.0";echo "content-transfer-encoding:base 64";echo "content-type:txt;name=test.txt";cat... (2 Replies)
Discussion started by: Devipriya Ch
2 Replies

2. Shell Programming and Scripting

Message Body while sending an email

I am making use of the following code to display the results of my txt file in an email: mail -s 'Count Validation Test Comparison Results' Ronit@XYZ.com < Count_Validation_Results_`date +%m%d%Y`.txt Email Output: ----------Query 1 Count Validation Results-------- Source count is 4 Target... (7 Replies)
Discussion started by: ronitreddy
7 Replies

3. Shell Programming and Scripting

Body content is in random format while sending email from Linux to my outlook.

Hi I have a script running in lunix machine which emails log file content to my outlook. Here is the actual log file result: Image-1 In-Master:25028 ReplicaDn Consumer Supplier Delay dc=xxx,dc=com lmjker0110:12345 ... (4 Replies)
Discussion started by: buzzme
4 Replies

4. Shell Programming and Scripting

Shell scripting unable to send the sql query data in table in body of email

I have written a shell script that calls below sql file. It is not sending the query data in table in the body of email. spool table_update.html; SELECT * FROM PROCESS_LOG_STATS where process = 'ActivateSubscription'; spool off; exit; Please use code tags next time for your code and data.... (9 Replies)
Discussion started by: Sharanakumar
9 Replies

5. Shell Programming and Scripting

SQL query output convert to HTML & send as email body

Hi , I have a sql query in the unix script ,whose output is shown below.I want to convert this output to HTML table format & send email from unix with this table as email body. p_id src_system amount 1 A 100 2 B 200 3 C ... (3 Replies)
Discussion started by: jagadeeshn04
3 Replies

6. Shell Programming and Scripting

Sending an email with a body and attachments using uuencode

Hi, Im having a bit of an issue with using the uuencode command and sending out an email. My aim is to send an email out which has a body and also have attachments. Currently I can either get one or the other and not both on the same email. uuencode... (4 Replies)
Discussion started by: 02JayJay02
4 Replies

7. AIX

Sending script output as email

Hi i have a script which executes daily through cron. The output of the script is appended to a log file everyday It also emails me the output of the logfile as we have the mailx command in the script The below is my requirement : Normally When I get the email it sends the entire content... (3 Replies)
Discussion started by: newtoaixos
3 Replies

8. UNIX for Dummies Questions & Answers

Sending email with attachment and body

Hi I want to able to attach a file to a email and send it with a body the body of the email is within the "body" file, and the attachment in "atch" if i send like below it will send the email correctly /usr/sbin/sendmail me@you.com< body And when i send the attachment alone... (3 Replies)
Discussion started by: sridanu
3 Replies

9. Shell Programming and Scripting

Not able to attach text in body of email while sending mail with attachment

Hi, We have been trying to send mail with attachment and it is going fine, but when we try to attach a text to the body of the email, we find that the mail is going fine with the body text but the attachment is not going through. We are using ksh. The command that is successfull without the... (6 Replies)
Discussion started by: jmathew99
6 Replies

10. Shell Programming and Scripting

Sending one email for every row as per sql result

I want to send email for every row comes out of following SQL statement thank you for your help. *****SQL STATEMENT****** Select SCUSER AS "USER IDS" , SCEUSER AS "LOCKED OUT" FROM SYS.7333.F98OWSEC; *******OUPUT COMES LIKE THIS AND ONE EMAIL COMES AS PER SCRIPT BELOW****** ******BUT... (4 Replies)
Discussion started by: s1a2m3
4 Replies
Login or Register to Ask a Question