I tried the above but now I am getting the below error:

org.jooq.exception.DataAccessException: SQL [update "schema"."entity" set 
"associations" = array_remove("schema"."entity"."associations", row(?, ?, 
?, ?)) where "schema"."entity"."entity_id" = cast(? as uuid)]; ERROR: 
function array_remove(schema.custom_type[], record) does not exist
  Hint: No function matches the given name and argument types. You might 
need to add explicit type casts.
  Position: 53
    at org.jooq_3.14.16.POSTGRES.debug(Unknown Source)
    at org.jooq.impl.Tools.translate(Tools.java:2903)
    at 
org.jooq.impl.DefaultExecuteContext.sqlException(DefaultExecuteContext.java:757)
    at org.jooq.impl.AbstractQuery.execute(AbstractQuery.java:389)
    at 
org.jooq.impl.AbstractDelegatingQuery.execute(AbstractDelegatingQuery.java:119)


Any idea on this.
On Monday, February 6, 2023 at 7:36:02 PM UTC+5:30 lukas...@gmail.com wrote:

> Ah yes, my bad. The data type isn't f.getDataType() (which is 
> DataType<CustomTypeRecord>), but  ENTITY.ASSOCIATIONS.getDataType() (which 
> is DataType<CustomTypeRecord[]>)
>
> As so often with type inference in Java and other languages, try to assign 
> things to local variables, so you'll see what is expected / inferred.
>
> I hope this helps
> Lukas
>
> On Mon, Feb 6, 2023 at 2:11 PM Pragya Gaur <pragy...@gmail.com> wrote:
>
>> I have created a type as below:
>>
>> CREATE TYPE schema.custom_type AS (
>> name VARCHAR(255),
>> lastname   VARCHAR(255),
>> is_old BOOLEAN,
>> propagate BOOLEAN);
>>
>> And I have a table that has an array of custom_type as shown below:
>>
>> CREATE TABLE IF NOT EXISTS schema.entity (
>> entity_id VARCHAR(255),
>> temp_id VARCHAR(255),
>> associations schema.custom_type[],
>> PRIMARY KEY (entity_id, temp_id)
>> );
>>
>> Now I have a requirement to execute the below query in jooq: 
>> update schema.entity SET associations = array_remove(associations, 
>> ('name1','lastname1',true,true)::associations) where entity_id = 
>> '85f74dc4-ab9f-46b5-8fce-1591b9b24b03';
>>
>> I tried below but its giving me complier error to cast arguments to RowN 
>> and if I do that then at runtime I get error saying that there is no data 
>> type custom_type in postgres.
>>
>> Field<CustomTypeRecord> f = DSL.val(new CustomTypeRecord("name1", 
>> "lastname1",true, true));
>>
>> dslContext.update(Tables.ENTITY)
>> .set( Tables.ENTITY.ASSOCIATIONS, DSL.field("array_remove({0}, {1})", 
>> f.getDataType(), Tables.ENTITY.ASSOCIATIONS, f))
>> .where(Tables.ENTITY.ENTITY_ID.eq("85f74dc4-ab9f-46b5-8fce-1591b9b24b03")
>> .execute();
>>
>> Can you please help me construct this.
>> On Friday, February 3, 2023 at 6:55:15 PM UTC+5:30 lukas...@gmail.com 
>> wrote:
>>
>>> Pragya,
>>>
>>> You probably simplified your own example a bit, to the extent that the 
>>> code shared here doesn't reflect the actual code or the actual problem. In 
>>> particular, I'm a bit confused about your usage of CUSTOMTYPE vs 
>>> CUSTOMTYPECOLUMN (a type and a field aren't the same thing)
>>>
>>> Can you please verify that you're using the correct references of fields 
>>> etc.? Or, rather, share the actual, complete code example here?
>>>
>>> On Fri, Feb 3, 2023 at 2:18 PM Pragya Gaur <pragy...@gmail.com> wrote:
>>>
>>>> I am getting complier error "cast arguments to RowN on the set 
>>>> statement. (set( Tables.MY_TABLE.CUSTOMTYPE, DSL.field("array_remove({0}, 
>>>> {1})", f.getDataType(), Tables.MY_TABLE.CUSTOMTYPE, f)))
>>>> And if cast both the set functions params to RowN then it complies but 
>>>> then I get runtime error that cannot convert field to row. Can you please 
>>>> suggest how to use this DSL.field("array_remove({0}, {1})", 
>>>> f.getDataType(), Tables.MY_TABLE.CUSTOMTYPE, f) in update set method.
>>>>
>>>>
>>>> Field<CustomTypeRecord> f = DSL.val(new CustomTypeRecord("test3", 
>>>> "-1"));
>>>>
>>>> dslContext.update(Tables.MY_TABLE)
>>>> .set( Tables.MY_TABLE.CUSTOMTYPE, DSL.field("array_remove({0}, {1})", 
>>>> f.getDataType(), Tables.MY_TABLE.CUSTOMTYPE, f))
>>>> .where(condition)
>>>> .execute();
>>>>
>>>>
>>>>
>>>> On Friday, February 3, 2023 at 5:29:29 PM UTC+5:30 lukas...@gmail.com 
>>>> wrote:
>>>>
>>>>> How exactly is it not working for you? What are you seeing? Runtime 
>>>>> errors? Wrong results?
>>>>>
>>>>> On Fri, Feb 3, 2023 at 12:58 PM Pragya Gaur <pragy...@gmail.com> 
>>>>> wrote:
>>>>>
>>>>>> I meant, I tried below step, but it is not working for me.
>>>>>>
>>>>>> Field<CustomTypeRecord> f = DSL.val(new CustomTypeRecord("test3", 
>>>>>> "-1"));
>>>>>>
>>>>>> dslContext.update()
>>>>>> .set( Tables.MY_TABLE.CUSTOMTYPE, DSL.field("array_remove({0}, 
>>>>>> {1})", f.getDataType(), Tables.MY_TABLE.CUSTOMTYPE, f))
>>>>>> .where(condition)
>>>>>> .execute();
>>>>>> On Friday, February 3, 2023 at 4:30:47 PM UTC+5:30 lukas...@gmail.com 
>>>>>> wrote:
>>>>>>
>>>>>>> Can you please be specific about this "something"?
>>>>>>>
>>>>>>> On Fri, Feb 3, 2023 at 11:59 AM Pragya Gaur <pragy...@gmail.com> 
>>>>>>> wrote:
>>>>>>>
>>>>>>>>
>>>>>>>> I am very new to JOOQ. Can you please suggest how to use it in 
>>>>>>>> update statements. I tried out something like this but not working for 
>>>>>>>> me.
>>>>>>>>
>>>>>>>> Field<CustomTypeRecord> f = DSL.val(new CustomTypeRecord("test3", 
>>>>>>>> "-1"));
>>>>>>>> dslContext.update()
>>>>>>>> .set( Tables.MY_TABLE.CUSTOMTYPE,
>>>>>>>> DSL.field("array_remove({0}, {1})", f.getDataType(), 
>>>>>>>> Tables.MY_TABLE.CUSTOMTYPE, f))
>>>>>>>> .where(condition)
>>>>>>>> .execute();
>>>>>>>> On Friday, February 3, 2023 at 2:03:46 PM UTC+5:30 
>>>>>>>> lukas...@gmail.com wrote:
>>>>>>>>
>>>>>>>>> ARRAY_REMOVE will be supported in the upcoming jOOQ 3.18:
>>>>>>>>> https://github.com/jOOQ/jOOQ/issues/11981
>>>>>>>>>
>>>>>>>>> Until then, you can just use plain SQL templating whenever you 
>>>>>>>>> need to work with vendor specific functions that aren't supported:
>>>>>>>>>
>>>>>>>>> https://www.jooq.org/doc/latest/manual/sql-building/plain-sql-templating/
>>>>>>>>>
>>>>>>>>> Field<CustomTypeRecord> f = DSL.val(new CustomTypeRecord("test3", 
>>>>>>>>> "-1"));
>>>>>>>>> DSL.field("array_remove({0}, {1})", f.getDataType(), 
>>>>>>>>> MY_TABLE.CUSTOMTYPECOLUMN, f);
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> I hope this helps,
>>>>>>>>> Lukas
>>>>>>>>>
>>>>>>>>> On Fri, Feb 3, 2023 at 9:30 AM Pragya Gaur <pragy...@gmail.com> 
>>>>>>>>> wrote:
>>>>>>>>>
>>>>>>>>>> I have a TYPE defined say customtype and have a table where one 
>>>>>>>>>> of the columns is customtype[]. 
>>>>>>>>>> I am trying to find ways where I can execute the below sql query 
>>>>>>>>>> in JOOQ:
>>>>>>>>>>
>>>>>>>>>> update MY_TABLE SET customtypecolumn = 
>>>>>>>>>> array_remove(customtypecolumn, ('test3','-1')::customtypecolumn) 
>>>>>>>>>> where 
>>>>>>>>>> <some_condition>
>>>>>>>>>>
>>>>>>>>>> I tried following this link 
>>>>>>>>>> https://jooq-user.narkive.com/ScEfUAlX/fastest-way-to-remove-values-from-an-integer-array
>>>>>>>>>> But this way I am getting exception TYPE customtype is not 
>>>>>>>>>> supported in dialect POSTGRES
>>>>>>>>>>
>>>>>>>>>> -- 
>>>>>>>>>> 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 jooq-user+...@googlegroups.com.
>>>>>>>>>> To view this discussion on the web visit 
>>>>>>>>>> https://groups.google.com/d/msgid/jooq-user/78e86317-41d1-41ed-ba6d-f2060ac3018an%40googlegroups.com
>>>>>>>>>>  
>>>>>>>>>> <https://groups.google.com/d/msgid/jooq-user/78e86317-41d1-41ed-ba6d-f2060ac3018an%40googlegroups.com?utm_medium=email&utm_source=footer>
>>>>>>>>>> .
>>>>>>>>>>
>>>>>>>>> -- 
>>>>>>>> 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 jooq-user+...@googlegroups.com.
>>>>>>>>
>>>>>>> To view this discussion on the web visit 
>>>>>>>> https://groups.google.com/d/msgid/jooq-user/2fcbcc56-c404-4b5e-b765-fad5a6757c04n%40googlegroups.com
>>>>>>>>  
>>>>>>>> <https://groups.google.com/d/msgid/jooq-user/2fcbcc56-c404-4b5e-b765-fad5a6757c04n%40googlegroups.com?utm_medium=email&utm_source=footer>
>>>>>>>> .
>>>>>>>>
>>>>>>> -- 
>>>>>> 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 jooq-user+...@googlegroups.com.
>>>>>>
>>>>> To view this discussion on the web visit 
>>>>>> https://groups.google.com/d/msgid/jooq-user/72e9a543-9ac1-4a52-a23f-1853dc9342ben%40googlegroups.com
>>>>>>  
>>>>>> <https://groups.google.com/d/msgid/jooq-user/72e9a543-9ac1-4a52-a23f-1853dc9342ben%40googlegroups.com?utm_medium=email&utm_source=footer>
>>>>>> .
>>>>>>
>>>>> -- 
>>>> 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 jooq-user+...@googlegroups.com.
>>>>
>>> To view this discussion on the web visit 
>>>> https://groups.google.com/d/msgid/jooq-user/c3f56a46-18e3-4503-a8b4-a95df394c940n%40googlegroups.com
>>>>  
>>>> <https://groups.google.com/d/msgid/jooq-user/c3f56a46-18e3-4503-a8b4-a95df394c940n%40googlegroups.com?utm_medium=email&utm_source=footer>
>>>> .
>>>>
>>> -- 
>> 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 jooq-user+...@googlegroups.com.
>>
> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/jooq-user/7367dd6f-f5fd-44db-a6e6-add34452e87dn%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/jooq-user/7367dd6f-f5fd-44db-a6e6-add34452e87dn%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>>
>

-- 
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 jooq-user+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jooq-user/4cbf6c1b-e7c8-4fbb-b805-8900774b2fban%40googlegroups.com.

Reply via email to