0

I am writing a function where I declare a variable of type text[]. Must use values in SELECT, with IN.

DO $$
    declare
        ids uuid[] := array['00000000-0000-0000-0000-000000000000', '00000000-0000-0000-0000-000000000000', '00000000-0000-0000-0000-000000000000','00000000-0000-0000-0000-000000000000'...];
        begin
    SELECT * from "table"
        where "Id" IN (projectIds);
end
$$;

But this way it doesn't work. I try to google, everywhere very strange ways. That declare third-party types. That IDs are indicated in a temporary table.

Erwin Brandstetter
  • 605,456
  • 145
  • 1,078
  • 1,228
  • 3
    `where "Id" = any(ids)` – klin Nov 20 '22 at 17:30
  • [42601] ERROR: Query does not have destination for result data Hint: If you need to discard SELECT results, use PERFORM. Where: PL/pgSQL function inline_code_block, line 5, statement SQL statement :( – QviNSteN Nov 20 '22 at 17:34
  • 1
    That's because your *Query does not have destination for result data*. The error message seems pretty clear. What were you planning to do with the results? Hint: a `DO` statement does not return anything. Consider a function: https://stackoverflow.com/a/7945958/939860 To just test your statement use `PERFORM` instead of `SELECT`. See: https://stackoverflow.com/a/67711519/939860 – Erwin Brandstetter Nov 20 '22 at 17:45
  • See [here](https://stackoverflow.com/search?q=[postgresql]+Query+does+not+have+destination+for+result+data+) for a solution to your follow up error –  Nov 20 '22 at 19:37

0 Answers0