Tag: cws_src680_qiq
User: fs      
Date: 2006/06/29 03:17:43

Modified:
   dba/dbaccess/qa/complex/dbaccess/CRMDatabase.java

Log:
 extended the scenario

File Changes:

Directory: /dba/dbaccess/qa/complex/dbaccess/
=============================================

File [changed]: CRMDatabase.java
Url: 
http://dba.openoffice.org/source/browse/dba/dbaccess/qa/complex/dbaccess/CRMDatabase.java?r1=1.1.2.2&r2=1.1.2.3
Delta lines:  +49 -4
--------------------
--- CRMDatabase.java    27 Jun 2006 08:06:03 -0000      1.1.2.2
+++ CRMDatabase.java    29 Jun 2006 10:17:40 -0000      1.1.2.3
@@ -4,9 +4,9 @@
  *
  *  $RCSfile: CRMDatabase.java,v $
  *
- *  $Revision: 1.1.2.2 $
+ *  $Revision: 1.1.2.3 $
  *
- *  last change: $Author: fs $ $Date: 2006/06/27 08:06:03 $
+ *  last change: $Author: fs $ $Date: 2006/06/29 10:17:40 $
  *
  *  The Contents of this file are made available subject to
  *  the terms of GNU Lesser General Public License Version 2.1.
@@ -34,6 +34,8 @@
  ************************************************************************/
 package complex.dbaccess;
 
+import com.sun.star.container.ElementExistException;
+import com.sun.star.lang.WrappedTargetException;
 import com.sun.star.lang.XMultiServiceFactory;
 import com.sun.star.sdbc.SQLException;
 import com.sun.star.sdbc.XConnection;
@@ -66,6 +68,7 @@
         m_dataSource = m_database.getDataSource();
         m_connection = m_database.defaultConnection();
         createTables();
+        createQueries();
     }
 
     // 
--------------------------------------------------------------------------------------------------------
@@ -95,7 +98,7 @@
     {
         HsqlTableDescriptor table = new HsqlTableDescriptor( "products",
             new HsqlColumnDescriptor[] {
-                new HsqlColumnDescriptor( "ID", "INTEGER", true, true ),
+                new HsqlColumnDescriptor( "ID", "INTEGER", 
HsqlColumnDescriptor.PRIMARY ),
                 new HsqlColumnDescriptor( "Name", "VARCHAR(50)" ) } );
         m_database.createTable( table, true );
 
@@ -105,7 +108,7 @@
 
         table = new HsqlTableDescriptor( "customers",
             new HsqlColumnDescriptor[] {
-                new HsqlColumnDescriptor( "ID", "INTEGER", true, true ),
+                new HsqlColumnDescriptor( "ID", "INTEGER", 
HsqlColumnDescriptor.PRIMARY ),
                 new HsqlColumnDescriptor( "Name", "VARCHAR(50)" ),
                 new HsqlColumnDescriptor( "Address", "VARCHAR(50)" ),
                 new HsqlColumnDescriptor( "City", "VARCHAR(50)" ),
@@ -116,6 +119,21 @@
         m_database.executeSQL( "INSERT INTO \"customers\" VALUES(2,'Simply 
Delicious','Down Under','Melbourne','518') " );
         m_database.executeSQL( "INSERT INTO \"customers\" VALUES(3,'Pure 
Health','10 Fish St.','San Francisco','94107') " );
 
+        table = new HsqlTableDescriptor( "orders",
+            new HsqlColumnDescriptor[] {
+                new HsqlColumnDescriptor( "ID", "INTEGER", 
HsqlColumnDescriptor.PRIMARY ),
+                new HsqlColumnDescriptor( "CustomerID", "INTEGER", 
HsqlColumnDescriptor.REQUIRED, "customers", "ID"  ),
+                new HsqlColumnDescriptor( "OrderDate", "DATE" ),
+                new HsqlColumnDescriptor( "ShipDate", "DATE" ) } );
+        m_database.createTable( table, true );
+
+        table = new HsqlTableDescriptor( "orders_details",
+            new HsqlColumnDescriptor[] {
+                new HsqlColumnDescriptor( "OrderID", "INTEGER", 
HsqlColumnDescriptor.PRIMARY, "orders", "ID" ),
+                new HsqlColumnDescriptor( "ProductID", "INTEGER", 
HsqlColumnDescriptor.PRIMARY, "products", "ID"  ),
+                new HsqlColumnDescriptor( "Quantity", "INTEGER" ) } );
+        m_database.createTable( table, true );
+
         // since we created the tables by directly executing the SQL 
statements, we need to refresh
         // the tables container
         XTablesSupplier suppTables = 
(XTablesSupplier)UnoRuntime.queryInterface(
@@ -123,5 +141,32 @@
         XRefreshable refreshTables = (XRefreshable)UnoRuntime.queryInterface(
             XRefreshable.class, suppTables.getTables() );
         refreshTables.refresh();
+    }
+
+    private void createQueries() throws ElementExistException, 
WrappedTargetException, com.sun.star.lang.IllegalArgumentException
+    {
+        m_database.getDataSource().createQuery(
+            "all orders",
+            "SELECT \"Orders\".\"ID\" AS \"Order No.\", " +
+                    "\"Customers\".\"Name\" AS \"Customer Name\", " +
+                    "\"Orders\".\"OrderDate\", " +
+                    "\"Orders\".\"ShipDate\", " +
+                    "\"OrderDetails\".\"Quantity\", " +
+                    "\"Products\".\"Name\" AS \"Product Name\" " +
+            "FROM \"OrderDetails\" AS \"OrderDetails\", " +
+                  "\"Orders\" AS \"Orders\", " +
+                  "\"Products\" AS \"Products\", " +
+                  "\"Customers\" AS \"Customers\" " +
+            "WHERE  ( \"OrderDetails\".\"OrderID\" = \"Orders\".\"ID\" " +
+                 "AND \"OrderDetails\".\"ProductID\" = \"Products\".\"ID\" " +
+                 "AND \"Orders\".\"CustomerID\" = \"Customers\".\"ID\" )"
+        );
+
+        m_database.getDataSource().createQuery(
+            "unshipped orders",
+            "SELECT * " +
+            "FROM \"all orders\"" +
+            "WHERE ( \"ShipDate\" IS NULL"
+        );
     }
 }




---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to