thank you Lukas,
yeah tab1 & hlmTempTable are same.
Let me try this way and will update you the results.
~Shyam
On Friday, January 31, 2014 12:53:11 PM UTC+5:30, Lukas Eder wrote:
>
> So, the new "tab1" is what before you called "hlmTempTable".
>
> Unfortunately, there is no way for an internal DSL like jOOQ to introspect
> a derived table's columns in a way for the compiler to *know* that there is
> an HC1_LEAF_ID Field in tab1. jOOQ will allow you to dereference the column
> through Table.field(), e.g.:
>
> Field<Integer> HC1_LEAF_ID = tab1.field(cd.HC1_LEAF_ID).as("HC1_LEAF_ID");
>
> // Dereference a field ---------> ^^^^^^^^^^^^^^^^^^^^^
>
>
> 2014-01-31 Sha <[email protected] <javascript:>>:
>
>> Yes ofcourse I did.
>> *I assigned to a local variable like below as an example*.
>>
>> Table<Record4<Integer, Integer, Integer, Short>> tab1 =
>> ctx.select(cd.HC1_LEAF_ID,cd.HC2_LEAF_ID,cd.HC3_LEAF_ID,cd.PLANE_ID).from(cd).where(cd.IS_PHANTOM.equal((byte)
>>
>> 1))
>> .asTable().as("tab1");
>> Field<Integer> HC1_LEAF_ID = tab1*.HC1_LEAF_ID.*as("HC1_LEAF_ID");
>>
>> *Error :*
>> HC1_LEAF_ID cannot be resolved or is not a field
>>
>> Am not doing correctly ? or anything wrong with my understanding ?
>>
>>
>> Thank you.
>> ~Shyam
>>
>> On Thursday, January 30, 2014 1:03:20 PM UTC+5:30, Lukas Eder wrote:
>>
>>> Shyam, I'm not sure "how to assign it", that was just an "educated
>>> guess", given the information I have. You have only shown small code
>>> snippets so far. Can you please show the full program necessary to
>>> reproduce that particular compilation error?
>>>
>>>
>>> 2014-01-30 Sha <[email protected]>:
>>>
>>> Not assigned. I did exactly same as in the manual.
>>>>
>>>> how to assign it?
>>>>
>>>> Thank you.
>>>> ~Shyam
>>>>
>>>>
>>>> On Wednesday, January 29, 2014 7:28:18 PM UTC+5:30, Lukas Eder wrote:
>>>>
>>>>> Shyam, did you assign the "hlmTempTable" to a local variable (in
>>>>> Java)? Or how else would the Java compiler know what you mean when you
>>>>> write hlmTempTable?
>>>>>
>>>>>
>>>>> 2014-01-29 Sha <[email protected]>
>>>>>
>>>>> Thank you.
>>>>>>
>>>>>> But in below way
>>>>>> ctx.select(hl.ITEM_ID,hl.HA_ID,(hl.PERIOD_ID).max())
>>>>>> .from(hl).groupBy(hl.ITEM_ID,hl.HA_ID).asTable(*"hlmTempTable"*,
>>>>>> "ITEM_ID","HA_ID","PERIOD_ID");
>>>>>>
>>>>>> When I say in memory table name as *hlmTempTable *gives error as
>>>>>> below
>>>>>> "*hlmTempTable cannot be resolved to a variable*"
>>>>>>
>>>>>> So getting compilation error.
>>>>>>
>>>>>> How to use it correctly ?
>>>>>>
>>>>>> thank you.
>>>>>> ~Shyam
>>>>>>
>>>>>>
>>>>>> On Wednesday, January 29, 2014 2:55:00 PM UTC+5:30, Lukas Eder wrote:
>>>>>>
>>>>>>> Your usage of asTable() is correct. In order to extract fields from
>>>>>>> an "untyped" table (e.g. a derived table), use any of these methods:
>>>>>>>
>>>>>>> - http://www.jooq.org/javadoc/3.2.x/org/jooq/TableLike.html#
>>>>>>> field(org.jooq.Field)
>>>>>>> - http://www.jooq.org/javadoc/3.2.x/org/jooq/TableLike.html#
>>>>>>> field(int)
>>>>>>> - http://www.jooq.org/javadoc/3.2.x/org/jooq/TableLike.html#
>>>>>>> field(java.lang.String)
>>>>>>>
>>>>>>> Note that access by Field (the first variant) is using the argument
>>>>>>> Field's qualified and / or unqualified name to extract a typed field
>>>>>>> from
>>>>>>> the Table type.
>>>>>>>
>>>>>>> Hope this helps
>>>>>>> Lukas
>>>>>>>
>>>>>>>
>>>>>>> 2014-01-29 Sha <[email protected]>
>>>>>>>
>>>>>>>> Hi Lukas,
>>>>>>>> I have very difficult time using Result list of query as
>>>>>>>> temporary table.
>>>>>>>>
>>>>>>>> *Here are more details :*
>>>>>>>>
>>>>>>>> *Actual sql script*
>>>>>>>>
>>>>>>>> CREATE TABLE #hlm --- this is Temporary table hlm in SQL Server DB
>>>>>>>>
>>>>>>>> (
>>>>>>>> id INT IDENTITY(1, 1) NOT NULL,
>>>>>>>>
>>>>>>>> item_id INT,
>>>>>>>> ha_id INT,
>>>>>>>> period_id INT
>>>>>>>> )
>>>>>>>>
>>>>>>>> insert into #hlm (item_id, ha_id, period_id)
>>>>>>>> SELECT item_id,
>>>>>>>> ha_id,
>>>>>>>> MAX(period_id) AS period_id
>>>>>>>> from *hierarchy_leaf *
>>>>>>>> group by ITEM_ID, ha_id
>>>>>>>>
>>>>>>>> *For the above i have written JOOQ equalent script as below in two
>>>>>>>> ways.*
>>>>>>>>
>>>>>>>> HierarchyLeaf hl = HIERARCHY_LEAF.as("hl");
>>>>>>>>
>>>>>>>> *Way 1 : *
>>>>>>>> Table<Record3<Integer, Short, Integer>>
>>>>>>>> hlmTempTable = ctx.select(hl.ITEM_ID,hl.HA_ID,(hl.PERIOD_ID).max())
>>>>>>>> .from(hl).groupBy(hl.ITEM_ID,hl.HA_ID).asTable();
>>>>>>>>
>>>>>>>> *Way 2 : *
>>>>>>>> ctx.select(hl.ITEM_ID,hl.HA_ID
>>>>>>>> ,(hl.PERIOD_ID).max())
>>>>>>>> .from(hl).groupBy(hl.ITEM_ID,hl.HA_ID).asTable("hlmTempTable",
>>>>>>>> "ITEM_ID","HA_ID","PERIOD_ID");
>>>>>>>>
>>>>>>>>
>>>>>>>> *In both ways I tried but me not able to join the table
>>>>>>>> hlmTempTable with other table.*
>>>>>>>>
>>>>>>>> *How to do it joining operation on derived table **hlmTempTable*
>>>>>>>> * ?*
>>>>>>>> *Also any specific example how to use asTable method of table ?*
>>>>>>>>
>>>>>>>> Thank you.
>>>>>>>> ~Shyam
>>>>>>>>
>>>>>>>> --
>>>>>>>> You received this message because you are subscribed to the Google
>>>>>>>> Groups "jOOQ User Group" group.
>>>>>>>> To unsubscribe from this group and stop receiving emails from it,
>>>>>>>> send an email to [email protected].
>>>>>>>>
>>>>>>>> For more options, visit https://groups.google.com/groups/opt_out.
>>>>>>>>
>>>>>>>
>>>>>>> --
>>>>>> You received this message because you are subscribed to the Google
>>>>>> Groups "jOOQ User Group" group.
>>>>>> To unsubscribe from this group and stop receiving emails from it,
>>>>>> send an email to [email protected].
>>>>>> For more options, visit https://groups.google.com/groups/opt_out.
>>>>>>
>>>>>
>>>>> --
>>>> You received this message because you are subscribed to the Google
>>>> Groups "jOOQ User Group" group.
>>>> To unsubscribe from this group and stop receiving emails from it, send
>>>> an email to [email protected].
>>>> For more options, visit https://groups.google.com/groups/opt_out.
>>>>
>>>
>>> --
>> You received this message because you are subscribed to the Google Groups
>> "jOOQ User Group" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to [email protected] <javascript:>.
>> For more options, visit https://groups.google.com/groups/opt_out.
>>
>
>
--
You received this message because you are subscribed to the Google Groups "jOOQ
User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.