DAS is supporting data transfer between SDO and DB. In this, the
uniqueness of a
DataObject(DO) is ensured by having a PK in it. If this is not done,
it will not be possible to
get correct query results and also to do CUD on DB based on changes in
DO. Due to this
the DAS query mandates that the SELECT clause should include a PK. For
the same reason
support for SQL aggregate functions like count(), sum(), disctinct() etc. is not
completely implemented in DAS. In other words, a query like SELECT
COUNT(ID) is meant
for giving a sum and will not have a PK in it and so will not work well in DAS

Query like below will work - (verified in Derby)
    <Command name="countBook" SQL="select BOOK_ID, COUNT(*) from BOOK
GROUP BY BOOK_ID" kind="Select">
        <ResultDescriptor columnName="BOOK_ID" tableName="BOOK"
columnType="commonj.sdo.IntObject"/>
        <ResultDescriptor columnName="COUNT(*)" tableName="BOOK"
columnType="commonj.sdo.IntObject"/>
    </Command>

But this does not have any true meaning of count(*) as the result will
be something like -

<?xml version="1.0" encoding="ASCII"?>
<root:root xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
xmlns:das="http:///org.apache.tuscany.das.rdb/das";
    xmlns:root="root" xsi:type="das:DataGraphRoot">
  <BOOK>
    <BOOK_ID>1</BOOK_ID>
    <COUNT(*)>1</COUNT(*)>
  </BOOK>
  <BOOK>
    <BOOK_ID>2</BOOK_ID>
    <COUNT(*)>1</COUNT(*)>
  </BOOK>
</root:root>

So apart from MQ SQL Driver related issue, DAS is not supporting
aggregate functions as these can not
be tied to Table Row PK per ResultSet row.

Workaround will be get all records using "SELECT BOOK_ID FROM BOOK" as
DAS Command and then do aggregate
operations using Java API instead of native SQL function inside SQL Query.

If your requirement is far more complex than SELECT count(*), you can
try the stored procedure support
provided in DAS. e.g. check StoredProcs.testGetNamedCustomers() test
case to see how the count(*) is
returned through OUT param and the DataGraph of DOs is returned as return value.

Regards,
Amita

On Nov 7, 2007 4:50 AM, Jason Clark <[EMAIL PROTECTED]> wrote:
> As I've stated before, I'm not getting the metadata returned to me for a
> query. As such, I'm having to provide result descriptors, including an ID.
>
>
>
> I want to do the following
>
>
>
> <Command name="count" SQL="select COUNT(ID) from CONTACTS" kind="Select">
>
> </Command>
>
>
>
> Without metadata being returned, it's again asking me for result
> descriptors. But, if I just add
>
>
>
> <ResultDescriptor columnName="COUNT" tableName="CONTACTS"
> columnType="commonj.sdo.Int"/>
>
>
>
> I get told no ID. But, obviously, there can't be
>
>
>
> <ResultDescriptor columnName="ID" tableName="CONTACTS"
> columnType="commonj.sdo.Int"/>
>
>
>
> because that query returns a resultset with 1 column.
>
>
>
> Has anyone else had experience with SQL Server 2005 not returning MetaData?
> Their docs says they do and I have their latest drivers, but I'm getting
> very little for metadata.
>
>
>
> A simple test of the metadata results returns
>
>
>
> Column Table Name:
>
> Schema name:
>
> Column Type: 12
>
> Column Name: BUSINESS_CELL
>
>
>
> As you can see, I'm missing Table Name and Schema Name. I'm doing a simple
> Select query on this, so.
>
>
>
> I'm at a loss here.
>
>
>
> Any more ideas?
>
>
>
> -Jason Clark
>
>
>
>
>
>
>

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

Reply via email to