Getting data from several tables
HelloI started a few days working with Oracle TopLink, and since yesterday, I came across a problem that I can not find a solution, so I hope that someone will direct me in the right direction with this one... I'm using the tutorial provided by Oracle [http://www.oracle.com/technology/products/ias/toplink/doc/11110/tutorial/index.htm].
Assuming I want to get the most effective possible , the following data (* only * these data): first_name_of_employee, last_name_of_employee, number_of_phones_of_employee.
The Employee and phone tables are involved, table phone has an EMP_ID field that points to the field of the employee EMP_ID. How could I get such data for all employees? The first two pieces of data are pretty easy to get, but get one final turned out to be more difficult than I imagined...
Any help will be most appreciated.
Thank you
Vlad
You can probably use a ReportQuery and Expressions for this query. In TopLink you can do something you can do in JPQL using Expressions, like our support JPQL uses Expressions. To get the number of phones, you can use a count() on the id of the employee's phone with a groupBy to id of the employee. Get back the name and the name can be tricky depending on your database because I think that you can select return values that groupBy, you might try grouping by first and last name as well.
that is something like:
The ExpressionBuilder builder = new ExpressionBuilder();
Query ReportQuery = new ReportQuery (Builder, Employee.class);
query.addAttribute ("firstName");
query.addAttribute ("lastName");
query.addCount (builder.anyOf("phones").get ("id"));
query.addGrouping ("id");
query.addGrouping ("firstName");
query.addGrouping ("lastName");
---
James: http://www.eclipselink.org
Tags: Fusion Middleware
Similar Questions
-
Export data from several tables
Hello
I use the Data Export utility in SQL Developer 4.0.1. There is an option to choose a list of tables I want to understand, however in my case, I can get the list of tables by running a query against the USER_TABLES and applying some NOT LIKE filters. How to move this list to the export utility.
Is it possible to do so.
for example
SELECT table_name from user_tables WHERE NOT (table_name LIKE 'DOD%' OR table_name LIKE 'DAY%' OR table_name LIKE '%_HIST');
Whatever the result I get is a list of the tables, that I need to export.
Kind regards
Vikram R
You can not.
But you can add these tables to a cart (see view > Cart) and passing to the export utility.
-
Reading data from several tables on Apex
Hi all
My apologies if the below question has been answered already, just that I couldn't find the relevant discussion.
I have an interactive report I want to use to display data in 2 tables:
Table 1 about 10 columns but I want to just see 3 columns, Field1 and Field2 field3.
Table 2 has about 5 columns and I want only showing 2 of these columns (Column1 and Column2) on the same report with columns in table 1 above.
I need my report to look like this: field1, Field2 field3 Column1 Column2
FROM table1, table2
I tried the example above and it seems to not work, can I please get assistance on how to achieve this.
Thanks in advance.
Hello
Thanks for your reply, I actually found and answer the question.
I wanted to display the data in 2 tables (views) distinct have no joints, and so therefore I couldn't join them with a join condition.
What I did was created a dummy field on the two tables with similar values attached tables using these dummy fields and it works perfectly.
Thank you.
-
Remove data from several tables
I want to delete the data of all tables in this database which having device_id = "A1".
How to do it. 2 questions heres
(1) there are about 40 tables of the database and do not know what table contained the device_id field.
(2) we have several such deviced_id should be deleted, for example device_id = 'A1', or device _id = "A2", "A3". can sql read this info from a table and the process? Thank youLook at this example
SQL> create table t1 (device_id varchar2(2)); Table created. SQL> create table t3 (device_id varchar2(2)); Table created. SQL> insert into t1 values('A1'); 1 row created. SQL> insert into t1 values('A'); 1 row created. SQL> insert into t3 values('A1'); 1 row created. SQL> insert into t3 values('B'); 1 row created. SQL> commit; Commit complete. SQL> select * from t1; DE -- A1 A SQL> select * from t3; DE -- A1 B SQL> select table_name from all_tab_columns where column_name='DEVICE_ID'; TABLE_NAME ------------------------------ T1 T3 SQL> DECLARE 2 CURSOR my_cur 3 IS 4 SELECT table_name 5 FROM all_tab_columns 6 WHERE column_name = 'DEVICE_ID'; 7 BEGIN 8 FOR MY_REC IN MY_CUR LOOP 9 --DBMS_OUTPUT.PUT_LINE('delete from '||my_rec.table_name||' where device_id=''A1'''); 10 EXECUTE IMMEDIATE 'DELETE FROM '||my_rec.table_name||' WHERE device_id=''A1'''; 11 END LOOP; 12 13 END; 14 / PL/SQL procedure successfully completed. SQL> select * from t1; DE -- A SQL> select * from t3; DE -- B SQL>
- - - - - - - - - - - - - - - - - - - - -
Kamran Agayev a. (10g OCP)
http://kamranagayev.WordPress.com -
Hello
That was the question asked in an interview.
Given the scenario has been that I have two servers say s1 and s2, each containing a database with tables source1 and source2 respectively...
And I have a target table on server 2 with name target 1.
Cent were as
1 can data ufetch target1 source1 without creating table C $? If Yes, how can it be achieved.
2. how temporary will be created all to get ata in source1 and source2 to target1? Explain the same thing?
Also I would like to know what is the actual use of the c arrays $? Why they are used.
I would be very grateful for answers.
Thank you and best regards,
Mahesh
Hello
Look at these links.
http://odiexperts.com/why-creating-a-separate-schema-for-temporary-tables-in-ODI/
Also this
http://odiexperts.com/direct-load-by-interface-with-no-work-tables/
Concerning
-
Getting data from several XML files
Could someone please shed some light on the best way to read several external xml files through Flex? We haveabout 100 xml files (of which few are accessible by users).
I tried to implement the following generic function which takes a file name, but when debugging it, it seems that the Manager never gets call after executing the line of service.send ()! I would much appreciate your help!
public void fetchFileContent(fileName:String):void {//this method is called when you click on a button
var service: HTTPService = new HTTPService();
service. URL = "filePath /" + file name;
service.useProxy = false;
service.resultFormat = 'e4x ';
service.addEventListener ("result", fileRetrievalHandler)
service. Send();
}
public void fileRetrievalHandler(evnt:ResultEvent):void {}
fileContent = evnt.result.feed; This line is never executed
}
"miglara" wrote in message
News:glhase$5sr$1@forums. Macromedia.com...
> Could someone please shed some light on the best way to read more
> external xml files through Flex? We haveabout 100 xml files (of
> who
(> only little is accessed randomly by users).
> I tried to implement the following generic function which takes a
> filename
> but when debugging it, it seems that the Manager never gets call after
> executing the line of service.send ()! I would much appreciate your help!
>
> public void fetchFileContent(fileName:String):void {//this method is
> called by clicking on a button
> var service: HTTPService = new HTTPService();
> service.url = ' filePath / "+ file name;
> service.useProxy = false;
> service.resultFormat = 'e4x ';
> service.addEventListener ("result", fileRetrievalHandler)
> service.send ();
> }
>
> public void fileRetrievalHandler(evnt:ResultEvent):void {}
> fileContent = evnt.result.feed; This line is never executed
> }Try to add a fault handler and see if that goes off. Also, since you are
use HTTPService rather than URLLoader, you should know that this will probably not
already worked for your development environment, unless you have either changed the
Directory of output to go on the server or you have changed some compiler flags
to allow you to get local and access to the network at the same time. That's why
I always use URLLoader to load XML files to relative path... it just
works without my need to change anything. -
on average + get data from another table
Hello..
I have two tables:
user_table: contains (user_id, username)
rating_table: contains (rating_id, side, user_id)
I am trying to create a view of the note for users...
the notice must contain:
the id, user_name, the average of the coast
I created the following script:
Select a.user_id, b.username, AVG (a.rate_value)
rating_bookstore a, user_bookstore b
where a.user_id = b.user_id
A.user_id group;
but I got the following error message:
ORA-00979: not a GROUP BY expression
any help is appreciated...
Kind regards...10 x 2 wrote:
Hello..I have two tables:
user_table: contains (user_id, username)
rating_table: contains (rating_id, side, user_id)I am trying to create a view of the note for users...
the notice must contain:
the id, user_name, the average of the coastI created the following script:
Select a.user_id, b.username, AVG (a.rate_value)
rating_bookstore a, user_bookstore b
where a.user_id = b.user_id
A.user_id group;but I got the following error message:
ORA-00979: not a GROUP BY expressionany help is appreciated...
Kind regards...Select a.user_id, b.username, AVG (a.rate_value)
rating_bookstore a, user_bookstore b
where a.user_id = b.user_id
A.user_id group, b.username; -
Is it possible to see/get the data from the table to a dump file
I have files dmp generated using expdp on oracle 11 g...
expdp_schemas_18MAY2013_1.dmp
expdp_schemas_18MAY2013_2.dmp
expdp_schemas_18MAY2013_3.dmp
Can I use a settings file given below to get the data from the table in the file sql or impdp the only option to load the data of table in database.
VI test1.par
USERID = "/ as sysdba".
DIRECTORY = DATA
dumpfile=expdp_schemas_18MAY2013%S.dmp
SCHEMAS = USER1, USER2
LOGFILE = user_dump_data.log
SQLFILE = user_dump_data. SQL
and impdp parfile = test1.par.
No,
DataPump cannot retrieve a dumpfile data in a flat file.
Dean
-
How to get data from a database table and insert into a file
Hello
I'm new to soa, I want to create an xml with the data from database tables, I'll have the xsd please suggest me how to get the data in the tables and insert in a file
concerningin your bpel process, you can use the db adapter to communicate with the database.
with this type of adapter, you can use stored procedures, selects, etc to get the data from your database into your bpel workflow.When did it call in your bpel to the db adapter process it will return an output_variable with the contents of your table data, represented in a style of xml form.
After that, you can use the second card (a file synchronization adapter) to write to the content of this variable in output to the file system
-
How to get data from one or several times of perticuler dates
(1) how can we get data from one or more dates perticuler.
for example. date of 01/01/2011 and time is 00:00:00 to 23:59:59
and
(2) how can we get data from one or more dates perticuler.
from date 01/01/2011 to 01/02/2011 date and time e.g. is from 00:00:00 to 23:59:59.
can we?Hello
Use a WHERE clause to include only certain lines.
For example:SELECT * FROM table_x WHERE dt BETWEEN TO_DATE ( '01/01/2011 00:00:00' , 'DD/MM/YYYY HH24:MI:SS' ) AND TO_DATE ( '01/01/2011 23:59:59' , 'DD/MM/YYYY HH24:MI:SS' ) ;
In this example, the first date (before the keyword AND) and second (after the keyword AND) lie on the same calendar day. It's just a coincidence, they can be on different dates.
The first date must not be later than the date of the second; If this is the case, you will get 0 found lines.I hope that answers your question.
If not, post a small example of data (CREATE TABLE and only relevant columns, INSERT statements) for all tables and also post the results desired from these data.
Explain, using specific examples, how you get these results from these data.
Always tell what version of Oracle you are using. -
Getting data from tables msql and e-mailing the result
Here is some code that I'm eager to collect data from two tables msql and send by email to a user. (This is to remind the user of their user name and password in a weak security situation - that they have submitted their email address)
I glued some elements of other pages together, hoping it will do what I want.
At present, it fails with the message
"You have an error in your SQL syntax. Check the manual for your version of the MySQL server for the right syntax to use near Test "in line 1", after posting $org as requested (as a test)
I would be grateful if someone can debug this problem, or otherwise advise.
<? php require_once('.. /.. / Connections/tormented3.php');? >
<? PHP
now, the recordset to email a link to the training
$colname_rstSix = "1";
If (isset($_GET['email'])) {}
$colname_rstSix = (get_magic_quotes_gpc())? $_GET ['email']: addslashes($_GET['email']);
}
@mysql_select_db ($database_tormented3, $tormented3);
$query_rstSix = sprintf ("SELECT ck_organisation FROM chk_sixmonth WHERE ck_email = ' %s", $colname_rstSix);
$rstSix = mysql_query ($query_rstSix, $tormented3) or die (mysql_error ());
$row_rstSix = mysql_fetch_assoc ($rstSix);
$totalRows_rstSix = mysql_num_rows ($rstSix);
Recordset to the end
$org = $row_rstSix ["ck_organisation"];
echo $org; temporary test. Yes, it sends a correct text to monitornow recordset to the Organization link to access details
@mysql_select_db ($database_tormented3, $tormented3);
$query_rstPword = sprintf ("SELECT username, passwords password organization FROM WHERE = ' %s", $org);
$rstPword = mysql_query ($query_rstPword, $tormented3) or die (mysql_error ());
$row_rstPword = mysql_fetch_assoc ($rstPword);
$totalRows_rstPword = mysql_num_rows ($rstPword);Start with routine e-mail
$start = "your information to update access the website of the mental health of Torbay.
Your host username";// set up the e-mail header
$username = $row_rstSix ["username"];
$pword = $row_rstSix ["password"];
$message. = '$start $username. Your password is $pword\n please update your entries. « ;
If (mail ($email "Recall information Access",
$message, "in: . ((" [email protected] \r\n")) { }
header ('location:http://www.sample.org.uk "") ;// Redirect to the page if the email has been sent successfully
"exit";
} else {}
$error == ' < style p = "color: red;" > an error has occurred, your email could not be sent. Please try again < /p > ';
}? >
Thank you very much.
I assumed that your first successful query because SELECT... ck_organisation your $org echo printed what you expected.
Isn't the second query SELECT... Organization which is a failure? Have you tried the echo method or die in this query? Or is it the one that displays "the query is empty?
Try changing the following code snippet and we'll see what happens. I've added a couple more conditions where you can send them to the form. I added also oblique (') around the domain names in the second query, just in case any of those are reserved words in MySQL (I don't get them, but they are available in the MySQL online documentation).
mysql_select_db($database_tormented3, $tormented3); $query_rstSix = sprintf("SELECT ck_organisation FROM chk_sixmonth WHERE ck_email = '%s'", $colname_rstSix); $rstSix = mysql_query($query_rstSix, $tormented3) or die(mysql_error()); $totalRows_rstSix = mysql_num_rows($rstSix); if (!$totalRows_rstSix) { // no record exists with email $colname_rstSix // Alert user and let them try again. exit; } $row_rstSix = mysql_fetch_assoc($rstSix); //end recordset $org = $row_rstSix['ck_organisation']; echo $org; //temporary test. Yes, it does send correct text to monitor //now recordset to link organisation to access details // mysql_select_db($database_tormented3, $tormented3); // not needed. Still selected from above $query_rstPword = sprintf("SELECT `organisation`, `username`, `password` FROM `passwords` WHERE `organisation` = '%s'", $org); echo "$query_rstPword
"; $rstPword = mysql_query($query_rstPword, $tormented3) or die(mysql_error()); $totalRows_rstPword = mysql_num_rows($rstPword); if (!$totalRows_rstPword) { // no record in passwords with $org // Decide what you want to do in this situation. // exit; ??? } $row_rstPword = mysql_fetch_assoc($rstPword);--
Mark A. Boyd
Keep-on-Learnine :-) -
Hello. Is it possible to export data from a table in Oracle using SQL Loader? If Yes, can you tell a good examples?
Hello
Hello. Is it possible to export data from a table in Oracle using SQL Loader?
No, with SQL * Loader, you can load data from external files into tables not export.
coil c:\temp\empdata.txt
sqlplusabc.sql (assumes that abc.sql runs select * from emp)
spool offIt cannot work like this, because the declaration of the COIL is not recognized outside the SQL * Plus the term.
But, you can include the statement of the COIL in abc.sql like this:
spool c:\temp\empdata.txt select * from emp; spool off
Then, you just have to run the SQL script as follows:
sqlplus
@abc.sql However, I advise you to use Oracle SQL Developer, this is a free tool and with it you can export a Table in several types of format (html, xml, csv, xls,...).
Please find attached a link to this tool:
http://www.Oracle.com/technetwork/developer-tools/SQL-Developer/Overview/index.html
Hope this helps.
Best regards
Jean Valentine -
getting data from two servers?
Experts-
We have two servers for the storage of the tables. 1 history 1. current server Prod
We have same tables in the databases server.
All the info before one month from the date of the day are stored in database tables history server
and the rest in database tables current prod server.
I create reports such as when the user enters a date, OBIEE must check if the date is in a month (30 days) the date today or earlier at 30 days, on this basis, it must get data from historical Server database tables / running production database server.
How can I implement this?
I need to create two clusters of connction (RPD records) and develop the same model twice? (One for the historical paintings and one for prod tables?)
or can I use the technique of fragmentation? If so, can you give me an idea hwow to implement the Fragmentation of this requirement?
Thank you for your help in advanceYou must use the fragmentation of this requirement. It is not difficult once you understand the basic principle. Nico article read here for details:
http://gerardnico.com/wiki/dat/OBIEE/fragmentation_content
The only non-standard bit for you will be to define the criteria of fragmentation on your sources of logical table. This is the part that says BI server to hit source.
After return here if you get stuck.
Paul
-
How can I insert data from another table into a table containing a timestamp column
How you insert data from another table in a table if the target table contains a timestamp column. I tried to set the default value of GETDATE() column in the target table, but it does not work.
I use MS SQLSorry, I managed to get around this by inserting null as the value
-
data from 3 tables with later dates
Hello
Need help with the PL/SQL code, I need to write a code that will get the data from 3 tables with the most recent date.
For an individual ACT_CODE the output of the SQL query should display the data including the last dates back to 3 tables, if there is no
Date of the table, it should show the remaining data (think that the left join will do here)
Names of tables:
Institution_UPDT aiu
AC ASQ_CONTACT
GR_AUTHORIZE gr
All 3 tables have ACT_Code in common
Column names
INSTITUTION_UPDT IAU - IAU. ACT_CODE, AIU.project_id as proj, IAU. UPDT_TYPE_ID, IAU. User_id, IAU. UPDT_DATE
ASQ_CONTACT ac - ac. ACT_CODE as contact_code, ac.project_id, ac.first_name, ac.middle_initial, ac.last_
Name, AC.title, AC. Status, AC.status_date
GR_AUTHORIZE gr - GR ACT_CODE as grad_code, gr.name, gr.title AS grad_title, gr.submit_date
Are the names of the columns date
AC.status_date,
IAU. UPDT_DATE and
Gr.submit_date
Thanks to you all
appreciate your help
JeshHi, Ngoumba,
If a given ACT_Code couldn't miss from any of the tables, then you will use better full outer joins, not a join left outer.
Perhaps it would be more effective to make a UNION of the three tables, then rotate the results in three datecolumns.
You can use the GROUP BY aggregation to get the last date for each ACT_Code in each table.
If you need other columns in the row which is the last date, you can use the ROW_NUMBER analytic function, like this:SELECT ACT_Code , updt_date , ROW_NUMBER () OVER ( PARTITION BY ACT_Code ORDER BY updt_date DESC ) AS r_num FROM institution_updt
The lines with r_num = 1 are the most recent
This is a technique of ot the UNION-PIVOT example:
WITH union_data AS ( SELECT ACT_Code , MAX (updt_date) AS last_date , 1 AS table_id FROM institution_updt GROUP BY ACT_Code UNION ALL SELECT ACT_Code , MAX (status_date) AS last_date , 2 AS table_id FROM ASQ_Contact GROUP BY ACT_Code UNION ALL SELECT ACT_Code , MAX (submit_date) AS last_date , 3 AS table_id FROM GR_Authorize GROUP BY ACT_Code ) SELECT ACT_Code , MAX (CASE WHEN table_id = 1 THEN last_date END) AS aiu_updt_date , MAX (CASE WHEN table_id = 2 THEN last_date END) AS ac_status_date , MAX (CASE WHEN table_id = 3 THEN last_date END) AS gr_submit_date FROM union_data GROUP BY ACT_Code ORDER BY ACT_Code ;
Published by: Frank Kulash, on September 16, 2009 15:02
Added UNION-pivot example
Maybe you are looking for
-
How to mount EXT2 or EXT3 on a Mac external hard drive (10, 8 - 10.10)?
A unit DVR records TV programs on an external USB drive, as long as the disk is EXT2 or EXT3 format. No other format is acceptable. I want to view these files, which are about 1 GB each. How you get such format on a MacBookPro to view files? Trie
-
Firefox hangs and I don't know where to find "subject: breaks down.
In recent weeks, Firefox started to plant several times and quit unexpectedly - especially when I click to open it. I often get the annoying message "well, this is embarrassing." More useless. I sent the report of the accident and expect to hear from
-
Pavilion 17-g113dx: USB hub does not work on Pavilion 17-g113dx after intallation of win 7
Hi, I have a 17-g113dx Pavilion, which was originally to gain 10 on it, but I'm frustrated with it and installed win 7. After the driver installation failed for the USB hub. Is there a driver that is compatible with this machine and the operating s
-
9.1 Bluetooth iOS buzzing audio iPhone 6s
I discovered a bug in the iOS 9.1, tested on 2 iPhone 6 and one of 6 s. 1. connect your iPhone 6 or 6 s with a bluetooth device that has the ability to power off stop. This means that you can turn off the bluetooth device and the phone does not recog
-
iPod touch installs as an unknown device, gives 43 error code
ORIGINAL TITLE: Hi, need help! I have an ipod touch and recently my computer windows vista installs it as an unknown device. Then, the computer gives me code error 43 and USB\VID_0000 & PID_0000\5 & 2010C5D6 & 1 & 3 How to fix? He also says that my c