Hey all, I posted this to r/supabase but maybe her...
# help
c
Hey all, I posted this to r/supabase but maybe here is a bit more appropriate. I'm a bit stuck running a cron job query and sending those results to an API endpoint
Copy code
select
  cron.schedule(
    'webhook-every-day', -- name of the cron job
    '1 0 * * *', -- every day at 12:01am
    $$
    -- declare variable
    declare
    results setof events
    -- start::query reminders table
    RETURN QUERY SELECT title, date
    INTO results
    FROM events
    WHERE CAST(date AS DATE) = NOW()::DATE
    -- end::query
    select status
    from
      http_post(
        'https://api.com/',
        results, -- payload as an array of rows?
        'application/json'
      )
    $$
  );
This produces an error at or near
setof events
n
Hello @cardyet! This thread has been automatically created from your message in #843999948717555735 a ``few seconds ago``. Pinging @User so that they see this as well! Want to unsubscribe from this thread? Right-click the thread in Discord (or use the ... menu) and select Leave Thread to unsubscribe from future updates. Want to change the title? Use the
/title
command! We have solved your problem? Click the button below to archive it.
d
What's the error Message?
n
cardyet (2022-03-12)
c
creating the cron there is no error, but checking the logs for each cron job show this.
ERROR:  syntax error at or near "setof" LINE 4:       results setof events; ^
line 4 doesn't line up with setof though