Hello, how are you? I'm new to supabase, I would l...
# off-topic
i
Hello, how are you? I'm new to supabase, I would like to know if the put method can be used to update a column, I am currently creating an android application and I am using an http fuel library, but apparently it is not compatible with the patch method and it causes me problems and when using put I get the following error: { "message": "Payload values do not match URL in primary key column(s)" }
g
If you only want to update certain columns, I believe no, it is a full row update. You could use an rpc function though to do it.
i
Hello, thanks for answering: How could I execute this rpc function? , my idea is to change the status by pressing a button in the application: the status is sent from the same app
g
You create a postgres function taking in the column data and key as parameters then do an sql update on a row with that key. You call the function with an API rpc call either with client code, or a url call (available in the dashboard API section if you have the function written). Sample from a function I have:
Copy code
curl -X POST 'https://ugcxxxxxxxxseypbq.supabase.co/rest/v1/rpc/test_fn' \
-d '{ "row_id": "value" }' \
-H "Content-Type: application/json" \
-H "apikey: SUPABASE_KEY" \
-H "Authorization: Bearer SUPABASE_KEY"
i
👏🏼 thank you very much, i will try it
How can I receive the value of id when consuming the rpc? , I am trying with this and it gives me an error:
Copy code
declare
  id_chip text;
begin

update public.chips
set status = 'soldout';
where chip_id = id_chip
end;
g
Are you using the dashboard function ui to create your function? If so you can provide arguments to the function. If you are using the sql editor you need to create the function with an argument list as part of it.
i
yes I am using the supabase dashboard
g
That is with SQL for the language so no begin/end. Note the argument is the main thing.
i
Perfect, thank you very much, I was able to do it