Fetch the data from three tables
hi
i have three table HR,plan ,voidplan
HR table
rep_id name
1111 shyam
2222 kavi
3333 snaga
PLAN table
id rep_id name status
1 1111 shyam approved
2 2222 kavi pending
VOID PLAN table
id rep_id name status
1 1111 shaym approved
i got the row which is same in two table(HR and PLAN) using the query
select rep_id from plan p,hr h where h.rep_id=p.rep_id and status='approved'
so the output is
rep_id
1111
now i need the solution to retrieve the rep from voidplan+plan table
the result should be like this
rep_id
1111(from plan and hr)
1111(void plan)
please help me to solve this problem
regards,
vally.s
how about UNION ALL
select rep_id from plan p,hr h where h.rep_id=p.rep_id and status='approved'
union all
select rep_id from void_plan
this will get only the rows that join and then ALL rows from void_plan (but I suspect this isn't what you want?)
maybe you only want rows from void_plan that are returned from the first query
select rep_id from void_plan v
where v.rep_id in (select rep_id from plan p,hr h where h.rep_id=p.rep_id and status='approved'
)
Similar Messages
-
Fetch the data from two tables
hell all
i want to fetch the data from two tables, one is from internal table and another one is data base table. what syntax i have to use either FOR ALL ENTRIES or INNER JOIN?hi
Use FOR ALL ENTRIES.
see the sample code
select * into table tvbrk from vbrk
where fkart in ('F2', 'F3', 'RE',
'ZVEC' , 'ZVEM' , 'ZVED',
'S1')
and erdat in so_erdat
and kunag in s_kunag.
erdat in so_erdat
and fkart in ('F2', 'F3', 'RE',
'ZVEC' , 'ZVEM').
if not tvbrk is initial.
select * into table t_zregion from zregion
for all entries in tvbrk
where country = tvbrk-land1
and region = s_regio.
endif.
thanks
sitaram -
How to fetch the data from databse table and get the required output
Hi,
I have made a project that connects CEP to database table but i m getting some problem in fetching the data from database.
From the following code :
If the where condition is removed then the application runs fine but i am still not able to fetch the data from the table because it is not showing any output.
Can anyone please suggest me that how to write WHERE statement correctly and how i will be able to see the output.
Following is the config.xml for processor:
======================================
<?xml version="1.0" encoding="UTF-8"?>
<wlevs:config xmlns:wlevs="http://www.bea.com/ns/wlevs/config/application"
xmlns:jdbc="http://www.oracle.com/ns/ocep/config/jdbc">
<processor>
<name>JDBC_Processor</name>
<rules>
<query id="q1"><![CDATA[
SELECT STOCK.SYMBOL as symbol, STOCK.EXCHANGE as exchange
FROM ExchangeStream [Now] as datastream, STOCK
WHERE datastream.SYMBOL = datastream.SYMBOL ]]></query>
</rules>
</processor>
<jms-adapter>
<name>JMS_IN_Adapter</name>
<jndi-provider-url>t3://CHDSEZ135400D:7001</jndi-provider-url>
<destination-jndi-name>jms.TestKanikaQueue</destination-jndi-name>
<user>weblogic</user>
<password>welcome1</password>
</jms-adapter>
</wlevs:config>
Following is the assembly file:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:osgi="http://www.springframework.org/schema/osgi"
xmlns:wlevs="http://www.bea.com/ns/wlevs/spring" xmlns:jdbc="http://www.oracle.com/ns/ocep/jdbc"
xmlns:spatial="http://www.oracle.com/ns/ocep/spatial"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/osgi
http://www.springframework.org/schema/osgi/spring-osgi.xsd
http://www.bea.com/ns/wlevs/spring
http://www.bea.com/ns/wlevs/spring/spring-wlevs-v11_1_1_3.xsd
http://www.oracle.com/ns/ocep/jdbc
http://www.oracle.com/ns/ocep/jdbc/ocep-jdbc.xsd
http://www.oracle.com/ns/ocep/spatial
http://www.oracle.com/ns/ocep/spatial/ocep-spatial.xsd">
<wlevs:event-type-repository>
<wlevs:event-type type-name="StockEvent">
<wlevs:properties>
<wlevs:property name="SYMBOL" type="byte[]" length="16" />
<wlevs:property name="EXCHANGE" type="byte[]" length="16" />
</wlevs:properties>
</wlevs:event-type>
<wlevs:event-type type-name="ExchangeEvent">
<wlevs:class>com.bea.wlevs.event.example.JDBC_CEP.ExchangeEvent</wlevs:class>
</wlevs:event-type>
<wlevs:event-type type-name="StockExchangeEvent">
<wlevs:properties>
<wlevs:property name="symbol" type="byte[]" length="16" />
<wlevs:property name="price" type="byte[]" length="16" />
<wlevs:property name="exchange" type="byte[]" length="16" />
</wlevs:properties>
</wlevs:event-type>
</wlevs:event-type-repository>
<bean id="readConverter" class="com.bea.wlevs.adapter.example.JDBC_CEP.Adapter_JDBC" />
<bean id="outputJDBCBean" class="com.bea.wlevs.bean.example.JDBC_CEP.OutputBean_JDBC">
</bean>
<wlevs:adapter id="JMS_IN_Adapter" provider="jms-inbound">
<wlevs:listener ref="ExchangeStream" />
<wlevs:instance-property name="converterBean"
ref="readConverter" />
</wlevs:adapter>
<wlevs:processor id="JDBC_Processor" advertise="true">
<wlevs:listener ref="OutputChannel" />
<wlevs:table-source ref="STOCK" />
</wlevs:processor>
<wlevs:channel id="ExchangeStream" event-type="ExchangeEvent" advertise="true">
<wlevs:listener ref="JDBC_Processor" />
</wlevs:channel>
<wlevs:channel id="OutputChannel" event-type="StockExchangeEvent"
advertise="true">
<wlevs:listener ref="outputJDBCBean" />
</wlevs:channel>
<wlevs:table id="STOCK" event-type="StockEvent"
data-source="StockDs" table-name="STOCK" />
<wlevs:table id="STOCK_EXCHANGE" event-type="StockExchangeEvent"
data-source="StockDs" table-name="STOCK_EXCHANGE" />
</beans>
ExchangeEvent.java:
package com.bea.wlevs.event.example.JDBC_CEP;
public class ExchangeEvent {
public String SYMBOL;
public String symbol;
public String exchange;
public ExchangeEvent() {
public String getSYMBOL() {
return SYMBOL;
public void setSYMBOL(String sYMBOL) {
SYMBOL = sYMBOL;
public String getSymbol() {
return symbol;
public void setSymbol(String symbol) {
this.symbol = symbol;
public String getExchange() {
return exchange;
public void setExchange(String price) {
this.exchange = price;
Adapter Class:
package com.bea.wlevs.adapter.example.JDBC_CEP;
import com.bea.wlevs.adapter.example.JDBC_CEP.MyLogger;
import com.bea.wlevs.adapters.jms.api.InboundMessageConverter;
import java.text.DateFormat;
import java.util.Date;
import com.bea.wlevs.adapters.jms.api.MessageConverterException;
import com.bea.wlevs.event.example.JDBC_CEP.ExchangeEvent;
import javax.jms.JMSException;
import javax.jms.Message;
import javax.jms.TextMessage;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;
public class Adapter_JDBC implements InboundMessageConverter{
@SuppressWarnings("unchecked")
public List convert(Message message) throws MessageConverterException, JMSException {
Random rand = new Random();
int unique_id = rand.nextInt();
DateFormat dateFormat;
dateFormat = DateFormat.getTimeInstance();
dateFormat.format(new Date());
MyLogger.info(unique_id + " CEP Start Time is: " + dateFormat.format(new Date()));
System.out.println("Message from the Queue is :"+ message);
TextMessage textMessage = (TextMessage) message;
String stringMessage = textMessage.getText().toString();
System.out.println("Message after getting converted into String is :"+ stringMessage);
String[] results = stringMessage.split(",\\s*"); // split on commas
ExchangeEvent event1 = new ExchangeEvent();
event1.setSYMBOL(results[0]);
List events = new ArrayList(2);
events.add(event1);
return events;
Output Bean Class :
package com.bea.wlevs.bean.example.JDBC_CEP;
import com.bea.wlevs.ede.api.StreamSink;
import com.bea.wlevs.event.example.JDBC_CEP.ExchangeEvent;
import com.bea.core.datasource.DataSourceService;
public class OutputBean_JDBC implements StreamSink{
public void onInsertEvent(Object event) {
if (event instanceof ExchangeEvent) {
ExchangeEvent cacheEvent = (ExchangeEvent) event;
System.out.println("Symbol is: " + cacheEvent.getSymbol());
System.out.println("Exchange is: " + cacheEvent.getExchange());
System.out.println(DataSourceService.class.getClass());
Kindly let me know if you need further info.Do you have StockDs configured in your server config.xml?
I think the query should look more like this:
SELECT stocks.SYMBOL, stocks.EXCHANGE
FROM STOCK as stocks, ExchangeStream [Now] as datastream WHERE stocks.SYMBOL = datastream.SYMBOL
Thanks
andy -
How can i Delete the data from three tables at a time using same key.
I am New to Oracle ADF, I have a Requirement Like these, I have three tables like Employee,Salaries,Teams all of these are having one common EmpNo as common attribute, I have Search form these will return the all the employees related to that search query, when i click on Delete button the particular employe Data should delete from all the three tables based on the EmpNo.
Any Help is appreciable..1) The easiest way is to mark the foreign key constraints from SALARIES to EMPLOYEES and from TEAMS to EMPLOYEES as ON DELETE CASCADE. The DB server will then delete the necessary rows whenever you delete an employee row.
2) Another way is to implement a Before-Delete-Row DB trigger on the EMPLOYEES table where you can delete the related rows in the other tables (have in mind, that if you have foreign keys you may get a Mutating Table Exception, so this approach might be not very good).
3) An ADF way is to implement a custom EntityImpl class for the Employee entity and to override the remove() method where you can lookup the related TeamMember and Salary entities (through EntityAssoc accessors) and invoke their remove() methods too.
4) Another ADF way is to implement a custom EntityImpl class for the Employee entity and to override the doDML() method where you can delete the necessary rows in SALARIES and TEAMS tables through JDBC calls whenever a DELETE operation is being performed on the underlying Employee entity.
Dimitar -
Hi how can i fetch the data from tree table
Hi i am designing a UI in which i am creating a java tree table as on sun java site http://java.sun.com/products/jfc/tsc/articles/treetable2/index.html now i have to fetch the perticular column value on the mouse click.I have implemented mouse listener and on mouse clicked event I tried :
Object obj=tableInputOutputEntities.getValueAt(tableInputOutputEntities.getSelectedRow(),tableInputOutputEntities.getSelectedColumn());
as we usually do in case on JTable but it is also throwing null exception. Again after going through forum i found some code to get the current row and current column selected values and tried with getValueAt(int,int) method but still it is throwing nulll pointer exception. Please help me out.
public void mouseClicked(MouseEvent e)
Point p = e.getPoint();
int row = treeTable.rowAtPoint(p);
int column = treeTable.columnAtPoint(p);
Object obj=treeTable.getValueAt(row,column);
System.out.println("Object value: "+obj.toString());
}Regards
NaxyHello Kevin,
The question to use which method depend on your detail requirements. If you use BAPI, you need to find which Bapi can provide the data you want. Bapi normally use as a function called by external system. So you need to develop an external program like VB/Java to call this Bapi and move it to SQL. LSMW is use when you want to upload data from an external system to SAP. So it does not serve your requirement. Idoc can be use to export data to an external system. Again like Bapi, you need to find what Idoc can provide the data you want. However, it does not any programming from the external system. If I were you, based on your requirements, I think writing an Abap program that read the data you want and download it to NT/SQL server will be faster and easier. -
Fetch the data from the tables in the SQL 2005 server to sap R/3.
Hi Experts,
We need to fetch the data from the tables in the SQL 2005 server to sap R/3.
Please explain which will be the best approach to fetch the same and how to do it. Sample program can greatly help.
<< Please do not offer points >>
Regards,
Shobana K
Edited by: Rob Burbank on Sep 21, 2010 2:36 PMHi,
Try NATIVE SQL statements in your abap code otherwise you can try to establish jdbc connection from ABAP program.
search in SDN for samples!
Suresh -
Fetch the values from internal table inside an internal table (urgent!!)
data : BEGIN OF PITB2_ZLINFO occurs 0,
BEGDA LIKE SY-DATUM,
ENDDA LIKE SY-DATUM,
PABRJ(4) TYPE N, "Payroll Year
PABRP(2) TYPE N, "Pay. Period
ZL LIKE PC2BF OCCURS 0,
END OF PITB2_ZLINFO.
I have a internal table like this,
How to Fetch the values from internal table inside an internal table.
Kindly Help me on this..
Regards,
Ram.Hi,
Try this....
Loop at PITB2_ZLINF0.
Loop at PITB2_ZLINF0-ZL.
endloop.
Endloop.
Thanks...
Preetham S -
How to Fetch the Data from a Cube
Dear All,
We created a cube containing dimensions
Customer, Product, Branch, Activity, Time dimensions
using Oracle Analytical WorkSpace Manager.
Once Cube is created,
How can I see the Data existing in the Cube using normal SQL Queries ??? Through Analytical Workspace Manager Toll we r able to see the data. But our requirement is to see the data from the Cube using SQL Queries.
Regards,
S.Vamsi KrishnaHey I got the Solution. It follows in this way :
A Cube is nothing but a Data Storage. Based on the Mapping we given it considers the data.
To fetch the data from the Cube -> we have to write the SQl Query as below :
SELECT dealer_name,model_name,sales
FROM TABLE(OLAP_TABLE('MDB.FINAL_AW DURATION SESSION',
'DIMENSION dealer_name AS varchar2(30) FROM FINALDEAL
DIMENSION model_name AS varchar2(30) FROM FINALMODEL'));
We can create View for the above statement o
we can apply group by ,rollup, etc etc clauses
and even we can write where clauses for the above select statement.
But now my doubt is :
can we apply any calculations while mapping the Level to an Dimension.
Generally we will map Level toa dimension as DBUSER.TABLENAME.COLUMN NAME
can we apply any calculation like :
MIS.PROPKEY020MB.MATURITY_DATE+2
Please help for the above.
If any wrong is there please let me know
Regards,
S.Vamsi Krishna
can we apply -
Error in fetching the data from textfield and inserting to the database..
I'm using Java Swing as front end and MySQL as backend using the netbeans ide..I am trying to fetch the data from the textfiled in the form and insert to the database table.i've skipped the generated code..In the following code i get the erro cannot find symbol "stmt" in the actionPerformed method..
mport java.awt.event.*;
import java.sql.*;
public class BarcodeReader extends JFrame implements ActionListener {
public BarcodeReader() {
initComponents();
nb.addActionListener(this);
public void jdbcConnect(){
Connection con=null;
String url = "jdbc:mysql://localhost:3306/";
String db = "mynewdatabase";
String driver = "com.mysql.jdbc.Driver";
String user = "usrname";
String pass = "pwd";
try{
String s=newtxt.getText();
con=DriverManager.getConnection(url + db, user, pass);
Statement stmt=con.createStatement();
Class.forName(driver);
public void actionPerformed(ActionEvent e){
try{
jdbcConnect();
stmt.executeUpdate("INSERT into machine(mname) values '"+jTextField1.getText()+"'");
}}catch (Exception ex) {
System.out.println(ex);
public static void main(String args[]) {
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new BarcodeReader().setVisible(true);
}There are far too many errors to try and clear.
For one, the exception references the actionPerformed method (according to your text), so why is that not shown here?
For another you are performing, possible time-consuming, actions, and even worse IO actions, on the event thread, which is a huge no-no.
You are not closeing your resources properly, if at all, which is another huge no-no.
You are completely mixing your "view" (the gui), and your "model" (the data related classes), which is another huge no-no.
etc, etc, etc. -
Extractor class to fetch the data from PA0105
Hi All,
Can anyone suggest me the extractor class used to fetch the data from the table PA0105.
Any information regarding this will be highly helpful.If you give PA0105 all data will be extracted.
Or if you need any specific data you need to know the filed names first. check the table from SE16 for identifying the field names. and do it accordingly.
Please reward points
Regards
Venu -
How to get the data from Pooled Table T157E.
Hi Experts,
How to get the data from Pooled Table T157E.
Any help.
Thanks in Advance,
Ur's Harsha.create some internal table similar to T157E and pass all data as per SPRAS.
After that use internal table in your program as per the requirement.
Regds,
Anil -
How to delete the data from partition table
Hi all,
Am very new to partition concepts in oracle..
here my question is how to delete the data from partition table.
is the below query will work ?
delete from table1 partition (P_2008_1212)
we have define range partition ...
or help me how to delete the data from partition table.
Thanks
Sree874823 wrote:
delete from table1 partition (P_2008_1212)This approach is wrong - as Andre pointed, this is not how partition tables should be used.
Oracle supports different structures for data and indexes. A table can be a hash table or index organised table. It can have B+tree index. It can have bitmap indexes. It can be partitioned. Etc.
How the table implements its structure is a physical design consideration.
Application code should only deal with the logical data structure. How that data structure is physically implemented has no bearing on application. Does your application need to know what the indexes are and the names of the indexes,in order to use a table? Obviously not. So why then does your application need to know that the table is partitioned?
When your application code starts referring directly to physical partitions, it needs to know HOW the table is partitioned. It needs to know WHAT partitions to use. It needs to know the names of the partitions. Etc.
And why? All this means is increased complexity in application code as this code now needs to know and understand the physical data structure. This app code is now more complex, has more moving parts, will have more bugs, and will be more complex to maintain.
Oracle can take an app SQL and it can determine (based on the predicates of the SQL), which partitions to use and not use for executing that SQL. All done totally transparently. The app does not need to know that the table is even partitioned.
This is a crucial concept to understand and get right. -
To Select the data from two table one is transp table and onther is cluster
Hi All,
I want to select the data from two tables
Here i am giving with an example.
Fileds: kunnr belnr from bseg. table bseg
fields: adrnr from kna1 table: kna1.
Know i want to put these into one internal table based on kunnr and belnr.
Thanks in advance.
RameshHi,
U cant use joins on cluster table and BSEG is a cluster table so use FOR ALL ENTRIES for taht
refer this code
*& Form sub_read_bsak
text
--> p1 text
<-- p2 text
FORM sub_read_bsak.
*--Select data from BSAK Table
SELECT lifnr
augdt
augbl
gjahr
belnr
xblnr
blart
dmbtr
mwskz
mwsts
sgtxt
FROM bsak
INTO CORRESPONDING FIELDS OF TABLE it_bsak
WHERE belnr IN s_belnr
AND augdt IN s_augdt.
IF sy-subrc EQ 0.
*--Sort table by accounting document and vendor number
SORT it_bsak BY belnr lifnr.
ENDIF.
ENDFORM. " sub_read_bsak
*& Form sub_read_bseg
text
--> p1 text
<-- p2 text
FORM sub_read_bseg.
IF NOT it_bsak[] IS INITIAL.
*--Select data from BSEG table
SELECT belnr
gjahr
shkzg
kostl
hkont
ebeln
ebelp
FROM bseg
INTO CORRESPONDING FIELDS OF TABLE it_bseg
FOR ALL ENTRIES IN it_bsak
WHERE belnr EQ it_bsak-belnr
AND gjahr EQ it_bsak-gjahr
AND shkzg EQ 'S'.
IF sy-subrc EQ 0.
*--Sort table by accounting document
SORT it_bseg BY belnr.
ENDIF.
ENDIF.
ENDFORM. " sub_read_bseg -
How to bind the data from user table into user report
Hi All,
Please assist me to bind the data from user table into user report. I did create an user table with data and create a user report template (using Query Print Layout). How can I display my data into report format which I created before? Any sample program or document I can refer?
Platform: SAPB1 2005A
Add On Language: VB.Net 2003
Thanks.
rgds
ERICHi Ibai,
Thanks for your feed back. I give you an example.
Let say now i wanna print employee list, so i will go
1. Main Menu -> Reports -> HR -> Employee List
2. Choose the Selection Criteria -> OK
3. Matrix will display (Employee List)
4. I can print the report click on print button
5. Printing report
My target
1. Main Menu -> Eric_SubMenu -> Employee List
2. Matrix will display (Employee List)
3. Print button
4. Print report
My problem
Now I would like to use my own report format. My own report format means I wanna add on my logo or do some customization within the employee report. So how I am going to do? I only able to display the employee list in matrix. How do I create a new report format and display it.
Thanks.
rgds
ERIC -
How can i convert the data from mutiple-table to the other database(MSSQL)?
Dears,
How can i convert the data from mutiple-table to the other database such as MS-SQL?
I have a third party system based on MS-SQL 2000.
Now we want to make a integration between SAP R/3(Oracle) and SQL server.
When my user releases the purchase order in R/3, the application we coded will convert the releated data to the temp database on the SQL server.
But i don't know which tools will help me reach the purpose. BAPI, LSMW, IDoc... ???
Would anybody tell me which way is better and how to do?
Thanks a lot!
Kevin WangHello Kevin,
The question to use which method depend on your detail requirements. If you use BAPI, you need to find which Bapi can provide the data you want. Bapi normally use as a function called by external system. So you need to develop an external program like VB/Java to call this Bapi and move it to SQL. LSMW is use when you want to upload data from an external system to SAP. So it does not serve your requirement. Idoc can be use to export data to an external system. Again like Bapi, you need to find what Idoc can provide the data you want. However, it does not any programming from the external system. If I were you, based on your requirements, I think writing an Abap program that read the data you want and download it to NT/SQL server will be faster and easier.
Maybe you are looking for
-
I had to reset to Factory Settings recently and after reinstalling Firefox and some add-ons I have noticed that Youtube videos on some webistes such as Giantbomb.com or Joystiq.com for example don't give me the go fullscreen icon in the bottom right
-
How to deal with the checkbox columns in the two reports on the same page
Hi, I have 2 reports having checkbox column in the same page. Now how can i differentiate between these 2 checkboxes column and based on them the values in the reports ,while i have to do some processe based on these reports using checkboxes. Thnks i
-
Can I open raw files using photoshop elements
Can I open raw files using photoshop elements
-
Affter importing some pics to Trial, I am now running Full Aperture 2
After installing Upgrade to Aperture 2, all my pics from Aperture 1 were converted and show up OK. How do I get the pics that I imported into the Trial Aperture 2? I can't specify (it is greyed) that library as default library under preferences for s
-
Client Out of Memory error when running bex report
Hi, when i am running a finance report which got complex selection in the bex i am getting Error " Client Out of Memory" which terminates report processing. I request you to through some light on following questions 1. is this problem related to us