Problem about mapping 1 column with different tables..
Hi,
I have 3 Tables (I will give examples not exact tables but same structure and logic)
Cars :
ID ( Car ID)
Name
Planes :
ID ( Plane ID)
Name
Processes :
ID ( Process ID )
Type
VehicleID {code}*Sample Processes Table Data*
{code:java}ID Type VehicleID
1 1 1
2 1 2
3 2 1
3 2 2{code}
When type is *1*, This is *Car* and means that *VehicleID* maps to *Cars Table*,
When type is *2*, This is *Plane* and means that *VehicleID* maps to *Planes Table*.
And So On 3, 4, 5, 6 .. for Additional tables.
How can i map something like that? I can not merge these tables, they all must be separated..
I used to handle this by writing native SQL with some functions, however with JPA i could not figure it out..
Thanks again
Regards.
I do not know an easy way to do this in pure JPA. EclipseLink though is able to do this using a variable one to one mapping:
http://wiki.eclipse.org/Introduction_to_Relational_Mappings_%28ELUG%29#Variable_One-to-One_Mapping
This can be set using a customizer or JPA like annotations:
@VariableOneToOne(
targetInterface=Vehicle.class,
cascade=PERSIST,
fetch=LAZY,
discriminatorColumn=@DiscriminatorColumn(name="TYPE", discriminatorType=INTEGER),
discriminatorClasses={
@DiscriminatorClass(discriminator="1", value=Cars.class),
@DiscriminatorClass(discriminator="2", value=Planes.class)
Best Regards,
Chris
Similar Messages
-
Question about suming two columns from different tables in Subquery?
Hello everyone,
I have a subquery that works great for getting the total SUM of a Billing table, but I also need to add to that SUM the total surcharges or additional charges from a separate table. I tried this by doing something like so:
(SELECT SUM(SUM(Amount) FROM Billing WHERE Billing.JobID = Jobs.ID AND Billing.BillingType = 'Invoice' AND Billing.InvoiceCanceled = 'No', SUM(Payment) FROM Payments WHERE Payments.JobID = Jobs.ID AND Payments.Type = 'Bill')) as [Amount],
But it doesn't work as there is an incorrect syntax near 'FROM'. I'm assuming this is because of the two FROM's in the Subquery? But I am not sure how else I would be able to do this then?
Any help would be greatly appreciated. I just noticed this bug and am hoping to get a fix out as quickly as possible.
Thanks Again,Hi, sorry for taking so long to get back to this post.
I tried this example like so:
(SELECT SUM(A1) AS Total1, SUM(A2) AS Total2
FROM
(SELECT
(SELECT SUM(Amount) FROM Billing WHERE Billing.JobID = Jobs.ID AND Billing.BillingType = 'Invoice' AND Billing.InvoiceCanceled = 'No') AS A1,
(SELECT SUM(Payment) FROM Payments WHERE Payments.JobID = Jobs.ID AND Payments.Type = 'Bill') AS A2),
However, get an error that an Incorrect Syntax exists near the ','. I remove the comma (Which I think should be there), and I get an error that an Incorrect Syntax exists near the '.'...
I also tried doing it like this (Based on other suggestions I've found online:
(SELECT SUM(SELECT SUM(Amount) FROM Billing WHERE Billing.JobID = Jobs.ID AND Billing.BillingType = 'Invoice' AND Billing.InvoiceCanceled = 'No') as [Amount],
(SELECT SUM(Payment) FROM Payments WHERE Payments.JobID = Jobs.ID AND Payments.Type = 'Bill') as [Additional]),
And I get an error that an Incorrect Syntax exists near 'SELECT'...
I also tried doing something like this with the SQL I already had...
(SELECT SUM(Amount) FROM Billing WHERE Billing.JobID = Jobs.ID AND Billing.BillingType = 'Invoice' AND Billing.InvoiceCanceled = 'No') as [BilledAmount],
(SELECT SUM(Payment) FROM Payments WHERE Payments.JobID = Jobs.ID AND Payments.Type = 'Bill') as [Additional],
SUM(BilledAmount + Additional) AS [TotalBilled],
But I get an error that the alias' are Invalid Column Names... I have used Alias' before so I'm not sure why this would be an issue here...
As you can see, I've been trying to figure this issue out, but haven't had much luck... :( -
How to use a USER_DATASTORE to index multiple columns in different tables
I would appreciate if somebody can give an example or point to links with examples on how to use USER_DATASTORE on multiple columns in different tables. THe Oracle Text documentation only shows multiple columns in the same table.
Thanks in advance.I am not sure why your getting the wrong results but you should seriously reconsider the approach your are taking. Using functions like this is very ineffecient and should be avoided at all cost.
-
Expression operator with different tables....
Hello All,
I am facing this problem that I have this if condition that has an expression inside it where the expression id composed out of 4 columns in 4 different tables where these tables can not be joined because there is no logical join between them. The if statement goes as follows:
if column1.table1 is equal to 0
then equate column1.table2 to column1.table3 and put in column1.table4(which is a new column to be created)
else if column1.table1 is equal to 1
then subtract column1.table2 and column1.table3 and put in column1.table4(another new column)
end if
end if
Note that the operator being used in order to have the conditional statement is the splitter operator. So my problem can be concluded in how can I have an expression that is composed out multiple column from different tables. Noting that if this is done a message saying you either need to join the tables or use a set operation and I can't do either since the data that would be outputted would be irrelevant.....
Regards,
HossamHi Hossam,
the attributes of the input group of an expression operator must come from one outgroup (of a table for example).
If you want to use columns from different tables in one expression operator, you must join them first. There is no way around it.
Try to build a complete SQL query of what you want to do. Then rebuild this query in owb.
As a rule of thumb: what cannot be done in SQL cannot be done in owb (since owb generates sql).
Regards,
Carsten. -
How to update multiple columns from different tables using cursor.
Hi,
i have two tables test1 and test2. i want to udpate the column(DEPT_DSCR) of both the tables TEST1 and TEST2 using select for update and current of...using cursor.
I have a code written as follows :
DECLARE
v_mydept1 TEST1.DEPT_CD%TYPE;
v_mydept2 TEST2.DEPT_CD%TYPE;
CURSOR C1 IS SELECT TEST1.DEPT_CD,TEST2.DEPT_CD FROM TEST1,TEST2 WHERE TEST1.DEPT_CD = TEST2.DEPT_CD AND TEST1.DEPT_CD = 'AA' FOR UPDATE OF TEST1.DEPT_DSCR,TEST2.DEPT_DSCR;
BEGIN
OPEN C1;
LOOP
FETCH C1 INTO v_mydept1,v_mydept2;
EXIT WHEN C1%NOTFOUND;
UPDATE TEST2 SET DEPT_DSCR = 'PLSQL1' WHERE CURRENT OF C1;
UPDATE TEST2 SET DEPT_DSCR = 'PLSQL2' WHERE CURRENT OF C1;
END LOOP;
COMMIT;
END;
The above code when run says that it runs successfully. But it does not updates the desired columns[DEPT_DSCR].
It only works when we want to update single or multiple columns of same table...i.e. by providing these columns after "FOR UPDATE OF"
I am not sure what is the exact problem when we want to update multiple columns of different tables.
Can anyone help me on this ?oops my mistake.....typo mistake...it should have been as follows --
UPDATE TEST1 SET DEPT_DSCR = 'PLSQL1' WHERE CURRENT OF C1;
UPDATE TEST2 SET DEPT_DSCR = 'PLSQL2' WHERE CURRENT OF C1;
Now here is the upated PL/SQL code where we are trying to update columns of different tables --
DECLARE
v_mydept1 TEST1.DEPT_CD%TYPE;
v_mydept2 TEST2.DEPT_CD%TYPE;
CURSOR C1 IS SELECT TEST1.DEPT_CD,TEST2.DEPT_CD FROM TEST1,TEST2 WHERE TEST1.DEPT_CD = TEST2.DEPT_CD AND TEST1.DEPT_CD = 'AA' FOR UPDATE OF TEST1.DEPT_DSCR,TEST2.DEPT_DSCR;
BEGIN
OPEN C1;
LOOP
FETCH C1 INTO v_mydept1,v_mydept2;
EXIT WHEN C1%NOTFOUND;
UPDATE TEST1 SET DEPT_DSCR = 'PLSQL1' WHERE CURRENT OF C1;
UPDATE TEST2 SET DEPT_DSCR = 'PLSQL2' WHERE CURRENT OF C1;
END LOOP;
COMMIT;
END;
Please let us know why it is not updating by using using CURRENT OF -
Mapping multiple columns of a table to single dimension using odi
Hi John,
Can we map multiple columns of a table to a single dimnesion?
For example, in RDBMS, for the employee details, Grade position etc will be in different columns, and in Planning these would be as members of one dimension.
So while loading data from oracle to essbase can we map these multiple columns to single dimension?
If yes how?Hi,
In your staging area/target you can concatentate the columns.
So in your interface and on your target datastore, pick the column which is going to hold the details of the concatenation.
Then in the expression editor use the CONCAT function, or you could use ||
eg CONCAT(<sourceCol1>, <sourceCol2>)
or <sourceCol1> || <sourceCol2>
obviously you need to change the information between <sourceCol1> to your source datastore column
Cheers
John
http://john-goodwin.blogspot.com/ -
One Key FIgure in more than one column with different restrictions
Hi,
I am using a key figure in more than one column with different restrictions, but restriction in one column is affecting the result in other column. What shall i do to make it independent from one another??Hi Pravender Chauhan,
If you want in Single column different value for different Rows based on same Key Figure, you can create Structure where you can define different logic for each row but using same key figure.
If you want to use different Key figures then you should have to Restricted Key Figure and for any calculation you can use calculated Key figure.
Assign points if Useful.
Regards,
Rajdeep. -
Hi all. Sorry, english is not my native language. I´ve made an .indd: each page has two columns with different threads (is a bilingual text). When I export this .indd to .epub only appears one column from a thread following the next thread. What can i do to fix this? My indesign is CS6
Thank youThere are fixed format EPUB files as can be used for children's books, etc. where there are a lot of illustrations. However, those are very work-intensive to produce. I've never worked on one.
Anne-Marie Concepcion did a Lynda.com video on producing one.
Rorohiko produces a product called ePubCrawler which can help in produced fixed format EPUB files:
Fixed Layout EPUB Assistant In InDesign: ePubCrawler | Rorohiko ... -
Using the same TableModel with different tables
hi,
is it possible to have a TableModel class that I could use to display different columns in different tables?
For example, suppose I have a TableModel containing user info (user_id, user_name, user_address) and I wanted to display (user_name, user_address) in one table, but just (user_id) (or even (user_id, user_name) in another).
If this is possible, what are some good design ideas?
thanks,
paulhi,
and thanks for your reply.
I've checked the api but I can't see how one "flips" such a switch.
Does there actually exist a "public void flipModelSwitch()" method? :-)
More seriously, precisely how do I do this?
paul -
Problem when expanding Tree - Tree with nested table column
Hi, i have created the tree using the Tree with nested table column.
I have created a node called TREE_ROOT in the context.
This node has few attributes which includes children_loaded, is_leaf, is_expanded.
I have created the recursive node TREE_SUB for the above node TREE_ROOT.
In the view, i have created the table with the master column. The above attributes have been mapped accordingly. I have created the action handler for load_children.
In this action handler method, i receive the context_element correctly. In this method, i determine the children of the selected element and the resulting children are attached to this context_element.
But the problem is: when i add elements to context_elements in the method load_children, these
elements get added to the node TREE_ROOT as well.
Please help.
thanks and best regards,
PramodI just use some types defined in this user... Well, I hope you know what is the type definition of d_period_sec,
don't you ? I didn't ask to provide all types existed now, only types you are
using.
Anyhow you have been granted with execute privilege for types you are using:
SQL> conn tau_tll/tau_tll;
Connected.
SQL> create or replace type d_period_sec as object (date# date);
2 /
Type created.
SQL> grant execute on d_period_sec to public with grant option;
Grant succeeded.
SQL> conn scott/tiger
Connected.
SQL> CREATE OR REPLACE TYPE unit_function AS OBJECT (
2 xi NUMBER,
3 yi NUMBER,
4 xe NUMBER,
5 ye NUMBER,
6 xm NUMBER,
7 ym NUMBER,
8 v NUMBER,
9 a NUMBER,
10 f NUMBER,
11 descr VARCHAR2 (20)
12 );
13 /
Type created.
SQL> grant execute on unit_function to master;
Grant succeeded.
SQL> CREATE OR REPLACE TYPE unit_moving_point AS OBJECT
2 (
3 p tau_tll.d_period_sec, -- from user TAU_TLL
4
5 m unit_function
6 )
7 /
Type created.
SQL> grant execute on unit_moving_point to master;
Grant succeeded.
SQL> CREATE OR REPLACE TYPE moving_point_tab AS TABLE OF unit_moving_point;
2 /
Type created.
SQL> grant execute on moving_point_tab to master;
Grant succeeded.
SQL> CREATE OR REPLACE TYPE moving_point AS OBJECT (u_tab moving_point_tab);
2 /
Type created.
SQL> grant execute on moving_point to master;
Grant succeeded.
SQL> conn master/master
Connected.
SQL> CREATE TABLE MPOINTS (
2 id NUMBER,
3 mpoint scott.Moving_Point)
4 NESTED TABLE mpoint.u_tab store as moving_tab;
Table created.Rgds. -
Want to update a column with different column of same table
I have a table TEST_CDR which is having 250 millions records also having partition by hash.
there are two column in this table ID and CDR_ID want to update ID in CDR_ID but it take too much time like 24 hours or more.
please suggest me a simple way.Hi,
You can try this. but be careful about your backups and go through CTAS,nologging and parallel concepts...
Please refer this link.
http://www.dba-oracle.com/t_fast_batch_updates_ctas.htm
http://www.dba-oracle.com/t_nologging_append.htm
http://www.dba-oracle.com/t_efficient_update_sql_dml_tips.htm
http://eriglen.blogspot.in/2011/08/ctas-create-table-as-select-with.html
1.CTAS with nologging and parallel..
SQL> create table test_cdr_1(id,cdr_id) nologging parallel as select id,id from test_cdr;
2.rebuild indexes, triggers and constraints to test_cdr_1
3.rename test_cdr to bkup_test_cdr;
4.rename test_cdr_1 to test_cdr;
Regards,
ragunath. -
ALV Table: DROPDOWN-Column with different valuesets per row
Hello,
I tried to create a dropdown by index cell in a table with different valuesets in each row. So I created an attribute VALUESET of type WDR_CONTEXT_ATTR_VALUE_LIST in my node to provide different valuesets per element. In my ALV-table I bound the property "valueset_fieldname" of the dropdown-cell to the context-attribute VALUESET:
lo_column = lo_alv_model>if_salv_wd_column_settings~get_column( id = 'PRICE').
CREATE OBJECT lo_drop_down_idx
EXPORTING
selected_key_fieldname = u2018PRICEu2019.
lo_drop_down_idx->set_valueset_fieldname( value = u2018VALUESETu2019 ).
lo_column->set_cell_editor( lo_drop_down_idx ).
Now I have the problem, that the list of the dropdown-cell displays the proper amount of values but not the proper texts . My valueset looks for example like this:
Value: A
Text: A
Value: B
Text: B
Value: C
Text: C
Value: D
Text: D
But my Dropdown-cell shows these values:
A
A
A
D
Could you please help?
Edited by: Developer on Feb 2, 2010 5:32 PMHello Lekha,
thank you for your answer. I think there might be an other reason for this problem. When I debug the view with the Webdynpro-Debugger the valueset in the context contains the correct values but the dropdown shows wrong values.
You also sent me a link with a codesample. In this coding you use the following statement:
lr_drp_idx->set_texts( 'VALUESET' ). This is a method of the class CL_WD_DROPDOWN_BY_IDX. I used the class cl_salv_wd_uie_dropdown_by_idx as I'm working with an ALV-Table. This class doesn't have the method set_texts. Instead it has a method called 'set_valueset_fieldname'. Maybe this method has a bug?
Regards, -
Matrix with Info Columns from different Table
Hi, how can i manage to have a column in a matrix that doesn't represent a value of the table the other columns are using?
For example, i have a matrix and this matrix has values of the UDT (@Table) and one column contains the projectcode. now i want one column in my matrix to show the project name of the OPRJ. how can i manage that, so that the value of this column in the matrix changes when i change the value of the other column with the project code?
best regards
PhilippHi
1) You can fill the matrix from Recordset.
For example: UDT is [@O01_USERTABLE].
PrjCode foreign key to the Projects table (OPRJ - not exposed through the DI API).
So, if you type correctly PrjCode, you can fetch description using method below.
Dim sSql As String = ""
sSql = " SELECT U.PrjCode AS PrjCode, S.PrjName As PrjName" & _
" FROM [@O01_USERTABLE] AS U, OPRJ AS S" & _
" WHERE U.PrjCode = S.PrjCode"
oRS = SBO_Company.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset)
oRS.DoQuery(sSql)
If oRS.RecordCount > 0 Then
Dim i As Integer = 0
oRS.MoveFirst()
While oRS.EoF = False
i = i + 1
oForm.DataSources.UserDataSources.Item("uNr").Value = i ' 1" matrix column for row number
oForm.DataSources.UserDataSources.Item("uPrjCode").Value = oRS.Fields.Item("PrjCode").Value
oForm.DataSources.UserDataSources.Item("uPrjName").Value = oRS.Fields.Item("PrjName").Value
oMatrix.AddRow()
oRS.MoveNext()
End While
End If
2) On ManageDataEvent, call Matrix_FetchDescriptions(...)
Public Sub ManageDataEvent(ByRef BusinessObjectInfo As SAPbouiCOM.BusinessObjectInfo, ByRef BubbleEvent As Boolean)
Dim oForm As SAPbouiCOM.Form = SBO_Application.Forms.Item(BusinessObjectInfo.FormUID)
If BusinessObjectInfo.EventType = SAPbouiCOM.BoEventTypes.et_FORM_DATA_LOAD Then
If Not BusinessObjectInfo.BeforeAction Then
Try
oForm.Freeze(True)
Dim oMatrix As SAPbouiCOM.Matrix
oMatrix = oForm.Items.Item("mtx00").Specific
If oMatrix.RowCount > 0 Then
Call Matrix_FetchDescriptions(oForm, -1)
End If
Catch ex As Exception
Finally
oForm.Freeze(False)
oForm.Update()
End Try
End If
End If
oForm = Nothing
End Sub
' Update column Name
Private Sub Matrix_FetchDescriptions(ByRef oForm As SAPbouiCOM.Form, ByVal iRow As Integer)
Dim oMatrix As SAPbouiCOM.Matrix
Dim oColumn As SAPbouiCOM.Column
Dim oCell As SAPbouiCOM.Cell
Dim oEdit As SAPbouiCOM.EditText
Try
If SBO_Company.Connect Then
oMatrix = oForm.Items.Item("mtx00").Specific
If oMatrix Is Nothing Then Throw New Exception("ERROR: matrix object is nothing")
Dim iNrRows As Integer = oMatrix.RowCount ' iRow
If iNrRows > 0 Then
Dim i As Integer = 1
For i = 1 To iNrRows
Dim sCode As String = ""
Dim sName As String = ""
Try
' Matrix column PrjCode
oColumn = oMatrix.Columns.Item("ePrjCode")
oCell = oColumn.Cells.Item(i)
oEdit = oCell.Specific
sCode = oEdit.Value
sName = GetNameByCode(sCode)
If Not sName.Equals("") Then
' Matrix column PrjName
oColumn = oMatrix.Columns.Item("ePrjName")
oCell = oColumn.Cells.Item(i)
oEdit = oCell.Specific
oEdit.Value = sName
End If
If iRow = i Then Exit Sub
Catch ex As Exception
Finally
End Try
Next
oForm.Refresh()
End If
End If
Catch ex As Exception
' log exception
Finally
oMatrix = Nothing
oColumn = Nothing
oCell = Nothing
oEdit = Nothing
System.GC.Collect() 'Release the handle to the table
End Try
End Sub
To get Name using Code...
Private Function GetNameByCode(ByVal sCode As String) As String
If sCode.Trim.Equals("") Then Return ""
Dim sName As String = ""
Dim oRS As SAPbobsCOM.Recordset
Try
oRS = SBO_Company.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset)
Dim sSql As String = "SELECT PrjName FROM OPRJ WHERE PrjCode = '" & sCode.Trim & "'"
oRS.DoQuery(sSql)
oRS.MoveFirst()
While oRS.EoF = False
sName = oRS.Fields.Item("PrjName").Value()
Exit While
End While
Catch ex As Exception
Finally
If Not oRS Is Nothing Then
System.Runtime.InteropServices.Marshal.ReleaseComObject(oRS)
oRS = Nothing
End If
End Try
Return sName
End Function
Note: Matrix_FetchDescriptions() have second argument (iRow As Integer) what may be used to indicate in what row you need to update PrjName column.
May be ItemManagment event when item pressed can be used... Try
HTH
BR
Sierdna S. -
2 SDO_GEOM columns with different coord systems
Hi
I have an intersection (traffic lights, etc.) that when shown on the map is a point and its position is stored as Lat/Long. However, when I zoom in on this intersection I need to be able to bring up a schematic (detailed plan) which will be in some cartesian coords.
My thought is to store the schematic data as a geometry collection in the same table as the rest of the data.
Is this possible?
And, are there any traps I should be looking for?You are free to mix geometries with different coordinate systems in a table, as long as all the geometries in a given column of the table have the same coordinate system. This should support what you are trying to do with expanded levels of detail in your point features.
-
Idoc mapping into E1IDB02 with different qualifiers
Hi,
I have to map a flat file to an Idoc (PEXR2002). Problem is in the flat file I have debitor and creditor informations wich have to be mapped into the same target segment named E1IDB02 with different qualifiers (BA for debitor and BB for creditor). Has anyone an idea how to do this?Hi,
Right click on this Segment E1IDB02 in the target nessage in the message mapping and say Duplicate Subtree.
Now, you can give each rule individually to this target element.
regards
Bhavesh
Maybe you are looking for
-
What format do I use to post on youtube so that IPhone and Androids can play it?
adobe premiere pro cs6: What format do I use to post on youtube so that IPhone and Androids can play it? how do I fix it so it will play I tryed h.264 youtube hd 720, h.264 andriod phone here is the youtube video play's fine on pc but will not play o
-
Uninstalling site studio properly
I did the uninstallation of site studio following the chapter 6 of site studio installaion guide. Every time I am doing installation back the old configuration is seen in the site studio which is corrupt. I am not able to see any fragments in the sit
-
Dynamic data not getting populated correctly
Hello Experts, I have a button on click of which, i m dynamically generating drop downs,In the same view i hav another button "CLOSE" on click of which i m navigating back to main view. Now the problem is ,when i select the se
-
My licenced photoshop cc turned into a trial version.
I am a licenced user of photoshop CC since Sep '13, for which I pay every month. Photoshop worked without problem until today. When I try to start photoshop, I get a message that it is only as trial version for which I have to register. What happened
-
Erreur de l'assistant labview sous un compte utilisateur standard
Bonjour, J'ai installé labview 7.1 sous windows XP sp1 et je fais bien fonctionner l'assitant de creation entrée sortie sous le compte admin, mais cela ne fonctionne pas sous un compte d'utilisateur standard. A savoir l'objet insere via l'assistant s