Selecting from Multiple Tables but requiring data to match from a 3rd table
Hello Everyone,
I'm having alot of trouble with this select
I have three tables:
prod_poured, conc_test, and cyl_breakTo put together my report, I need to grab this data:
cyl_break.pour_no "Pour Number", cyl_break.cyl_id "Cylinder ID", cyl_break.pour_d "Pour Date", conc_test.mix "Mix #", conc_test.amb_t "Ambient Temperature", conc_test.conc_t "Concrete Temperature", conc_test.air "Air %", cyl_break.break_d "Break Date", cyl_break.age "Age (Days)", cyl_break.spec_str "Specified Strength", cyl_break.str "Specimen Strength"and I need it to grab all data in those two tables when one column in the prod_poured table meets a certain condition
This is what I have so far:
select cyl_break.pour_no "Pour Number", cyl_break.cyl_id "Cylinder ID", cyl_break.pour_d "Pour Date", conc_test.mix "Mix #", conc_test.amb_t "Ambient Temperature", conc_test.conc_t "Concrete Temperature", conc_test.air "Air %", cyl_break.break_d "Break Date", cyl_break.age "Age (Days)", cyl_break.spec_str "Specified Strength", cyl_break.str "Specimen Strength"
from conc_test inner join cyl_break on conc_test.pour_no = cyl_break.pour_no, prod_poured
where conc_test.pour_no = prod_poured.test_id and prod_poured.job_no = '9-12-821';It gives me the right results but wayyy too many of them so obviously I've got something wrong.
the results it gives are this:
Pour Number Cylinder ID Pour Date Mix # Ambient Temperature Concrete Temperature Air % Break Date Age (Days) Specified Strength Specimen Strength
100322A 100322A3 22-MAR-10 10 16 16 4.2 19-APR-10 28 35 50.6
100322A 100322A3 22-MAR-10 10 16 16 4.2 19-APR-10 28 35 50.6
100322A 100322A3 22-MAR-10 10 16 16 4.2 19-APR-10 28 35 50.6
100322A 100322A3 22-MAR-10 10 16 16 4.2 19-APR-10 28 35 50.6
100322A 100322A3 22-MAR-10 10 16 16 4.2 19-APR-10 28 35 50.6
100322A 100322A3 22-MAR-10 10 16 16 4.2 19-APR-10 28 35 50.6
100322A 100322A3 22-MAR-10 10 16 16 4.2 19-APR-10 28 35 50.6
100322A 100322A3 22-MAR-10 10 16 16 4.2 19-APR-10 28 35 50.6
100322A 100322A3 22-MAR-10 10 16 16 4.2 19-APR-10 28 35 50.6
100322A 100322A4 22-MAR-10 10 16 16 4.2 19-APR-10 28 35 50.4
100322A 100322A4 22-MAR-10 10 16 16 4.2 19-APR-10 28 35 50.4
100322A 100322A4 22-MAR-10 10 16 16 4.2 19-APR-10 28 35 50.4
100322A 100322A4 22-MAR-10 10 16 16 4.2 19-APR-10 28 35 50.4
100322A 100322A4 22-MAR-10 10 16 16 4.2 19-APR-10 28 35 50.4
100322A 100322A4 22-MAR-10 10 16 16 4.2 19-APR-10 28 35 50.4
100322A 100322A4 22-MAR-10 10 16 16 4.2 19-APR-10 28 35 50.4
100322A 100322A4 22-MAR-10 10 16 16 4.2 19-APR-10 28 35 50.4
100322A 100322A4 22-MAR-10 10 16 16 4.2 19-APR-10 28 35 50.4
100324A 100324A3 24-MAR-10 10 9 15 5.8 21-APR-10 28 35 51.9
100324A 100324A3 24-MAR-10 10 9 15 5.8 21-APR-10 28 35 51.9
100324A 100324A3 24-MAR-10 10 9 15 5.8 21-APR-10 28 35 51.9
100324A 100324A3 24-MAR-10 10 9 15 5.8 21-APR-10 28 35 51.9
100324A 100324A4 24-MAR-10 10 9 15 5.8 21-APR-10 28 35 50.8
100324A 100324A4 24-MAR-10 10 9 15 5.8 21-APR-10 28 35 50.8
100324A 100324A4 24-MAR-10 10 9 15 5.8 21-APR-10 28 35 50.8
100324A 100324A4 24-MAR-10 10 9 15 5.8 21-APR-10 28 35 50.8
100326B 100326B3 26-MAR-10 10 9 15 5.7 23-APR-10 28 35 48.3
100326B 100326B3 26-MAR-10 10 9 15 5.7 23-APR-10 28 35 48.3
100326B 100326B3 26-MAR-10 10 9 15 5.7 23-APR-10 28 35 48.3
100326B 100326B3 26-MAR-10 10 9 15 5.7 23-APR-10 28 35 48.3
100326B 100326B3 26-MAR-10 10 9 15 5.7 23-APR-10 28 35 48.3
100326B 100326B3 26-MAR-10 10 9 15 5.7 23-APR-10 28 35 48.3
100326B 100326B3 26-MAR-10 10 9 15 5.7 23-APR-10 28 35 48.3
100326B 100326B3 26-MAR-10 10 9 15 5.7 23-APR-10 28 35 48.3
100326B 100326B3 26-MAR-10 10 9 15 5.7 23-APR-10 28 35 48.3
100326B 100326B3 26-MAR-10 10 9 15 5.7 23-APR-10 28 35 48.3
100326B 100326B3 26-MAR-10 10 9 15 5.7 23-APR-10 28 35 48.3
100326B 100326B3 26-MAR-10 10 9 15 5.7 23-APR-10 28 35 48.3
100326B 100326B3 26-MAR-10 10 9 15 5.7 23-APR-10 28 35 48.3
100326B 100326B3 26-MAR-10 10 9 15 5.7 23-APR-10 28 35 48.3
100326B 100326B4 26-MAR-10 10 9 15 5.7 23-APR-10 28 35 49
100326B 100326B4 26-MAR-10 10 9 15 5.7 23-APR-10 28 35 49
100326B 100326B4 26-MAR-10 10 9 15 5.7 23-APR-10 28 35 49
100326B 100326B4 26-MAR-10 10 9 15 5.7 23-APR-10 28 35 49
100326B 100326B4 26-MAR-10 10 9 15 5.7 23-APR-10 28 35 49
100326B 100326B4 26-MAR-10 10 9 15 5.7 23-APR-10 28 35 49
100326B 100326B4 26-MAR-10 10 9 15 5.7 23-APR-10 28 35 49
100326B 100326B4 26-MAR-10 10 9 15 5.7 23-APR-10 28 35 49
100326B 100326B4 26-MAR-10 10 9 15 5.7 23-APR-10 28 35 49
100326B 100326B4 26-MAR-10 10 9 15 5.7 23-APR-10 28 35 49
100326B 100326B4 26-MAR-10 10 9 15 5.7 23-APR-10 28 35 49
100326B 100326B4 26-MAR-10 10 9 15 5.7 23-APR-10 28 35 49
100326B 100326B4 26-MAR-10 10 9 15 5.7 23-APR-10 28 35 49
100326B 100326B4 26-MAR-10 10 9 15 5.7 23-APR-10 28 35 49
100324E 100324E3 24-MAR-10 10 10 15 6 21-APR-10 28 35 50.7
100324E 100324E3 24-MAR-10 10 10 15 6 21-APR-10 28 35 50.7
100324E 100324E3 24-MAR-10 10 10 15 6 21-APR-10 28 35 50.7
100324E 100324E3 24-MAR-10 10 10 15 6 21-APR-10 28 35 50.7
100324E 100324E3 24-MAR-10 10 10 15 6 21-APR-10 28 35 50.7
100324E 100324E4 24-MAR-10 10 10 15 6 21-APR-10 28 35 51.6
100324E 100324E4 24-MAR-10 10 10 15 6 21-APR-10 28 35 51.6
100324E 100324E4 24-MAR-10 10 10 15 6 21-APR-10 28 35 51.6
100324E 100324E4 24-MAR-10 10 10 15 6 21-APR-10 28 35 51.6
100324E 100324E4 24-MAR-10 10 10 15 6 21-APR-10 28 35 51.6The results I need it to give are this:
100322A 100322A3 22-MAR-10 10 16 16 4.2 19-APR-10 28 35 50.6
100322A 100322A4 22-MAR-10 10 16 16 4.2 19-APR-10 28 35 50.4
100324A 100324A3 24-MAR-10 10 9 15 5.8 21-APR-10 28 35 51.9
100324A 100324A4 24-MAR-10 10 9 15 5.8 21-APR-10 28 35 50.8
100324E 100324E3 24-MAR-10 10 10 15 6 21-APR-10 28 35 50.7
100324E 100324E4 24-MAR-10 10 10 15 6 21-APR-10 28 35 51.6
100326B 100326B3 26-MAR-10 10 9 15 5.7 23-APR-10 28 35 48.3
100326B 100326B4 26-MAR-10 10 9 15 5.7 23-APR-10 28 35 49As you can see my query provides the right results, just way too many of them. I only need to have one result per cylinder id.
I can't seem to wrap my mind around this one and if somebody could put together a proper select based on what I need that would be extremely helpful. If you need any more data to provide help just ask and I'll paste it.
Thanks,
dtr
Edited by: dtr on Apr 26, 2010 11:12 AM
dtr wrote:
Hi,
Here are the create table statements:
create table conc_test
(p_date date, job_no varchar, mix varchar, pour_no varchar, amb_t varchar, conc_t varchar, slump varchar, air varchar, density varchar, cyl_cast_time timestamp)
create table cyl_break
(job_no varchar, pour_no varchar, cyl_id varchar, pour_d varchar, break_d varchar, age varchar, spec_str varchar, str varchar, mix);
create table prod_poured
(prod_id varchar, pour_id varchar, test_id varchar);
Great!
Don't forget to post the INSERT statements, and the output from that data (if it is different from what you posted in your first message).
Basically I need to pull the data I showed above out of conc_test and cyl_break, but only data that has the proper job_number which is retrieved from the prod_poured table. The prod_poured test_id for everything that has the proper prod_poured job_no So an IN-subquery, like Sudhakar and I suggested, should work.
What was the problem when you tried them? Post the query you ran, even if you just copied and pasted it from this thread: there may have be an editing error.
prod_poured test_id is the same thing as conc_test pour_no and cyl_break pour_noExactly! But that doesn't answer the question: Is that value unique in all the tables? If not, in which tables can it be duplicated?
Similar Messages
-
Using radio button selection in multiple tables
Hello All,
I've got a bit of a design issue and it being a Friday my brain is a bit foggy and I can't seem to figure out a solution.
what I want to do is have 3 tables. The user should only be able to select one line from any of the three tables.
I can do this by having events that clear down selection on the two other tables on any selection of the third, but the select buttons of tables don't really give the UI impression that only one row can be selected. To do this I'd like to use the radio button element.
so
table A
choice - name
(o) - Anne
(o) - Bob
(o) - Charlie
Table B
choice - name
(x) - David
(o) - Ellen
(o) - Fran
Table C
choice - name
(o) - George
Here the entry in table B for David is selected. But any selection of any of the other options should deselected.
My thoughts are to use a radio button ui element, bind the "selected" value to a unique id for each row/table (an attribute of the node element for each table) and the value to a common shared attribute (not table specific).
Any better ideas - and certainly any which would mean I'm not going to have to maintain a lookup table of my unique ids and node elements to find out which one is selected?
Cheers,
ChrisOk - here's how I did it.
I created another lookup table which had a guid and reference to the element.
in the each elements I had a guid which I bound to the key for selection property of the radio button in the table.
I then bound the selected key property to an attribute that was common to all elements.
in my "processing" logic I read the selected key, read the lookup table - and therefore got the reference to the selected element.
Would have been an awful lot easier if I could have used a reference to the element itself as the "key" - but that was required to be a character field.
[image showing radio button selection working across multiple tables|http://i51.tinypic.com/bi79dx.jpg]
End result works quite nicely.
Cheers,
Chris -
Dynamic select for multiple tables
Hi Thanks for your reply.Can you please help me in this issue.
I have a requirement like how to select data from multiple tables using dynamic select. How do we maintain dynamic where condition.
Manohar.[How to write dynamic where clause|How to write a Dynamic Where clause]
-
Row selection across multiple tables
Hi
I currently have multiple tables where, if the user selects a particular row or group of rows in one table the correspondign row or group of rows is selected in the other table.
At the moment I've acheived this by placing listSelection listeners on all the tables so that when the selection on one table changes it fires an event and updates the slection on the other tables using:
secondTable.setRowSelectionInterval(
firstTable.getSelectedRows()[0],
firstTable.getSelectedRows()[firstTable.getSelectedRowCount() - 1]
);This works fine if the user selects a single row or a continuous group of rows. THe problem is if the user selected a non-continuous group, or selects a continuous group and then deselects some of these rows.
Because the method I've got selects all rows between the start and finish of the selection it means rows are highlighted on the other tables that are not highlighted on the first table.
My thoughts on how to approach this would be to cycle through the array of selected rows and select the corresponding rows in the other tables individually rather than selecting a range, but I can't see how to accomplish this. Could anyone give me some pointers or suggestions.
ThanksWhat you are doing is correct in principle (use a
listener to propagate the selection)
Always a good start :-)
but you need to
understand the subtleties of the ListSelectionEvent -
read the API carefully - it gives you a range of
indices which may have changed but does not tell you
whether any specific indices in that range are
selected or unselected.
That makes sense, the event just indicates that the selection has changed yes?
For that you will need to get
the source ListModel from the event and query each
row in the event range to determine its selection
state.
This is where I run into difficulty. I think I can go through the each row and find out if its selected or not (using isSelectedIndex(i))
What I'm unsure what to do is how to set that for the rows in the other ListModels. What I would have normally done would be something like
otherListModel.getIndex(i).setSelected(firstListModel.isSelectedIndex(i));But as the api doesnt list the methods to do that I think I might not have got this concept sorted in my head. Could someone provide me with some pointers?
Thanks -
Random select using multiple tables
Hello World!!!
I'm trying to fix a form I modified last month and it's causing me fits!
I need to add another validation element (email address) to my password validation Form. The problem lies in the fact that I can't simply add an additional SELECT Statement to the query because it won't randomly select the same number that the first one did (records won't match). When I try to JOIN on the tables inside the inner SELECT, basically the same thing happens. I get an a result for the "e-mail" column but it doesn't match the same record as the first two.
Is there an easier way of doing this??? Here's the code I'm using that works for my first two column returns (from the agent_sec_questions Table). I'm trying to add one more column (email) from the agent_data Table.
Thanks in advance for any suggestions.
SELECT security_question, question_number
FROM (SELECT security_question, question_number
FROM agent_sec_questions
WHERE agent_id =
(SELECT agent_id
FROM agent_data
WHERE username = 'john doe')
ORDER BY DBMS_RANDOM.VALUE (1, 9))
WHERE ROWNUM = 1;Here's the solution I came up with if interested. I got the random number first, then joined my tables. If you have a better one, please let me know...
Chow!
M
SELECT DBMS_RANDOM.VALUE(1,3) INTO Sel_Num FROM DUAL;
MESSAGE ('Sel_Num= '||Sel_Num||' ID= '||UPPER(:LOGON_BLOCK.USERID));
pause;
SELECT b.email, a.security_question, a.question_number
INTO L_email, L_sec_q, L_q_num
FROM lookup.agent_sec_questions a, lookup.agent_data b
WHERE b.agent_id = a.agent_id
AND b.username = TRIM(UPPER(:LOGON_BLOCK.USERID))
AND a.question_number = sel_Num
AND ROWNUM = 1; -
Select * for multiple tables in cfquery does not work anymore as it used to with CF5
I am migrating from CF5. the following code used to work:
SELECT *
FROM tablea a, tableb b
where a.id =b.id
now I get an error when getting the value of ID (error:
queryname.ID undefined). I suspect the * is the problem and is not
permitted in that format with CF 7.
Any help will be appreciated
Thankscfdump is, for the most part, a debugging tool which allows
you to look at varialbes and their values at various points of the
template. Rarely would you want to let real users see that sort of
output.
I'd be suspicious if adding cfdump, and nothing else solved
the problem. I also wouldn't rely on it as a permanent solution.
Using select * for a query against more than one table is still
"sloppy" code and cold fusion tends be less forgiving of sloppy
code with each upgrade.
In case you were wondering, it's "sloppy" because it brings
back more data than you need. You will never need the joining
fields twice. -
Hello,
I need to calculate a list of people, who got some services more that 2 times with the same service koda (pas_kodas) to the same person (zmo_kodas). It should not depend on report number.
http://www.gentoo.lt/sql.jpg
What I get is in green (services are calculated more than 2 times BUT in the same report).
What I need is in red: calculate servises more that 2 times ACCROSS all reports to the same person (zmo_kodas).
http://pastebin.com/dhSnnKnC
One person (zmo_kodas) can have a lot of reports (ats_nr).
Every report can have one or more services (pas_kodas).
Any ideas?Hi,
This sounds like a job for the COUNT function, perhaps:
WITH double_recipients AS
SELECT DISTINCT zmo_kodas
FROM table_x
GROUP BY zmo_kodas, pas_kodas
HAVING COUNT (*) > 2
SELECT x.*
FROM table_x x
JOIN double_recipients d ON d.zmo_kodas = d.zmo_kodas
;I'm making a lot of guesses about your table(s).
I hope this answers your question.
If not, post a little sample data (CREATE TABLE and INSERT statements, relevant columns only) for all tables, and also post the results you want from that data.
Explain, using specific examples, how you get those results from that data. Post everything on this site.
Always say which version of Oracle you're using. -
Change the display of the multiple Table items using a single Drop-down
I have created a Web Template in BEx WAD (BW 3.5) with 4 Tables assigned to 4 dfferent Queries. Now I want to change the display of the all the Four Tables based on the selection of display properties chosen in a single Dropdown item. The properties to be selected in the dropdown are like changing the Alternate style display of Rows, Suppress Alternate Style, Display only 30 Rows or 60 Rows.
Please help me in writing the script necessary to pass the command from the dropdown to all the Tables to get the desired output.
Thanks,
Krishna
Edited by: Hari Krishna Velampalli on Oct 26, 2008 12:00 AMDipika, Thanks for the response.
I tried using that option but again since we cannot give custom options in a drop-down,
I created a Form with a drop-down list of options like Suppress Result Rows, Suppress alternate style of rows, Display only 30 Rows, Display only 100 rows .. and so on.
Now I am able to change the display of my first table by selecting the options in the drop-down list. But my intention is to apply that selection to Multiple Tables.
How can I achieve that?
HK -
Select from 4 tables but include data from 3 even if 4th is null
Hello -
I'm quite new to oracle and apex, but enjoying learning - but sometimes I need a gentle nudge to know what I need to learn about.
I have a select statement that works - selecting specific columns from 3 tables:
SELECT
"TERRITORIES"."TER_NAME" "TER_NAME",
"TERRITORY_TYPES"."TTP_DESCRIPTION" "TTP_DESCRIPTION",
"COUNTRIES"."CNT_DESCRIPTION" "COUNTRY"
FROM
"TERRITORIES", "TERRITORY_TYPES","COUNTRIES"
WHERE
"TERRITORIES"."TER_TTP_ID"="TERRITORY_TYPES"."TTP_ID"
and
"COUNTRIES"."CNT_TER_ID"="TERRITORIES"."TER_ID"
I want to add in a 4th table for, you guessed it, States.
However, many of the countries do not yet have states in the states table (and may never have any). Therefore, they do not appear in the results. I want them included in the query, so that I'll have the opportunity to add in the data via Apex.
Is there a phrase I can insert in the 1st query so that I'll get data for Territory Type, Territory and Country, even if the State table is null?
Or, do I need to insert records into the state table, such as: insert into states (state_ID, STATE_CNT_ID) values (state_seq.nextval,2). If so, do I just do that over and over, replacing the value? Or is this where I need to learn about bind variables? Or some other command?
Thank you-
Marion in NY
Edited by: mtpaper on Oct 24, 2009 12:54 PM
I FIGURED IT OUT! I DID IT! How do I mark myself as helpful???
insert INTO states
(state_ID, STATE_CNT_ID)
SELECT state_seq.nextval, cnt_id
FROM countries
WHERE not exists (select * from states where states.state_cnt_id = countries.cnt_id)
Edited by: mtpaper on Oct 24, 2009 1:10 PMYou certainly could insert data into the STATES table, but I generally wouldn't advise inserting rows into a STATES table for states that don't actually exist. It would seem to make far more sense to just do an outer join when you include the STATES table in your query
SELECT "TERRITORIES"."TER_NAME" "TER_NAME",
"TERRITORY_TYPES"."TTP_DESCRIPTION" "TTP_DESCRIPTION",
"COUNTRIES"."CNT_DESCRIPTION" "COUNTRY",
s.state_name
FROM TERRITORIES t ,
TERRITORY_TYPES tt,
COUNTRIES c,
states s
WHERE "TERRITORIES"."TER_TTP_ID"="TERRITORY_TYPES"."TTP_ID"
and "COUNTRIES"."CNT_TER_ID"="TERRITORIES"."TER_ID"
and c.cnt_id = s.state_cnt_id(+)The {noformat}(+){noformat} operator indicates that you want to do an outer join. So if there is no row in the STATES table that matches the join condition, a NULL is returned.
From a purely stylistic standpoint, I would generally suggest using aliases (i.e. the T, TT, C, and S in the FROM clause) rather than having to constantly write out all the table names. And I wouldn't suggest putting double-quotes around everything-- that forces all your identifiers to be upper case and case sensitive.
Justin -
Purge data older than an year from multiple tables
Hello all,
I have a requirement to purge data older than 1 year.
These are multiple related table with 300 million rows in each and need to delete about 1 million rows. I need to archive the data to a different database for some tables and then delete and for the other tables I dont need to archive but just delete.
All these tables are being used in transactional replication.
I need to join these tables to delete data as some of them wont have a timestamp column
I was thinking to run the purge job based off 2 sql agent jobs one which will archive and the delete and the other which would only delete where archiving is not required. All these tables use a lot of guid based columns.
What would be the best strategy to purge the data? My concern is the transaction replication. Any help in preparing the script to purge data in batches older than 1 year.
ThanksHopefully this example will help you:
DECLARE @transactions TABLE (transactionID INT IDENTITY, transactionDate DATE, clientID INT)
DECLARE @clients TABLE (clientID INT IDENTITY, clientName VARCHAR(30))
INSERT INTO @clients (clientName) VALUES ('James'),('Jean-Luc'),('Jonathon'),('Katheryn'),('Ben')
INSERT INTO @transactions (transactionDate, clientID) VALUES ('2000-01-01',1),('2000-01-01',2),('2000-01-01',3),('2000-01-01',4),('2000-01-01',5),('2015-01-01',4),('2015-01-01',5)
DELETE c FROM @clients c
LEFT OUTER JOIN @transactions t
ON c.clientID = t.clientID
AND t.transactionDate > DATEADD(YEAR,-1,CURRENT_TIMESTAMP)
WHERE t.clientID IS NULL
DELETE t FROM @transactions t
WHERE t.transactionDate < DATEADD(YEAR,-1,CURRENT_TIMESTAMP)
SELECT *
FROM @clients
SELECT *
FROM @transactions
Of course, you're going to want to use similar logic to move the records before you delete them, but you can specify the table to delete by its alias in the delete statement. -
How to dynamically display the data from a table base on row selection of another table in ADF
Hi ,
I have a requirement in ADF. I need to change the data of a table based on row selection of another Table . Both the table have a Parent Child relationship between them. They have a common attribute say department_id.
For this I created bind variable in view object of employees table and wrote a where clause in the sql query using that bind variable. Then I created method for selection listener of department Table in java bean.
My method is following
public void onrowselection(SelectionEvent selectionEvent) {
RichTable richTable = (RichTable)selectionEvent.getSource();
CollectionModel tableModel = (CollectionModel)richTable.getValue();
JUCtrlHierBinding adfTableBinding = (JUCtrlHierBinding)tableModel.getWrappedData();
Object selectedRowData = richTable.getSelectedRowData();
JUCtrlHierNodeBinding nodeBinding = (JUCtrlHierNodeBinding)selectedRowData;
oracle.jbo.domain.Number newVal = (oracle.jbo.domain.Number) nodeBinding.getAttribute("DepartmentId");
Number pallet = newVal.bigDecimalValue();
System.out.println("Selected values " + pallet);
BindingContext bindingctx = BindingContext.getCurrent();
BindingContainer bindings = bindingctx.getCurrentBindingsEntry();
DCBindingContainer bindingsImpl = (DCBindingContainer) bindings;
DCIteratorBinding dciter = bindingsImpl.findIteratorBinding("EmployeesView1Iterator");//access the iterator by its ID value in the PageDef file
ViewObject vo =dciter.getViewObject();
vo.setNamedWhereClauseParam("DepartmentId", pallet);//enter your value
vo.executeQuery();
It is printing the selected value of department id from department table in the log. But it is not able to pass the value to employees view. It is showing the following error in the log
"Definition DepartmentId of type Variable is not found in EmployeesView1."
I will be very thankful if someone helps me to solve this errror or is there any other way to achieve the same requirement.
Thanks
NileshNote quite sure why you simply wont create a viewlink for the viewobject the tables are based on..
The viewlink attribute will be based on the departmentId and it's a simple master detail relationship which automatically uses ppr.
However, if both tables are on the same page; using your hack about;
On the underlying viewobject, define a viewcriteria e.g. "listById" and set your bind variable here.
I would bind table two to a RichTable component:
RichTable t2;
public void onrowselection(SelectionEvent selectionEvent) {
RichTable richTable = (RichTable)selectionEvent.getSource();
CollectionModel tableModel = (CollectionModel)richTable.getValue();
JUCtrlHierBinding adfTableBinding = (JUCtrlHierBinding)tableModel.getWrappedData();
Object selectedRowData = richTable.getSelectedRowData();
JUCtrlHierNodeBinding nodeBinding = (JUCtrlHierNodeBinding)selectedRowData;
oracle.jbo.domain.Number newVal = (oracle.jbo.domain.Number) nodeBinding.getAttribute("DepartmentId");
Number pallet = newVal.bigDecimalValue();
System.out.println("Selected values " + pallet);
refreshTable2(pallet);
BindingContext bindingctx = BindingContext.getCurrent();
BindingContainer bindings = bindingctx.getCurrentBindingsEntry();
DCBindingContainer bindingsImpl = (DCBindingContainer) bindings;
DCIteratorBinding dciter = bindingsImpl.findIteratorBinding("EmployeesView1Iterator");//access the iterator by its ID value in the PageDef file
ViewObject vo =dciter.getViewObject();
vo.setNamedWhereClauseParam("DepartmentId", pallet);//enter your value
vo.executeQuery();
private void refreshTable2(Number pallet){
RichTable x=getT2();
CollectionModel cm=(CollectionModel)x.getValue();
JUCtrlHierBinding jcb=(JUCtrlHierBinding)cm.getWrappedData();
BindingContainer bindings = bindingctx.getCurrentBindingsEntry();
DCBindingContainer bindingsImpl = (DCBindingContainer) bindings;
DCIteratorBinding dciter = bindingsImpl.findIteratorBinding(jcb.getName()+"Iterator");
ViewObject vo =dciter.getViewObject();
ViewCriteriaManager vcm=vo.getViewCriteriaManager();
ViewCriteria vc=vcm.getViewCriteria("listById");
vo.applyViewCriteria(vc);
vo.setNamedWhereClauseParam("DepartmentId",pallet);
vo.executeQuery();
AdfFacesContext.getCurrentInstance().addPartialTarget(getT2()); -
Generic datasource by function module to fetch data from multiple tables?
I'm writing a function module to fetch price, for generic datasource.
At first, extract test is OK. But InfoPackage never stop when loading data to PSA in BW.
And I find the example codes:
OPEN CURSOR WITH HOLD S_CURSOR FOR
SELECT (S_S_IF-T_FIELDS) FROM SFLIGHT
WHERE CARRID IN L_R_CARRID AND
CONNID IN L_R_CONNID.
ENDIF. "First data package ?
* Fetch records into interface table.
* named E_T_'Name of extract structure'.
FETCH NEXT CURSOR S_CURSOR
APPENDING CORRESPONDING FIELDS
OF TABLE E_T_DATA
PACKAGE SIZE S_S_IF-MAXSIZE.
IF SY-SUBRC <> 0.
CLOSE CURSOR S_CURSOR.
RAISE NO_MORE_DATA.
ENDIF.
S_COUNTER_DATAPAKID = S_COUNTER_DATAPAKID + 1.
ENDIF.
There using Cursor to fetch data package by package, and raise exception NO_MORE_DATA to stop the loading process.
Now I fetch data from multiple tables, I don't think I can use Cursor.
Then How can I handle this?
Thanks a lot.Thanks
IF IT_999[] IS INITIAL.
SELECT A~KNUMH A~MATNR A~KSCHL VKORG VTWEG A~DATBI A~DATAB KBETR KMEIN KPEIN C~MTART APPENDING CORRESPONDING FIELDS OF
TABLE TP_DATA
FROM A999 AS A
INNER JOIN KONP AS B
ON A~KNUMH = B~KNUMH
INNER JOIN MARA AS C
ON A~MATNR = C~MATNR
* FOR ALL ENTRIES IN IT_999
WHERE
* A~KNUMH = IT_999-KNUMH AND
( ( A~KSCHL = 'ZPRC' AND VKORG = 'Z000' AND VTWEG = 'Z1' ) OR
( A~KSCHL = 'ZPRD' AND VKORG = 'A000' AND VTWEG = 'Y3' ) ) AND
* A~DATBI >= SY-DATUM AND
LOEVM_KO = ''.
SELECT A~KNUMH A~MATNR A~KSCHL VKORG VTWEG A~DATBI A~DATAB KBETR AS KHETR KMEIN KPEIN C~MTART APPENDING CORRESPONDING FIELDS OF
TABLE TP_DATA
FROM A999 AS A
INNER JOIN KONP AS B
ON A~KNUMH = B~KNUMH
INNER JOIN MARA AS C
ON A~MATNR = C~MATNR
* FOR ALL ENTRIES IN IT_999
WHERE
* A~KNUMH = IT_999-KNUMH AND
A~KSCHL = 'ZPR3' AND A~VKORG = 'I000' AND
* DATBI >= SY-DATUM AND
LOEVM_KO = ''.
ENDIF.
IF IT_997[] IS INITIAL.
SELECT A~KNUMH A~MATNR A~KSCHL VTWEG A~DATBI A~DATAB KBETR AS KHETR KMEIN KPEIN C~MTART APPENDING CORRESPONDING FIELDS OF
TABLE TP_DATA
FROM A997 AS A
INNER JOIN KONP AS B
ON A~KNUMH = B~KNUMH
INNER JOIN MARA AS C
ON A~MATNR = C~MATNR
* FOR ALL ENTRIES IN IT_997
WHERE
* A~KNUMH = IT_997-KNUMH AND
A~KSCHL = 'ZPRA' AND VTWEG = 'Y1' AND
* DATBI >= SY-DATUM AND
LOEVM_KO = ''.
ENDIF.
IF IT_996[] IS INITIAL.
SELECT A~KNUMH A~MATNR A~KSCHL A~DATBI A~DATAB KBETR AS KHETR KMEIN KPEIN C~MTART APPENDING CORRESPONDING FIELDS OF
TABLE TP_DATA
FROM A996 AS A
INNER JOIN KONP AS B
ON A~KNUMH = B~KNUMH
INNER JOIN MARA AS C
ON A~MATNR = C~MATNR
* FOR ALL ENTRIES IN IT_996
WHERE
* A~KNUMH = IT_996-KNUMH AND
A~KSCHL = 'ZPRB' AND
* DATBI >= SY-DATUM AND
LOEVM_KO = ''.
ENDIF.
SELECT MATNR "u7269u6599u53F7u7801
MEINH "u4ED3u50A8u5355u4F4Du7684u5907u7528u8BA1u91CFu5355u4F4D
UMREZ "u57FAu672Cu8BA1u91CFu5355u4F4Du8F6Cu6362u5206u5B50
UMREN "u8F6Cu6362u4E3Au57FAu672Cu8BA1u91CFu5355u4F4Du7684u5206u6BCD
FROM MARM
INTO CORRESPONDING FIELDS OF TABLE IT_MARM
FOR ALL ENTRIES IN TP_DATA
WHERE MATNR = TP_DATA-MATNR AND MEINH = TP_DATA-KMEIN.
LOOP AT TP_DATA.
IF TP_DATA-KPEIN NE 0.
TP_DATA-KBETR = TP_DATA-KBETR / TP_DATA-KPEIN.
TP_DATA-KHETR = TP_DATA-KHETR / TP_DATA-KPEIN.
ENDIF.
IF TP_DATA-KSCHL = 'ZPRA'.
* TP_DATA-MEINH = 'ZI'.
* TP_DATA-KSCHL = 'B4'.
IF TP_DATA-KMEIN = 'ZI'.
TP_DATA-KBETR = TP_DATA-KHETR / '1.17'.
ELSE.
READ TABLE IT_MARM INTO WA_MARM1 WITH KEY MATNR = TP_DATA-MATNR MEINH = TP_DATA-KMEIN.
* READ TABLE IT_MARM INTO WA_MARM2 WITH KEY MATNR = TP_DATA-MATNR MEINH = 'CT'.
TP_DATA-KHETR = TP_DATA-KHETR * WA_MARM1-UMREN / WA_MARM1-UMREZ.
* * WA_MARM2-UMREZ / WA_MARM2-UMREN.
TP_DATA-KBETR = TP_DATA-KHETR / '1.17'.
ENDIF.
ELSEIF TP_DATA-KSCHL = 'ZPRB'.
* TP_DATA-KSCHL = 'L0'.
* TP_DATA-MEINH = 'ZI'.
IF TP_DATA-KMEIN = 'ZI'.
TP_DATA-KBETR = TP_DATA-KHETR / '1.17'.
ELSE.
READ TABLE IT_MARM INTO WA_MARM1 WITH KEY MATNR = TP_DATA-MATNR MEINH = TP_DATA-KMEIN.
* READ TABLE IT_MARM INTO WA_MARM2 WITH KEY MATNR = TP_DATA-MATNR MEINH = 'BAG'.
TP_DATA-KHETR = TP_DATA-KHETR * WA_MARM1-UMREN / WA_MARM1-UMREZ.
* * WA_MARM2-UMREZ / WA_MARM2-UMREN.
TP_DATA-KBETR = TP_DATA-KHETR / '1.17'.
ENDIF.
ELSEIF TP_DATA-KSCHL = 'ZPRC' OR TP_DATA-KSCHL = 'ZPRD'.
* TP_DATA-MEINH = 'ZI'.
IF TP_DATA-KMEIN = 'ZI'.
TP_DATA-KHETR = TP_DATA-KBETR * '1.17'.
ELSE.
READ TABLE IT_MARM INTO WA_MARM1 WITH KEY MATNR = TP_DATA-MATNR MEINH = TP_DATA-KMEIN.
* READ TABLE IT_MARM INTO WA_MARM2 WITH KEY MATNR = TP_DATA-MATNR MEINH = 'WZI'.
TP_DATA-KBETR = TP_DATA-KBETR * WA_MARM1-UMREN / WA_MARM1-UMREZ.
* * WA_MARM2-UMREZ / WA_MARM2-UMREN.
TP_DATA-KHETR = TP_DATA-KBETR * '1.17'.
ENDIF.
ELSEIF TP_DATA-KSCHL = 'ZPR3'.
* TP_DATA-KSCHL = 'B2'.
IF TP_DATA-KMEIN = 'ZI'.
TP_DATA-KBETR = TP_DATA-KHETR / '1.17'.
ELSE.
READ TABLE IT_MARM INTO WA_MARM1 WITH KEY MATNR = TP_DATA-MATNR MEINH = TP_DATA-KMEIN.
* READ TABLE IT_MARM INTO WA_MARM2 WITH KEY MATNR = TP_DATA-MATNR MEINH = 'BAG'.
TP_DATA-KHETR = TP_DATA-KHETR * WA_MARM1-UMREN / WA_MARM1-UMREZ.
* * WA_MARM2-UMREZ / WA_MARM2-UMREN.
TP_DATA-KBETR = TP_DATA-KHETR / '1.17'.
ENDIF.
ENDIF.
TP_DATA-MEINH = '01'.
MODIFY TP_DATA.
E_T_DATA-MATNR = TP_DATA-MATNR.
E_T_DATA-KSCHL = TP_DATA-KSCHL.
E_T_DATA-KHETR = TP_DATA-KHETR.
E_T_DATA-KBETR = TP_DATA-KBETR.
E_T_DATA-KMEIN = TP_DATA-KMEIN.
E_T_DATA-DATAB = TP_DATA-DATAB.
E_T_DATA-DATBI = TP_DATA-DATBI.
APPEND E_T_DATA.
CLEAR WA_MARM1.
CLEAR WA_MARM2.
ENDLOOP.
Edited by: Shen Peng on Oct 20, 2010 10:09 AM -
Move data from multiple Tables to a Single Table & Convert the list to ALV.
Hi,
My aim is to get the list of Materials with their descriptions, with MRP Controller, with Unrestriced Qty. & the Reorder Qty. So, I have to fetch the data from different tables. But finally I am not able to copy or move the fetched data from multiple tables into the single final table.
Also tell me how to convert this list into ALV.
Below is the program code.
*& Report Y_REORDER_REPORT
REPORT Y_REORDER_REPORT.
tables : marc,makt, mard.
DATA: Begin of i_final occurs 0,
matnr type marc-matnr,
maktx type makt-maktx,
DISPO type marc-DISPO,
MINBE type marc-MINBE,
LABST type mard-LABST,
end of i_final.
DATA: Begin of i_marc occurs 0,
matnr type marc-matnr,
DISPO type marc-DISPO,
MINBE type marc-MINBE,
end of i_marc.
DATA: Begin of i_makt occurs 0,
matnr type makt-matnr,
maktx type makt-maktx,
end of i_makt.
DATA: Begin of i_mard occurs 0,
matnr type mard-matnr,
LABST type mard-LABST,
LGORT TYPE MARD-LGORT,
end of i_mard.
SELECT matnr
dispo
minbe from marc
into corresponding fields of table i_marc
where dispo EQ 'STR'.
SORT I_MARC by MATNR.
WRITE: /10 'Material',
75 'MRP',
80 'Reorder Qty.'.
LOOP at i_marc.
Write: /10 i_marc-matnr,
75 i_marc-dispo,
80 i_marc-minbe.
ENDLOOP.
write: /.
SELECT matnr
MAKTX from makt
into corresponding fields of table i_makt
for all entries in i_marc
where matnr = i_marc-matnr.
LOOP at i_makt.
Write: /10 i_makt-matnr,
30 i_makt-maktx.
ENDLOOP.
SELECT matnr
LGORT
LABST from mard
into corresponding fields of table i_mard
for all entries in i_marc
where matnr = i_marc-matnr.
LOOP at i_mard.
Write: /10 i_mard-matnr,
30 I_MARD-LGORT,
40 i_mard-labst.
ENDLOOP.
move i_mard-matnr to i_final-matnr.
move i_marc-dispo to i_final-dispo.
move i_marc-minbe to i_final-minbe.
move i_makt-maktx to i_final-maktx.
move i_mard-labst to i_final-labst.
WRITE: /10 'Material',
30 'Material Desc.',
75 'MRP',
80 'Reorder Qty.',
105 'Current Stock'.
LOOP at i_final.
Write: /10 i_final-matnr,
30 i_final-maktx,
75 i_final-dispo,
80 i_final-minbe,
105 i_final-labst.
ENDLOOP.
*LOOP at i_mard.
*Write: /10 i_mard-matnr,
30 i_makt-maktx,
75 i_marc-dispo,
80 i_marc-minbe,
105 i_mard-labst.
*ENDLOOP.
Regards,
VishalChange like this,
SELECT matnr
lgort
labst FROM mard
INTO CORRESPONDING FIELDS OF TABLE i_mard
FOR ALL ENTRIES IN i_marc
WHERE matnr = i_marc-matnr.
LOOP AT i_mard.
WRITE: /10 i_mard-matnr,
30 i_mard-lgort,
40 i_mard-labst.
ENDLOOP.
LOOP AT i_marc.
READ TABLE i_mard WITH KEY matnr = i_marc-matnr.
READ TABLE i_makt WITH KEY matnr = i_marc-matnr.
MOVE i_mard-matnr TO i_final-matnr.
MOVE i_marc-dispo TO i_final-dispo.
MOVE i_marc-minbe TO i_final-minbe.
MOVE i_makt-maktx TO i_final-maktx.
MOVE i_mard-labst TO i_final-labst.
APPEND i_final.
ENDLOOP.
WRITE: /10 'Material',
30 'Material Desc.',
75 'MRP',
80 'Reorder Qty.',
105 'Current Stock'. -
JDBC-XI-FILE scenario. How to extract data from multiple tables
Hi,
At this moment I didn't have the access for XI system. So here I have some silly question. Could you please clarify the same ??
If I got to extract data from single table using JDBC adapter I can put the below query in communication channel
SELECT *FROM orders WHERE new='true'.
But if I got to extract data from multiple tables, logic to be used should be like as shown below. ( from previous thread------prabhu).
SELECT <Table_2>.EID, <Table_2>.FName, <Table_2>.LName, <Table_1>.REC_DAT, <Table_1>.DESCRP
FROM <Table_1> INNER JOIN <Table_2> on
<Table_1>.CARDNO = <Table_2>.CARD
where REC_DAT = <condition>
union
SELECT <Table_2>.EID, <Table_2>.FName, <Table_2>.LName, <Table_1>.REC_DAT, <Table_1>.DESCRP
FROM <Table_1> INNER JOIN <Table_2> on
<Table_1>.CARDNO = <Table_2>.CARD
where REC_DAT = <condition>
But my query is ........how to put the above entire code in one line. (i.e in Qery place of communication channel ) ??
Thanks
KumarHi Palnati,
You either use a select query with join or a stored procedure which will contain the logic to extract the data from multiple tables. But, the limitation in case of stored procedure is u can hv only one selct query in it.
You write ur actual query provided in the parameter 'Query SQL Statement". u can also wrt a stored procedure in it. Also, u can provide a update statement in it which will update a certain flag so tht u don selct the data again.
Check the following link
<a href="http://help.sap.com/saphelp_nw04/helpdata/en/14/80243b4a66ae0ce10000000a11402f/frameset.htm">http://help.sap.com/saphelp_nw04/helpdata/en/14/80243b4a66ae0ce10000000a11402f/frameset.htm</a>
Regards,
Akshay
Message was edited by:
Akshay Salunke -
Dynamic data select from table is giving dump
Hello Experts,
Below statement is giving Dump after it move all the data in my dynamic table.
When i see in debug. All my recored are avilable in <T_TAB> Table.
SELECT * FROM (pa_tab) INTO CORRESPONDING FIELDS OF TABLE <T_TAB>.
> IF SY-SUBRC = 0.
Information on where terminated
The termination occurred in the ABAP program "ZFIR_ZTABLE_UPLOAD" in
"F_DOWNLOAD".
The main program was "ZFIR_ZTABLE_UPLOAD ".
The termination occurred in line 403 of the source code of the (Include)
program "ZFIR_ZTABLE_UPLOAD"
of the source code of program "ZFIR_ZTABLE_UPLOAD" (when calling the editor
4030).
Processing was terminated because the exception "CX_SY_OPEN_SQL_DB" occurred in
the
procedure "F_DOWNLOAD" "(FORM)" but was not handled locally, not declared in
the
RAISING clause of the procedure.
The procedure is in the program "ZFIR_ZTABLE_UPLOAD ". Its source code starts
in line 399
of the (Include) program "ZFIR_ZTABLE_UPLOAD ".
please help me.
Regards,
Amit
Message was edited by:
Amit GuptaHi Amit,
Check if you are doing the following in your program
FIELD-SYMBOLS <T_TAB> TYPE STANDARD TABLE.
DATA: g_tabref type ref to data. "Reference to your table structure
CREATE DATA g_tabref type standard table of (pa_tab).
ASSIGN g_tabref->* to <T_TAB>.
SELECT * FROM (PA_TAB) INTO TABLE <T_TAB>.
Hope this solves your problem.
Let me know if you require any further info.
Enjoy SAP. Reward points of useful
Rajasekhar
Maybe you are looking for
-
HT1977 how do I permanently erase purchased app from my itunes account?
how do I permanently erase purchased app from my itunes account? It bothers me a lot when I try to syn my device to a new computer and all the apps i've ever purchased get downloaded to a new computer even the ones I never use anymore.
-
Top 25 Most Played list does not transfer to ipod
Hi there, I updated the Top 25 Most Played list created under my ipod. The list showing in itunes shows the updated list, however the list in my ipod itself is not updated. How do i update the list in my ipod. Thanks.
-
How to Send SMS through XI (PI)
Hi Can you explain how to communicate XI with a SMPP server (SMS Server)? I have a requirement to send notifications to the users through SMS. Do we have a separate Adapter to communicate with ? Please help on this. Thanks & Regards, Chaminda.
-
How to make LR respect existing organization of large collections
Hi. I'm new to LR. I've used other graphics programs frequently (Photoshop Elements, Photoshop LE, Paint Shop Pro, The Gimp, etc.) I was convinced to buy LR by reading about its combination of features, particularly its management, and the high prais
-
hello sir i am khushal hirpara. my iphone is 3gs 8gb black. but problem is in my iphone did't download any application and did't update any software. so plz halp me.....