Location of database data in ADF framework
Hi,
I an new to ADF framework. I use JDeveloper 12.1.3.
Here what intrigees me. I understand that when I use read-onlu view object, my data (data I pulled from database) are stored in RowSet and I can access it via the Iterator.
But here is what I don't understand. When I use entity based view, and I pull some data from database, where are they stored? In Instance of EntityObject on which my View is based or somewhere else?
Many thx
Other way around - VO is always storing the current version of the row, with any changes. Or a new row that was added. Or will be missing a row that was deleted. EO is storing the data needed to make those changes, until a commit or rollback is issued.
Now, I'll betray my ignorance - I'm not sure if EO is storing the original row. If I'm not mistaken, a rollback forces a re-query, and THAT is how the VO is re-set with the most current data from the database. But I'm willing for someone to set me straight.
Similar Messages
-
ADF Framework Concepts - Architecture
Hi, I have the following doubts; I hope that somebody can help me.
First question, If I have only stored procedures that only have ansi sql such as: insert into table ..., delete from table, update from table... etc,
so Which would the problem in ADF Framework with Entity Objects if I work of this mode. What are the advantages of working with the insert, update and delete statement in the java class and not in an ansi sql since stored procedures?. And When Should I use business rules in the database?
Second question, I understand that my Entity Objects are my business objects, my View Objects are my data access layer (DAL), and my application module are my logic layer so,
Why Could I add validate methods or business rules in the Entity Object?, even as Best Tip, I have read in a manual of Oracle that i should add validate Method or business rules in the method of remove and create in the Entity Object and not in the View Object due to the fact that Entity Objects is who talks with the database.
So my question is, is it bad?, because I should have ALL logic of my use cases in my Business Rules and not in the Entity Object, I think that. Please could give me an observation about it?
Third question, Where should be my logic business in the Application Module?, and what kind of logic should be in the database.
Thank you very much if someone can answer1 me.
Regards,
Engineer Francisco Riccio
Email: [email protected]
LIMA-PERUAs Frank has suggested above, there is not a single best practice for where you put business logic, because the best practice depends on your goals.
If your goal is to enforce a set of rules in a way that get enforced for any client technology (SQL*Plus, Oracle Forms, Visual Basic, PowerBuilder, etc.) that might be accessing the database, then you really have no choice than to become a PL/SQL developer and implement the logic inside the database.
However, if your environment is controlled to the point that you know data updates can only be made through the business components in Java, then implementing the business rules in the middle tier gives you a single, central place to define and enforce them using the Java and declarative facilities ADF BC provides for that.
Again as Frank stated, the DML operations and where you choose to enforce the logic based on your goals are orthogonal issues.
Most customers use the default features of ADFBC that perform the INSERT, UPDATE, DELETE operations for you against the base tables, but the Dev Guide does document what's required to work with stored procedures when needs occasionally require that as well. -
Master table with two child tables in ADF Framework
Hi,
I'm trying to implement single master with two detail tables using oracle adf framework of Jdev 11.1.1.4.0. I'm able to do single master-detail by using view link but unable to achieve nested details block i.e., master with nested child blocks.
I created Query based view object of Master and two query based view objects as details. Then I created two view link for master with first child and another view link for master with second child. Even then in my data controls I see as two different components which is incorrect.
Please let me know how to create a data control for an example shown below:
Fruits [MASTER]
--- Details of Fruits as adf table
-- Apples [FIRST CHILD]
---- Details of Apples as adf table
-- Oranges [SECOND CHILD]
---- Details of Oranges as adf table
Regards,
Amar.You need two viewLinks
Fruits->Apples
Fruits->Oranges
Then in the data model you pick the Fruits entry that has:
Fruits
|--->Apples
You stand on Fruits and you shuttle the Oranges to be under it from the left.
If you'll use the default HR schema you'll see this type of relation for Employees:
https://blogs.oracle.com/shay/entry/master_with_two_details_on_the -
How to consume data model adf library in view project?
Hello,
I am using Jdev 11.1.1.6.
I have a Jdev workspace containing business component (entity objects, view objects and application module exposing the VOs). This workspace is deployed to an ADF Library. This library is packaged with DB connection details.
I have another Jdev workspace that needs to consume this Data Model ADF Library. This workspace is basically just the view layer (no business components at all).
I have added the Data Model ADF Library to it's view project and it is showing application module and VOs under Data Controls.
My question is : How is this view project going to connect to DB at runtime?
Can it use the connection from packaged Data Model ADF Libabry? If yes, how?
or Do I need to create a business project under this view workspace, just for connection purpose? if yes then what is the use of including connections during ADF Library creation?
Thanks,
JaiHi,
it will use the connection in the ADF library. I recommend though that you not save database connect information in the ADF library. Instead:
- define the ADF BC model to use JDBC data sources
- In the ADF library, configure it to only contain the data source name
- In the view project (the workspace) configure the database connection exposed by the library
When the library is imported, check Application Resources --> Connections and right click on the imported connection name to configure it
Frank -
Seeding multiple databases with single Entity Framework context
I am developing a single-instance, multi-tenant web application, with a SQL database using Entity Framework 6 Code-First.
I want to have a separate database for each client, generated from the same EF models, with a single DbContext. The database to connect to will be determined by the subdomain that the client is using the web app from.
This seems to work fine and the correct database is connected to depending on the subdomain. However my issue is seeding the databases with data. This is the code I have:
foreach (var connString in ConfigurationManager.ConnectionStrings.Cast<ConnectionStringSettings>()))
Configuration.PerformDatabaseMigration(connString.Name);
This then calls the PerformDatabaseMigration method:
public class Configuration : DbMigrationsConfiguration<DataContext>
public Configuration()
AutomaticMigrationsEnabled = false;
AutomaticMigrationDataLossAllowed = false;
public static void PerformDatabaseMigration(string connStringName)
var databaseInitialiser = new Configuration { TargetDatabase = new DbConnectionInfo(connStringName) };
var dbMigrator = new DbMigrator(databaseInitialiser);
dbMigrator.Update();
protected override void Seed(DataContext context)
base.Seed(context);
var superAdmin = new User { Id = 1, UserName = "SuperAdmin" };
context.Users.AddOrUpdate(superAdmin);
The issue is that when seeding this data for the second database, the context passed into the Seed method already has the admin user added to the `DbSet<User>` property of the context, even though the context is for the second databse connection, not
the first. It appears that the context is not being cleared from seeding the first database, and so I receive a `DbUpdateException`, as my User.Username field is a unique index.
Cannot insert duplicate key row in object 'dbo.Users' with unique index 'IX_UserName'. The duplicate key value is (SuperAdmin).\r\nThe statement has been terminated.
public class User : ModelBase, IUserIdentity, IPrincipal, IIdentity
[Index(IsUnique = true)]
[Required]
[StringLength(40)]
public string UserName { get; set; }Hello Attune,
>>This seems to work fine and the correct database is connected to depending on the subdomain. However my issue is seeding the databases with data.
Is that you firstly create these databases and then call the PerformDatabaseMigration method to seed these database with data? Do you have a try to seed these database data when creating the database with AutomaticMigrationsEnabled = true; with your provided
configuration class, I tested it and it could work as seeding same data to different database:
internal sealed class Configuration : DbMigrationsConfiguration<CFs.CFContext>
public Configuration()
AutomaticMigrationsEnabled = true;
public static void PerformDatabaseMigration(string connStringName)
var databaseInitialiser = new Configuration { TargetDatabase = new DbConnectionInfo(connStringName) };
var dbMigrator = new DbMigrator(databaseInitialiser);
dbMigrator.Update();
protected override void Seed(CFs.CFContext context)
base.Seed(context);
var superAdmin = new ApplicationUser() { ApplicationUserID = 1, FirstName = "", LastName = "" };
context.ApplicationUsers.AddOrUpdate(superAdmin);
Regards.
We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
Click
HERE to participate the survey. -
Custom exception problems with ADF framework
Hi,
I have problems with the exception handling in an web service Java class (POJO).
In this class I throw my own exception WsException-class which extends the normal Exception-class.
The class WebservicesAppModule extends the oracle.jbo.ApplicationModule.
In the following I first describe the web service class and then the three tests a)-c).
In test b) you can find my main problem.
Web service Java class (POJO):
public Element check(Element element) throws WsException{
WebservicesAppModule am = null;
try {
// 1) system error
// if I comment the next line out, then am = null and a NullPointerException is thrown which appear as NullPointerException in the SOAP response
am = (WebservicesAppModule)Configuration.createRootApplicationModule(_am,_cf);
if(value == null){
// 2) application error
WsException wsex = new WsException();
wsex.addErrorCode(WsException.C_INVALID_BANK_CONNECTION);
throw wsex;
} else if (value2 == null){
// 3) explicit system error
throw new NullPointerException();
}catch(WsException wsex){
// 4) application error
throw wsex;
}catch(Throwable ex){
// 5) system error
log.debug("Technischer Fehler", ex);
WsException wsex = new WsException("system error");
wsex.addErrorCode(WsException.C_NOK);
throw wsex;
} finally {
if (_am != null) {
Configuration.releaseRootApplicationModule(am, false);
Test a):
- The WebservicesAppModule is initialized (1)
- value = null, so the process run in the "application error" if-block (2)
- The WsException is thrown and catched in the "application error" catch-block (4)
The SOAP repsonse is okay:
--- Response ---
HTTP/1.1 100 Continue
Server: Oracle Application Server Containers for J2EE 10g (10.1.2.0.2)
Date: Thu, 20 Jul 2006 09:43:39 GMT
HTTP/1.1 500 Internal Server Error
Date: Thu, 20 Jul 2006 09:43:55 GMT
Server: Oracle Application Server Containers for J2EE 10g (10.1.2.0.2)
Content-Length: 520
Connection: Close
Content-Type: text/xml; charset=utf-8
<?xml version = '1.0' encoding = 'UTF-8'?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<SOAP-ENV:Body>
<SOAP-ENV:Fault>
<faultcode>SOAP-ENV:Server.Exception:</faultcode>
<faultstring>[11000, 10001] [de.test.webservices.WsException]</faultstring>
<faultactor>/app-Webservices-context-root/WebServices</faultactor>
</SOAP-ENV:Fault>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
Test b):
- The WebservicesAppModule is NOT initialized (the line is comment out) (1)
- The process run in system error catch-block (5)
In the SOAP repsonse I expected the following <faultstring> (like in test c) )
<faultstring>system error: [10000] [de.test.webservices.WsException]</faultstring>
and not
<faultstring> [java.lang.NullPointerException]</faultstring>
What´s the problem?
--- Response ---
HTTP/1.1 100 Continue
Server: Oracle Application Server Containers for J2EE 10g (10.1.2.0.2)
Date: Thu, 20 Jul 2006 08:59:12 GMT
HTTP/1.1 500 Internal Server Error
Date: Thu, 20 Jul 2006 09:01:02 GMT
Server: Oracle Application Server Containers for J2EE 10g (10.1.2.0.2)
Content-Length: 506
Connection: Close
Content-Type: text/xml; charset=utf-8
<?xml version = '1.0' encoding = 'UTF-8'?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<SOAP-ENV:Body>
<SOAP-ENV:Fault>
<faultcode>SOAP-ENV:Server.Exception:</faultcode>
<faultstring> [java.lang.NullPointerException]</faultstring>
<faultactor>/app-Webservices-context-root/WebServices</faultactor>
</SOAP-ENV:Fault>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
Test c):
- The WebservicesAppModule is initialized (1)
- value != null, so the process run to the next if-block (2)
- value2 == null, so the process run in the "explicit system error" (3)
- The WsException is thrown and catched in the "system error" catch-block (5)
This test shows that not the NullPointerException of Test b) is the problem.
This response is expected in Test b).
--- Response ---
HTTP/1.1 100 Continue
Server: Oracle Application Server Containers for J2EE 10g (10.1.2.0.2)
Date: Thu, 20 Jul 2006 13:53:46 GMT
HTTP/1.1 500 Internal Server Error
Date: Thu, 20 Jul 2006 13:54:19 GMT
Server: Oracle Application Server Containers for J2EE 10g (10.1.2.0.2)
Content-Length: 533
Connection: Close
Content-Type: text/xml; charset=utf-8
<?xml version = '1.0' encoding = 'UTF-8'?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<SOAP-ENV:Body>
<SOAP-ENV:Fault>
<faultcode>SOAP-ENV:Server.Exception:</faultcode>
<faultstring>system error: [10000] [de.test.webservices.WsException]</faultstring>
<faultactor>/app-Webservices-context-root/WebServices</faultactor>
</SOAP-ENV:Fault>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
What is the cause for the false <faultstring> in test b)? Where set the the ADF framework the NullPointerException and how can I avoid that?
Thanks and best regards,
TobiasHi,
I have problems with the exception handling in an web service Java class (POJO).
In this class I throw my own exception WsException-class which extends the normal Exception-class.
The class WebservicesAppModule extends the oracle.jbo.ApplicationModule.
In the following I first describe the web service class and then the three tests a)-c).
In test b) you can find my main problem.
Web service Java class (POJO):
public Element check(Element element) throws WsException{
WebservicesAppModule am = null;
try {
// 1) system error
// if I comment the next line out, then am = null and a NullPointerException is thrown which appear as NullPointerException in the SOAP response
am = (WebservicesAppModule)Configuration.createRootApplicationModule(_am,_cf);
if(value == null){
// 2) application error
WsException wsex = new WsException();
wsex.addErrorCode(WsException.C_INVALID_BANK_CONNECTION);
throw wsex;
} else if (value2 == null){
// 3) explicit system error
throw new NullPointerException();
}catch(WsException wsex){
// 4) application error
throw wsex;
}catch(Throwable ex){
// 5) system error
log.debug("Technischer Fehler", ex);
WsException wsex = new WsException("system error");
wsex.addErrorCode(WsException.C_NOK);
throw wsex;
} finally {
if (_am != null) {
Configuration.releaseRootApplicationModule(am, false);
Test a):
- The WebservicesAppModule is initialized (1)
- value = null, so the process run in the "application error" if-block (2)
- The WsException is thrown and catched in the "application error" catch-block (4)
The SOAP repsonse is okay:
--- Response ---
HTTP/1.1 100 Continue
Server: Oracle Application Server Containers for J2EE 10g (10.1.2.0.2)
Date: Thu, 20 Jul 2006 09:43:39 GMT
HTTP/1.1 500 Internal Server Error
Date: Thu, 20 Jul 2006 09:43:55 GMT
Server: Oracle Application Server Containers for J2EE 10g (10.1.2.0.2)
Content-Length: 520
Connection: Close
Content-Type: text/xml; charset=utf-8
<?xml version = '1.0' encoding = 'UTF-8'?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<SOAP-ENV:Body>
<SOAP-ENV:Fault>
<faultcode>SOAP-ENV:Server.Exception:</faultcode>
<faultstring>[11000, 10001] [de.test.webservices.WsException]</faultstring>
<faultactor>/app-Webservices-context-root/WebServices</faultactor>
</SOAP-ENV:Fault>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
Test b):
- The WebservicesAppModule is NOT initialized (the line is comment out) (1)
- The process run in system error catch-block (5)
In the SOAP repsonse I expected the following <faultstring> (like in test c) )
<faultstring>system error: [10000] [de.test.webservices.WsException]</faultstring>
and not
<faultstring> [java.lang.NullPointerException]</faultstring>
What´s the problem?
--- Response ---
HTTP/1.1 100 Continue
Server: Oracle Application Server Containers for J2EE 10g (10.1.2.0.2)
Date: Thu, 20 Jul 2006 08:59:12 GMT
HTTP/1.1 500 Internal Server Error
Date: Thu, 20 Jul 2006 09:01:02 GMT
Server: Oracle Application Server Containers for J2EE 10g (10.1.2.0.2)
Content-Length: 506
Connection: Close
Content-Type: text/xml; charset=utf-8
<?xml version = '1.0' encoding = 'UTF-8'?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<SOAP-ENV:Body>
<SOAP-ENV:Fault>
<faultcode>SOAP-ENV:Server.Exception:</faultcode>
<faultstring> [java.lang.NullPointerException]</faultstring>
<faultactor>/app-Webservices-context-root/WebServices</faultactor>
</SOAP-ENV:Fault>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
Test c):
- The WebservicesAppModule is initialized (1)
- value != null, so the process run to the next if-block (2)
- value2 == null, so the process run in the "explicit system error" (3)
- The WsException is thrown and catched in the "system error" catch-block (5)
This test shows that not the NullPointerException of Test b) is the problem.
This response is expected in Test b).
--- Response ---
HTTP/1.1 100 Continue
Server: Oracle Application Server Containers for J2EE 10g (10.1.2.0.2)
Date: Thu, 20 Jul 2006 13:53:46 GMT
HTTP/1.1 500 Internal Server Error
Date: Thu, 20 Jul 2006 13:54:19 GMT
Server: Oracle Application Server Containers for J2EE 10g (10.1.2.0.2)
Content-Length: 533
Connection: Close
Content-Type: text/xml; charset=utf-8
<?xml version = '1.0' encoding = 'UTF-8'?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<SOAP-ENV:Body>
<SOAP-ENV:Fault>
<faultcode>SOAP-ENV:Server.Exception:</faultcode>
<faultstring>system error: [10000] [de.test.webservices.WsException]</faultstring>
<faultactor>/app-Webservices-context-root/WebServices</faultactor>
</SOAP-ENV:Fault>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
What is the cause for the false <faultstring> in test b)? Where set the the ADF framework the NullPointerException and how can I avoid that?
Thanks and best regards,
Tobias -
About customer form(extends ActionForm) in ADF framework
1. In addition DataForm outside, ADF framework whether or not define form(extends ActionForm)?
2. If possible, used the form(extends ActionForm) in jsp page.Why set these data to the view and then these data can not be inserted after application model commit without any exception?The answer will depend on how you are storing the parameter in your ADF application and when do you actually need it to be set and based on what.
This can be for example a property of a managed bean in your JSF application and you can initialize it either in the bean itself or in the faces-config.xml file as a managed property.
http://www.oracle.com/technology/tech/java/newsletter/articles/jsf_pojo/index.html -
Does location services use data
I was wondering whether Location Services uses data and if so how much?
No, it uses the location of the nearest wi-fi router as determined by Apple's database, which is usually, but not always, up-to-date.
-
Dynamically updating data in ADF
Hi,
I am currently developing an adf application where I need to show some dynamic value to the user based on the user login in application.
Now I am getting this user specific value by using API calls and feeding the view table of ADF, which in turns creates the row dynamically and display the result to the user.
The issue is that since I am feeding the data in View table of ADF dynamically, if a different user log in to the application then at that time the API calls will fetch that user specific details and will delete the existing data from the table and will insert the new values.
So the value which was displayed to the 1st user will not be available for use.
Please help me in solving this issue.
I am using Jdeveloper 11.1.1.5Hi TImo,
Thanks for the reply and suggestion. I will try the suggestion given by you and will let you know if face any issue.
Also please let me know if is there any way to dynamically displaying the data in ADF instead of inserting it first in table.
Thanks much !!! -
How can I populate a pdf with database data?
How can I populate a pdf that we have on our server with database data on our server?
Actually, if you export it in the right format then you won't need a script
at all.
You can import data directly into fields from a plain-text file via Tools -
Forms - More Form Options - Import Data...
I believe the format is tab-delimited with the field names in the first row
and their values in the second. -
Using a second table in a Database Data Block ??
In a Form, I have a Data Block which is a Database Data Block. The Items are associated with columns in a table.
I want the items in this repeating block to show in a different order. To do this, I need to use a second table and say where table1.key = table2.key ....
I keep getting problems at runtime with
ORA-00918: column ambiguously defined
I tried to qualify everywhere a column name is used. When I do show error it shows
SELECT ROWID, ....
And then the "column ambiguously defined".
I do not have an item in my Form for ROWID. Maybe it is automatic. (This form DOES do update).
Is it possible to use two tables in a Data Block like this?
ThanksIf you only need to order the records in the block, why not defining the "ORDER BY" clause in the block's property??
Set the "ORDER BY" clause at design time from the property palette of the block or runtime with column of your choice.
at runtime your can use:
SET_BLOCK_PROPERTY('your_block', ORDER_BY, 'your_column');If you need to join to tables in one block read the [Block Based on Join|http://www.oracle.com/technology/products/forms/pdf/BlockOnAJoin.pdf] Documentation.
Tony -
Direct database data access without data level authorization check
Hello,
My customer raised issue about direct database data access. Due to the customeru2019s strong security policy, it shouldnu2019t be allowed.
To prevent this kind of illegal data access, customer ask me to list up all the possibilities to display data without data level authorization check.
The things in my mind are
SQL Command Editor (for Oracle based system) : ORASPACE, DB02, ST04
Query Based : SQVI (Quick Viewer), SQ01/SQ02/SQ03 (SAP Query)
Data Browser : SE11, SE12, SE16, SE16N, SE17
Table Maintenance : SM30
Function Module : RFC_READ_TABLE
Function Module : DB_EXECUTE_SQL (DML)
Anyone knows anything which is not listed above?
ThanksHI,
Generally in production user's should not be given all these authorizations.
Ram. -
How can i query oracle database data to xml file with c++?
I want query data to xml file directly in my c++ application .
I know the oracle XSU provide interferce for query data to xml
file directly.
But XSU for oracle8i does not support c++.
I do not know if XSU for oracle9i support c++.
can you tell me?
If i do not use XSU to finish my applicayion.
what interface that oracle provide can help me do my work?
thank you !BTW why do you want to migrate oracle database data to db2 database? Any specific project requirement like Parallel run with Oracle database (e.g data replication)? Or any other issues - Cost? Manageability? Availability? Business requirements?
Do you need to do a day-to-day data transfer or it is for permanent migration? -
Database data to nested xml structure
Hi All,
I need to convert the data in the oracle database to nested xml tree structure as below:
Data in the database is in the following structure:
1 branch1 13-JAN-11 a.txt
1 branch1 25-JAN-11 b.txt
1 branch1 25-JAN-11 c.txt
1 branch2 20-JAN-11 d.txt
2
XML for the above data should be in the format:
<Root>
<Account_no value="1">
<Desc value="branch1">
<Date value="13-JAN-11">
<Name value="a.txt"/>
</Date>
<Date value="25-JAN-11">
<Name value="b.txt"/>
<Name value="c.txt"/>
</Date>
</Desc>
<Desc value="branch2">
<Date value="20-JAN-11">
<Name value="d.txt"/>
</Date>
</Desc>
</Account_no>
<Account_no value="2">
</Account_no>
</Root>
I am able to get this kind of xml structure using java after storing the database data in a n-ary tree. But it takes more time to execute.
Can this kind of same xml format be achieved using pl/sql programming?
Please help me with your valuable insights.
Thanks,
AlagappanHi,
Please always mention your db version (select * from v$version).
Here's one solution using SQL/XML functions :
Sample data used :
create table sample_data
account_no number,
description varchar2(30),
dt date,
name varchar2(30)
insert into sample_data values(1, 'branch1', to_date('13-JAN-11','DD-MON-RR'), 'a.txt');
insert into sample_data values(1, 'branch1', to_date('25-JAN-11','DD-MON-RR'), 'b.txt');
insert into sample_data values(1, 'branch1', to_date('25-JAN-11','DD-MON-RR'), 'c.txt');
insert into sample_data values(1, 'branch2', to_date('20-JAN-11','DD-MON-RR'), 'd.txt');
insert into sample_data values(2, 'branch3', to_date('20-JAN-11','DD-MON-RR'), 'e.txt');Query :
SELECT xmlserialize(document
xmlelement("Root",
xmlagg(
xmlelement("Account_no", xmlattributes(account_no as "value"),
xmlagg(
xmlelement("Desc", xmlattributes(description as "value"), dt)
order by description
) order by account_no
as clob indent ) doc
FROM (
SELECT account_no, description,
xmlagg(
xmlelement("Date", xmlattributes(to_char(dt,'DD-MON-RR') as "value"), name)
order by dt
) dt
FROM (
SELECT account_no, description, dt,
xmlagg(
xmlelement("Name", xmlattributes(name as "value"))
order by name
) name
FROM sample_data
GROUP BY account_no, description, dt
GROUP BY account_no, description
GROUP BY account_no
DOC
<Root>
<Account_no value="1">
<Desc value="branch1">
<Date value="13-JAN-11">
<Name value="a.txt"/>
</Date>
<Date value="25-JAN-11">
<Name value="b.txt"/>
<Name value="c.txt"/>
</Date>
</Desc>
<Desc value="branch2">
<Date value="20-JAN-11">
<Name value="d.txt"/>
</Date>
</Desc>
</Account_no>
<Account_no value="2">
<Desc value="branch3">
<Date value="20-JAN-11">
<Name value="e.txt"/>
</Date>
</Desc>
</Account_no>
</Root>
Here, I used XMLSerialize function with indent option to format the output (available starting with 11g). -
How can i migrate oracle database data to DB2 database
Hi
how can i migrate oracle database data to db2 database.
can anyone provide me solution.BTW why do you want to migrate oracle database data to db2 database? Any specific project requirement like Parallel run with Oracle database (e.g data replication)? Or any other issues - Cost? Manageability? Availability? Business requirements?
Do you need to do a day-to-day data transfer or it is for permanent migration?
Maybe you are looking for
-
Column in select change changes results
I am seeing quite strange behavior in one of my databases. I am running a fairly large query. when i put one particular column in the select it returns no data. select * returns the correct rows (with this column populated) as does selecting other fi
-
ChiliBean Control error '800a03e8' java.lang.NoClassDefFoundError
hi all, http://forum.java.sun.com/thread.jspa?forumID=759&threadID=5019680 in reference to the post above, i have a Win2003 server running Sun ONE with Chilisoft ASP plug-in. i did the suggestions there but am still getting the same error, to be exac
-
Linker error «error: undefined reference to '__ZN7problemC1Ev'»
Here's some code I have been trying to compile all day and having gotten a cryptic linker error that I can't figure out. First here is my Makefile: T09: check @echo "-------- problem --------" "$(FLASCC)/usr/bin/g++" $(BASE_CFLAGS) main.cpp -swf-
-
Creative_cloud_offline
Can AdobeCC apps be used offline?
-
My old iphone was replaced today, due to faults. Now it will not allow me to use my credit card account for the appstore and itunes? Please don't tell me to retry, or re check my information because it is all correct, it basically says u cannot use t