Sample code and senarios to use outer join?
We know the ABAP4 syntax for inner join, but never tried outer join and we even don't know if there is any outer join syntax in ABAP4 or not. Would be very appreciated if some ABAP expert here let us know if there is any outer join and list the difference between inner join and outer join with detailed senarios or when we would use outer join or when to use inner join? Also give a sample code on the outer join if there is any in ABAP?
Thanks and we will give you reward points!
Hye..
Left outer join between table 1 and table 2 where column D in both tables set the join condition:
Table 1 Table 2
A
B
C
D
D
E
F
G
H
a1
b1
c1
1
1
e1
f1
g1
h1
a2
b2
c2
1
3
e2
f2
g2
h2
a3
b3
c3
2
4
e3
f3
g3
h3
a4
b4
c4
3
|--|||--|
Left Outer Join
|--||||||||--|
| A | B | C | D | D | E | F | G | H |
|--||||||||--|
| a1 | b1 | c1 | 1 | 1 | e1 | f1 | g1 | h1 |
| a2 | b2 | c2 | 1 | 1 | e1 | f1 | g1 | h1 |
| a3 | b3 | c3 | 2 |NULL|NULL|NULL|NULL|NULL|
| a4 | b4 | c4 | 3 | 3 | e2 | f2 | g2 | h2 |
|--||||||||--|
Example
Output a list of all custimers with their bookings for October 15th, 2001:
DATA: CUSTOMER TYPE SCUSTOM,
BOOKING TYPE SBOOK.
SELECT SCUSTOMNAME SCUSTOMPOSTCODE SCUSTOM~CITY
SBOOKFLDATE SBOOKCARRID SBOOKCONNID SBOOKBOOKID
INTO (CUSTOMER-NAME, CUSTOMER-POSTCODE, CUSTOMER-CITY,
BOOKING-FLDATE, BOOKING-CARRID, BOOKING-CONNID,
BOOKING-BOOKID)
FROM SCUSTOM LEFT OUTER JOIN SBOOK
ON SCUSTOMID = SBOOKCUSTOMID AND
SBOOK~FLDATE = '20011015'
ORDER BY SCUSTOMNAME SBOOKFLDATE.
WRITE: / CUSTOMER-NAME, CUSTOMER-POSTCODE, CUSTOMER-CITY,
BOOKING-FLDATE, BOOKING-CARRID, BOOKING-CONNID,
BOOKING-BOOKID.
ENDSELECT.
Reward if helpful.
Thanks.
Imran.
Similar Messages
-
I have set up as security password-code for home screen. So when I turn it on, I forgotten the correct code and I'm locked out for 60 minutes ;( How do I retrieve or reset so I can use phone again. Please help!
You need to connect to iTunes and restore the iPhone to remove the passcode...then from a recent backup restore the content.
-
How to use outer join condition in my below query.
Hi All,
How to use outer join condition in my below query.
In the table APPS_JP.GEDIS_OFFER_HEADER goh I have more records
in the table APPS_JP.GEDIS_ORDER_BUILDS gob I have less number of records.
I want all the records from APPS_JP.GEDIS_OFFER_HEADER goh
including other conditions.
I have tried goh.OFFER_NO=gob.OFFER_NO(+) but same result.
[code]SELECT GOH.ORIG_SYSTEM,
gsp.USER_NAME,
goh.ORDER_NO,
goh.OMEGA_ORDER_NUMBER,
goh.ORDER_TYPE,
gc.CUSTOMER_ID,
gc.OMEGA_CUSTOMER_NUMBER,
CASE WHEN gc.PRIVATE = 'N' THEN gc.CUSTOMER_NAME ELSE '' END
AS COMPANY_NAME,
goh.ORDER_STATUS,
goh.TOTAL_SELLING_PRICE,
goh.TOTAL_MARGIN,
ga1.ADDRESS1
|| ','
|| ga1.ADDRESS2
|| ','
|| ga1.ADDRESS3
|| ','
|| ga1.POSTAL_CODE
|| ','
|| ga1.CITY
AS SHIPPING_ADDRESS,
ga2.ADDRESS1
|| ','
|| ga2.ADDRESS2
|| ','
|| ga2.ADDRESS3
|| ','
|| ga2.POSTAL_CODE
|| ','
|| ga2.CITY
AS BILLING_ADDRESS,
ga.ADDRESS_ID,
gol.DESCRIPTION,
APPS_JP.TZ.to_local_date (goh.OFFER_DATE, goh.OFFER_DATE_UTC)
AS OFFER_DATE,
gc.LEVEL_8,
goh.NO_OF_BUILDS,
gob.SFDC_ID,
goh.PURCHASE_ORDER_NO AS PO,
gc1.CUSTOMER_NAME AS END_USAGE,
gol.LOB,
goh.TOTAL_MARGIN_PCT,
goh.TOTAL_DISCOUNT,
goh.TOTAL_DISCOUNT_PCT
FROM APPS_JP.GEDIS_OFFER_HEADER goh,
APPS_JP.GEDIS_ORDER_BUILDS gob,
APPS_JP.GEDIS_ORDER_LINES gol,
APPS_JP.GEDIS_OFFER_RELATED_CUSTOMER gorc,
APPS_JP.GEDIS_OFFER_RELATED_CUSTOMER ship,
APPS_JP.GEDIS_OFFER_RELATED_CUSTOMER bill,
APPS_JP.GEDIS_CUSTOMER gc,
APPS_JP.GEDIS_CUSTOMER gc1,
APPS_JP.GEDIS_CONTACT gct,
APPS_JP.GEDIS_ADDRESS ga,
APPS_JP.GEDIS_ADDRESS_NORM ga1,
APPS_JP.GEDIS_ADDRESS_NORM ga2,
(SELECT DISTINCT SALESPERSON_ID, USER_NAME
FROM APPS_JP.GEDIS_SALESPERSON
WHERE SALESPERSON_ID IN
(SELECT TO_NUMBER (COLUMN_VALUE) AS SALESPERSON_ID
FROM TABLE (APPS_GLOBAL.SplitString ('337309'))))
gsp
WHERE goh.ORDER_NO <> 0
AND goh.OFFER_NO <> 0
AND goh.OFFER_NO=gol.OFFER_NO
AND gol.BUILD_NO = 1
AND gol.LINE_NO = 1
AND goh.OFFER_NO=gob.OFFER_NO
AND gob.BUILD_NO = 1
AND goh.OFFER_NO = gorc.OFFER_NO
AND gct.CONTACT_ID = gorc.CONTACT_ID
AND ga.CUSTOMER_ID = gc.CUSTOMER_ID
AND ga.PRIMARY = 'Y'
AND goh.LEAD_SALESPERSON=gsp.SALESPERSON_ID
AND goh.OFFER_NO = ship.OFFER_NO
AND ship.RELATION_TYPE = 'SHIP'
AND ga1.ADDRESS_ID = ship.ADDRESS_ID
AND ga1.CUSTOMER_ID = gc1.CUSTOMER_ID
AND goh.OFFER_NO = bill.OFFER_NO
AND bill.RELATION_TYPE = 'BILL'
AND ga2.ADDRESS_ID = bill.ADDRESS_ID
AND goh.OFFER_DATE BETWEEN APPS_JP.TZ.LOCAL_TO_DB_DATE (
SYSDATE - 30
AND APPS_JP.TZ.LOCAL_TO_DB_DATE (SYSDATE)
AND gorc.RELATION_TYPE = 'BASE'
AND gorc.CUSTOMER_ID = gc.CUSTOMER_ID
AND goh.SALES_CHANNEL = gc.SALES_CHANNEL
AND gc.SALES_CHANNEL = 'SMB'
AND goh.LEAD_SALESPERSON IN (goh.CREATED_BY, goh.LEAD_SALESPERSON)
ORDER BY goh.OFFER_NO;[/code]
Please help me how to use this outer join condition.
Thanks in advance.Hi,
If you want all the rows from goh, then you don't want any conditions like goh.OFFER_NO <> 0.
Make all the joins to goh outer joins, and make all conditions that apply to any tables joined to goh (or to tables joined to them) part of the join condition, like this:
FROM APPS_JP.GEDIS_OFFER_HEADER goh
LEFT OUTER JOIN APPS_JP.GEDIS_ORDER_BUILDS gob ON gob.OFFER_NO = goh.OFFER_NO
AND gob.BUILD_NO = 1
LEFT OUTER JOIN APPS_JP.GEDIS_ORDER_LINES gol ON gol.OFFER_NO = goh.OFFER_NO
AND gol.BUILD_NO = 1
AND gol.LINE_NO = 1
LEFT OUTER JOIN APPS_JP.GEDIS_OFFER_RELATED_CUSTOMER
gorc ...
I hope this answers your question.
If not, post a little sample data (CREATE TABLE and INSERT statements, relevant columns only) for all the tables involved, and the results you want from that data.
Simplify the problem as much as possible. For example, do you really need all those tables to show what the problem is? Of course, you need them in tyour real query, but if you understand a solution that only involves 4 or 5 tables, you'll know how to apply it to any number of tables.
Explain, using specific examples, how you get those results from that data.Always say what version of Oracle you're using (e.g. 11.2.0.2.0).
See the forum FAQ https://forums.oracle.com/message/9362002#9362002 -
Hi Guys,
I have some data in lookup tables and in the main tables the foreign keys are nullable. For this I have to use outer join query. But as it matters on performance because I am using 100's of tables like this and its making the query really slow. Is there any other way to get rid of outer join and get the same result??
Thanks in advance.
Ghulam Mustafa ButtFirst, why "avoid outer joins at all costs"? If you need the functionality of an outer join, using an outer join is the best option.
Second, I don't see where 161992's code does anything other than an inner join in a slighly more convoluted form.
Justin
Distributed Database Consulting, Inc.
http://www.ddbcinc.com/askDDBC -
How to use outer join in Corelated Update?
Hi,
I am using outer join in correlated update comand. But it is not updating the line which is not retrived from the query. Below is the example.
Update model_table a
Set a.model = (Select b.model_name from parts_table b
where b.model_id (+) = a.model_id)Check the above query and please let me know whether can user like this or not?
ThanksUpdating the values you want through subqueries is tricky. The correlated update should perform okay if the join columns are indexed but updating the correct rows may take some thought.
You might need to add a WHERE clause to the update to use the subquery to only update the rows when the subquery return value is not null - if this is what you want. Something like
Update model_table a
Set a.model = (Select b.model_name from parts_table b
where b.model_id = a.model_id)
where exists (Select b.model_name from parts_table b
where b.model_id = a.model_id)Edited by: riedelme on Jan 4, 2010 5:59 AM -
How to use outer join on 3 tables
how to use outer join on 3 tables
say tables are mkpf,lips and vbrp
mkpf-xblnr = lips-vbeln
lips-vbeln = vbrp-vgbelrefer following querry
select a~bukrs
a~anln1
a~ord42
a~ord43
b~afabe
b~ndabj
b~kaafa
b~aafag
c~kostl
d~afasl
d~ndjar
d~ndper
into corresponding fields of table gt_master
from ( ( anla as a inner join anlc as b
on abukrs = bbukrs
and aanln1 = banln1
and aanln2 = banln2 )
inner join anlz as c
on abukrs = cbukrs
and aanln1 = canln1
and aanln2 = canln2 )
inner join anlb as d
on abukrs = dbukrs
and aanln1 = danln1
and aanln2 = danln2
where a~bukrs in s_comp. -
Can I get a sample code and documents on how to use CL_GUI_ALV_GRID, cl_gui_custom_container. Or cl_salv_table
I want to create an ALV report and pick my columns with header information.
Thanks,
Eric.
Moderator Message: There are enough sample codes and documents on how to use CL_GUI_ALV_GRID. Please search for them.
Edited by: kishan P on Nov 12, 2010 10:53 AMHi Eric Adinku,
There are many reports available. In SE38 check reports starting with BCALV & SALV. Few examples include :
BCALV_EDIT_01
BCALV_EDIT_02
Thanks & Regards,
Faheem. -
Hi All,
We are migrating from on-premise SharPoint 2010 to SharePoint online 2013.
I have few questions below:
What are the possibilities and limitations of using Out of the box content search webpart?
Also, how the cross site publishing will work in SharePoint online something with managed navigations and product catalog apporach? if it is not supported, then what are the alternatives to acheive the same?
Appriciate any commnets/clarifications.Thanks in advance.
Thanks,
Dhananjay.Here are the possibilities of Content search webparts
http://office.microsoft.com/en-in/office365-sharepoint-online-enterprise-help/configure-a-content-search-web-part-in-sharepoint-HA104119042.aspx
http://office.microsoft.com/en-in/office365-sharepoint-online-enterprise-help/when-to-use-the-content-query-web-part-or-the-content-search-web-part-in-sharepoint-HA104206662.aspx
Compare the strengths and limitations of the Web Parts
It’s important that you understand the strengths and limitations of the two Web Parts because if you choose the wrong one, your site could run into performance problems. You can use both Web Parts to show content that is based on a query. In a simplified
world, here’s how you can decide between the two:
Use the CQWP when you have a limited amount of content, your query is simple, and you don’t expect your content to grow much in the future.
Use the CSWP in all other scenarios when you want to show content that is based on a query.
The table below gives a comparison of the two Web Parts:
Web Part behavior
Content Query Web Part
Content Search Web Part
Query configuration
Easy
You’ll need to know about certain search features such as
managed properties.
Query across large amounts of content
Limited
Yes
Handle complex queries
Limited
Yes
Scale to handle future content growth
Limited
Yes
Display content from other site collections
No
Yes (see
section below)
Design of query results can be customized
Yes, by using XSLT.
Yes, by using HTML.
Maintenance cost in a complex site architecture
High
Small (see
section below)
Narrow down the query results that are displayed in the Web Part
No
Yes, in combination with the
Refinement Web Part.
It was not there previously but then it was added to Office 365
http://blogs.office.com/2013/10/29/search-innovations-for-site-and-portal-design-in-sharepoint-online/
If this helped you resolve your issue, please mark it Answered -
After installing iOS 5, my ipad 2 will not accept my access code and has locked me out
after installing iOS 5, my ipad 2 will not accept my access code and has locked me out. Any ideas?
I don't know if your symptoms are the same as mine, but my problem is the same. Specifically:
My update seemed to go fine, but I noticed that items in Notification Center were not current or missing, as compared to the iPhone. Also, when iTunes saw the iPad without it being connected by cable, the portion of the iTunes screen that displayed the OS status was blank, and it told me that I had to connect physically to update. When I did, iTunes confirmed that iOS 5 was indeed installed and current.
With this, I decided to shut down the iPad completely, and restart it. When it came back up, the lock screen had changed. I now get a full keyboard (not just a number pad). When I attempt to enter my 4-digit passcode (and I know I'm entering the correctone), the iPad won't take it. Now it's completely locked and I can't access it.
The odd thing is the way the screen changed to display a full keyboard on the lock screen. This didn't happen to the iPhone.
All devices are running the current versions of everything. -
Need Sample Code for Vendor creation using JAVA API
Hi,
I have a scenario like Vendor creation using <b>Java API</b>.
1.I have Vendors (Main) Table.
2.I have <b>look up</b> tables like Account Group.
3.Also <b>Qualifier table</b>(Phone numbers) too.
Could you please give me the sample code which helps me to create Vendor records using Java API?
<b>I need Code samples which should cover all of the above scenario.</b>
<b>Marks will be given for the relevent answers.</b>
Best Regards
PK DevarajHi Devraj,
I hope the below code might solve all your problem:-
//Adding Qualified field
//Creating empty record in Qualifed table
//Adding No Qualifiers
Record qualified_record = RecordFactory.createEmptyRecord(new TableId(<TableId>));
try {
qualified_record.setFieldValue(new FieldId(<fieldId of NoQualifier), new StringValue(<StringValue>));//Adding No Qualifier
catch (IllegalArgumentException e2) {
// TODO Auto-generated catch block
e2.printStackTrace();
catch (MdmValueTypeException e2) {
// TODO Auto-generated catch block
e2.printStackTrace();
//Creating Record in Qualified table
CreateRecordCommand create_command = new CreateRecordCommand(connections);
create_command.setSession(sessionId);
create_command.setRecord(qualified_record);
try
create_command.execute();
catch(Exception e)
System.out.println(e.toString());
RecordId record_id = create_command.getRecord().getId();
//Adding the new record to Qualifed Lookup value and setting the Yes Qualifiers
QualifiedLookupValue lookup_value = new QualifiedLookupValue();
int link = lookup_value.createQualifiedLink(new QualifiedLinkValue(record_id));
//Adding Yes Qualifiers
lookup_value.setQualifierFieldValue(0 , new FieldId(<FieldID of Yes Qualifier>) , new StringValue(<StringValue>));
//Now adding LookUP values
//Fetch the RecordID of the value selected by user using the following function
public RecordId getRecordID(ConnectionPool connections , String sessionID , String value , String Fieldid , String tableid)
ResultDefinition rsd = new ResultDefinition(new TableId(tableid));
rsd.addSelectField(new FieldId(Fieldid));
StringValue [] val = new StringValue[1];
val[0] = new StringValue(value);
RetrieveRecordsByValueCommand val_command = new RetrieveRecordsByValueCommand(connections);
val_command.setSession(sessionID);
val_command.setResultDefinition(rsd);
val_command.setFieldId(new FieldId(Fieldid));
val_command.setFieldValues(val);
try
val_command.execute();
catch(Exception e)
RecordResultSet result_set = val_command.getRecords();
RecordId id = null;
if(result_set.getCount()>0)
for(int i = 0 ; i < result_set.getCount() ; i++)
id = result_set.getRecord(i).getId();
return id;
//Finally creating the record in Main table
com.sap.mdm.data.Record empty_record = RecordFactory.createEmptyRecord(new TableId("T1"));
try {
empty_record.setFieldValue(new FieldId(<FieldId of text field in Main table>),new StringValue(<StringValue>));
empty_record.setFieldValue(new FieldId(<FieldId of lookup field in Main table>), new LookupValue(<RecordID of the value retrieved using the above getRecordID function>));
empty_record.setFieldValue(new FieldId(<FieldId of Qualified field in Main table>), new QualifiedLookupValue(<lookup_value>));//QualifiedLookUp value Retrieved above
} catch (IllegalArgumentException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
} catch (MdmValueTypeException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
//Actually creating the record in Main table
CreateRecordCommand create_main_command = new CreateRecordCommand(connections);
create_main_command.setSession(sessionId);
create_main_command.setRecord(empty_record);
try
create_main_command.execute();
catch(Exception e)
System.out.println(e.toString());
Thanks
Namrata -
Internal Assertion Error while using outer join
Hi-
Has anyone experienced this error before: State: HY000. Code: 397397248. [NQODBC] [SQL_STATE: HY000] [nQSError: 10058] A general error has occurred. [nQSError: 46036] Internal Assertion: Condition !pConjunct->IsAndCond(), file server/Query/Optimizer/Request/Src/SQORToCNF.cpp, line 46. (HY000)
It happened after I changed the join in logical layer from inner join into left outer join from Fact Tab1 to Fact Tab2, This needs to be changed for cases:
Fact Tab1 contains:
Period|Currency|FX Rate
Mar-09|USD|1
Apr-09|USD|1.1
Fact Tab2 contains:
Period|Currency|Product|Profit
Mar-09|USD|Metal Abs|1000
Mar-09|USD|Grey Wood|2000
Expected Result:
Period|Currency|Product|Profit|FX Rate
Mar-09|USD|Metal Abs|1000|1
Mar-09|USD|Grey Wood|2000|1
Apr-09|USD|(NULL)|(NULL)|1.1
But, it shows the error as above (have changed the SERVER_THREAD_STACK_SIZE to 512 KB too but no luck, any idea?
Thanks,
WillHey Will,
Recently I've seen OBIEE generate some bad queries on an Oracle Database. I had setup a few time series measures and when I added more than three into a report, I got a table not found error. It turned out that it was a combination of the query getting very complex and the way it was using ANSI SQL Left Outer Join operator. I'm wondering if your situation is similar.
Can you try the following?
1. Log into the RPD and for your user, set the logging level to 7 (Manage->Security then find your user).
2. Clear all the caches (BI Server=Manage->Cache delete them all, Presentation Server=Settings->Manage Sessions then close all cursors)
3. Run the report for a date range that works fine
4. Run the report for a date range that causes the error.
5. Look at the physical SQL generated in the log files (Settings->Manage Sessions)
Compare the two queries and see if anything stands out. In fact try to execute both in SQL Developer or Toad and see if you get any errors. If you can, post the physical SQL and I might be able to notice something.
Just to confirm, you're using OCI to connect to an Oracle source right?
In my situation, I fixed it by disabling the LEFT OUTER JOIN syntax on the database. We might be able to get you to do something similar to fix your problem.
Thanks!
-Joe -
Issues with using Outer join in Data Template
Hi all,
this is my data in two tables .
Table Ronny1
colA colB
1 u
2 v
3 x
Table Ronny2
colC colD
1 q
2 r
This is my data template
<dataTemplate name="MGF" dataSourceRef="Source1">
<dataQuery>
<sqlStatement name="Q1" dataSourceRef="Source1">
<![CDATA[select C, D from Ronny2]]>
</sqlStatement>
<sqlStatement name="Q2" dataSourceRef="Source2">
<![CDATA[select A , B from lokesh1 where A = :C]]>
</sqlStatement>
</dataQuery>
<dataStructure>
<group name="G1" source="Q1">
<group name="G2" source="Q2">
<element name="A" value="A"/>
<element name="B" value="B"/>
</group>
</group>
</dataStructure>
</dataTemplate>
Now this would give me result as
A B
1 u
2 v
however my requirement is this
A B
1 u
2 v
3 x
that is, i want to display all the rows of table Ronny1 and matching rows from table Ronny2. I tried modifiying my second sql as
<![CDATA[select A , B from lokesh1 where A = :C (+)]]> ( using a outer join)
but this does give me correct data and comes back with the cartesion product.
Can anyone please answer this for me that how can we use the outer join in data templaes.
Thanks
Ronnyhey vetsrini,
sorry for the confusion here,
actually i want to display all the rows from table Ronny1 and i am also pulling in the matching rows from table Ronny2 and my data structure looks as ( pulling in column D from table Ronny2)
<dataStructure>
<group name="G1" source="Q1">
<group name="G2" source="Q2">
<element name="A" value="A"/>
<element name="B" value="B"/>
<element name="D" value="D"/>
</group>
</group>
</dataStructure>
and this is what i want the output to be
A B D
1 u q
2 v r
3 x
Hence the row where A <> C the data in the D column will be null, same as in the case of outer join.
any suggestions
Thx
Ronny -
Does any one have a sample code for sending email using IMAP ?
Hi
thank you for reading my post
I have tried to use SMTP and because of some problems i could not use it and i must use Imap (authentication required)
here is my SMTP code , does any one know how i can tune it to use Imap , or has a code snippet to send email using Imap ?
thanks
private static void postMail(String[] recipients, String subject, String message,
String from) throws MessagingException {
boolean debug = false;
class SMTPAuthenticator extends javax.mail.Authenticator
public PasswordAuthentication getPasswordAuthentication()
return new PasswordAuthentication(mail_usrname,mail_password);
//Set the host smtp address
Properties props = new Properties();
FileInputStream fis;
try {
System.out.println("Loading property file");
fis = new FileInputStream(new File("c:/email.properties"));
props.load(fis);
System.out.println("property file done");
} catch (FileNotFoundException e) {
System.out.println("file not found");
e.printStackTrace();
} catch (IOException e) {
System.out.println("can not read properties file");
e.printStackTrace();
/*props.put("mail.smtp.user", mail_usrname);
props.put("mail.smtp.host", smtpHost);
props.put("mail.smtp.port", smtpPort);
props.put("mail.smtp.starttls.enable","true");
props.put("mail.smtp.socketFactory.port", smtpPort);
// create some properties and get the default Session
Authenticator auth = new SMTPAuthenticator();
Session session = Session.getDefaultInstance(props, null);
session.setDebug(debug);
// create a message
Message msg = new MimeMessage(session);
// set the from and to address
InternetAddress addressFrom = new InternetAddress(from);
msg.setFrom(addressFrom);
InternetAddress[] addressTo = new InternetAddress[recipients.length];
for (int i = 0; i < recipients.length; i++) {
addressTo[i] = new InternetAddress(recipients);
msg.setRecipients(Message.RecipientType.TO, addressTo);
// Setting the Subject and Content Type
msg.setSubject(subject);
msg.setContent(message, "text/HTML");
System.out.println(msg.toString());
Transport.send(msg);Please try this out!!!!!!!!!
You can send emails using Outlook also. You can send email over Microsoft Exchange with this object (or another email server, using IMAP/POP).
Sub SendMailOutlook(aTo, Subject, TextBody, aFrom)
'Create an Outlook object
Dim Outlook 'As New Outlook.Application
Set Outlook = CreateObject("Outlook.Application")
'Create e new message
Dim Message 'As Outlook.MailItem
Set Message = Outlook.CreateItem(olMailItem)
With Message
'You can display the message To debug And see state
'.Display
.Subject = Subject
.Body = TextBody
'Set destination email address
.Recipients.Add (aTo)
'Set sender address If specified.
Const olOriginator = 0
If Len(aFrom) > 0 Then .Recipients.Add(aFrom).Type = olOriginator
'Send the message
.Send
End With
End Sub -
How do I use OUTER JOIN to email different message than the default
I have a devotional that goes out daily from a MOBILE table containing:
mob_id
calendardate
title
scripture
body
The same devotional goes out to 3 different churches.
I have a second TABLE called EDITED that holds an edited version of the daily devotional, containing:
edit_id
calendardate
etitle
escripture
ebody
The query should look in the edited table for a devotional first to see if it matches the current date then send it out. Otherwise it sends out the default devotional that corresponds with the current date.
I would like to send out in replacement of the default devotional to the church that edited the devotional.
I am using the following outer Join but it doesn’t work. It sends the same devotional to everybody.
<cfoutput>
<cfloop query="getClients">
<!--- determine if there is an edited version of the devotional available for this day --->
<cfquery name="getDevotional" datasource="#application.dsn#">
SELECT mobile.mob_id, mobile.display_date, mobile.title, mobile.body, mobile.scripture,edited.edit_id,edited.contact_id,edited.etitle,edited.escripture,edited. ebody
FROM mobile
left outer join edited ON mobile.display_date = edited.display_date
where mobile.display_date = <cfqueryparam value ="#dateformat(now(), "YYYY-MM-DD")#" cfsqltype="cf_sql_date">
</cfquery>
What am I missing?Yes the getClients grabs all information pertaining to the client and their layout information.
<cfquery name="getClients" datasource="#application.dsn#">
select *
from (subscriber INNER JOIN contacts ON subscriber.contact_id = contacts.contact_id)INNER JOIN layout ON contacts.contact_id = layout.contact_id
where subscriber.timezone = 3
</cfquery>
Below is the logic I used to determine which version to use:
<cfif getDevotional.edit_id NEQ "">#GetDevotional.etitle#<cfelse>#GetDevotional.title#</cfif> -
How to use outer join to display the results
I want to develop a report in which the column sequence will be as follows:
1)Item_code
2)Item_name
3)Stock
4)Pending
5)Re-order Level
6)Item_reorder_qty
I had written the query, but the problem is all the products does not get displayed. The products are more than 700. But after running the query, only 364 gets displayed.
How i can make use of outer join in the following statements :
AND ITEM_CODE = LCS_ITEM_CODE
AND ITEM_CODE = PI_ITEM_CODE
AND LCS_ITEM_CODE = PI_ITEM_CODE
in the below given query to solve this.
SELECT
ITEM_CODE,
ITEM_NAME,
((LCS_STK_QTY_BU + LCS_RCVD_QTY_BU - LCS_ISSD_QTY_BU- LCS_REJECT_QTY_BU)/IU_MAX_LOOSE_1)STK ,
SUM(TO_NUMBER(PI_QTY||'.'||PI_QTY_LS) - (PI_GI_QTY_BU/IU_CONV_FACTOR/IU_MAX_LOOSE_1))PNDG,
ITEM_RORD_LVL,
ITEM_RORD_QTY
FROM
OM_ITEM,
OM_ITEM_UOM,
OT_PO_HEAD,
OT_PO_ITEM,
OS_LOCN_CURR_STK
WHERE (ITEM_UOM_CODE = IU_UOM_CODE AND ITEM_CODE = IU_ITEM_CODE)
AND ITEM_CODE = LCS_ITEM_CODE
AND ITEM_CODE = PI_ITEM_CODE
AND LCS_ITEM_CODE = PI_ITEM_CODE
AND LCS_LOCN_CODE ='RM'
AND PI_PH_SYS_ID = PH_SYS_ID
GROUP BY ITEM_CODE,ITEM_NAME,LCS_STK_QTY_BU,LCS_RCVD_QTY_BU,LCS_ISSD_QTY_BU,LCS_REJECT_QTY_BU,IU_MAX_LOOSE_1,ITEM_RORD_LVL,ITEM_RORD_QTY
ORDER BY ITEM_CODE ASC
YogeshAs you have no table aliases I can't tell what columns relate to which tables on your join conditions.
Can you not just put (+) next to the outer joined columns you require on the where clause? Or perhaps consider using ANSI syntax for the joins such as <tableA> LEFT OUTER JOIN <tableB> ON (<join conditions>)
Maybe you are looking for
-
Discoverer Report run by the Pastoral Board called: Registered Lessees
Dear Friends, There is a report run by the Pastoral Board called: Registered Lessees DOL PN PLBU DATA ENTRY DRDL Pastoral Station Information Registered Lessees This report lists the information containted within the Pastoral stations module. The pas
-
GUI_DOWNLOAD blank lines in the middle
Hi All, I am using 'GUI_DOWNLOAD' FM to create excel file of my internal table data; Internal table is having 220 fields and expects to create 220 columns in excel file; In the middle of the excel file I get several blank lines on and off with only v
-
What can I do about this message -"Toshiba DVD Player has stopped working"
Hi My DVD Player used to work fine . . . and then I installed iTunes. It then worked for a while, but only by using 'Run as Administrator'. After a couple of weeks I started to get the message "Toshiba DVD Player has stopped working". I have uninstal
-
Hello, I'm attempting to partition my 2013 macbook pro and install windows 8. I had done this before on my 2010 macbook but it seems the bootcamp set up has changed. I have a full windows instalation disc and a DVD, yet, there seems to be no option
-
Query on folder using cfdirectory
HI i have a problem on my email page. i have to get the data on a remote pc. my cf server is running on linux, is there any ways i can access my files. i need to attach the files on my email. but before it will be attached i need to get the latest fi