1

Am I writing this code correctly?

select sbcm_ref.process_legal_entities_buf_record(legal_entities_buf_id value from table legal_entities_buf)

to

DSL.using(connection)
.select(Routines.processLegalEntitiesBufRecord(field(select(LEGAL_ENTITIES_BUF.LEGAL_ENTITIES_BUF_ID)
.from(LEGAL_ENTITIES_BUF)))).fetch();
Lukas Eder
  • 211,314
  • 129
  • 689
  • 1,509
  • or execute() instead of fetch()? – Oleksii Hlovatskyi Jun 02 '22 at 09:19
  • Can you please clarify your SQL syntax? There's no ` value from table ` syntax as far as I know? What SQL query are you trying to achieve, exactly?
    – Lukas Eder Jun 02 '22 at 09:48
  • First step - we did insert into LEGAL_ENTITIES_BUF table. Second step - Process data using procedure: select sbcm_ref.process_legal_entities_buf_record(legal_entities_buf_id value from table legal_entities_buf) Then the procedure for creating a legal entity begins – Oleksii Hlovatskyi Jun 02 '22 at 09:58

1 Answers1

1

I've never seen any (<column> value from table <table>) syntax in SQL (as in your function argument list), so I'm assuming this is just some pseudo SQL you wrote, not actual SQL, or a typo?

The actual SQL would look like this, then?

select sbcm_ref.process_legal_entities_buf_record(legal_entities_buf_id)
from legal_entities_buf

In that case, that would translate 1:1 to jOOQ

ctx.select(Routines.processLegalEntitiesBufRecord(
               LEGAL_ENTITIES_BUF.LEGAL_ENTITIES_BUF_ID))
   .from(LEGAL_ENTITIES_BUF)
   .fetch();
Lukas Eder
  • 211,314
  • 129
  • 689
  • 1,509
  • @a_horse_with_no_name: In a function argument list? ... I get it, the OP probably just placed the closing `)` at the wrong place... – Lukas Eder Jun 02 '22 at 12:01
  • Ah, I misread the query. –  Jun 02 '22 at 12:07
  • I have to write a query with LEGAL_ENTITIES_BUF_ID value – Oleksii Hlovatskyi Jun 02 '22 at 14:39
  • @OleksiiHlovatskyi: I will update my answer once you update your question. As it is now, your question isn't really very clear. The SQL you posted isn't valid, so I don't know what translation to jOOQ you're expecting. Please read this useful resource about what people trying to answer your question might be expecting: https://stackoverflow.com/help/minimal-reproducible-example – Lukas Eder Jun 02 '22 at 14:45
  • That's what I need: DSL.using(connection) .select(Routines.processLegalEntitiesBufRecord(field(select(LEGAL_ENTITIES_BUF.LEGAL_ENTITIES_BUF_ID) .from(LEGAL_ENTITIES_BUF) .where(LEGAL_ENTITIES_BUF.LEGAL_ENTITIES_BUF_ID.eq(legalEntityId))))) .fetch(); – Oleksii Hlovatskyi Jun 03 '22 at 06:41
  • @OleksiiHlovatskyi: OK, then what's your problem? I don't get it, sorry. – Lukas Eder Jun 03 '22 at 08:52
  • No more problems! The code works! Thank you! – Oleksii Hlovatskyi Jun 03 '22 at 10:28
  • @LukasEder: I am using JOOQ for genetation data for automated tests. I have a lot of tasks. I will sometimes ask you to help me) Have a nice day! – Oleksii Hlovatskyi Jun 03 '22 at 10:30
  • @OleksiiHlovatskyi: No problem. I'm looking at all the questions here on Stack Overflow – Lukas Eder Jun 03 '22 at 10:32