Skip to content
Advertisement

Tag: plpgsql

Sum variables when condition is met in sql

I have a table mes_transaction where I have variable dc – it’s either DEBIT or CREDIT. I am writing a sql procedure for another table(if I can say so). In the other table mes_aggregated_trx I have trx_amt – transaction amount variable. Basically what I need to do is to write a procedure that would sum trx_amt in mes_aggregated_trx based on

Selecting and passing a record as a function argument

It may look like a duplicate of existing questions (e.g. This one) but they only deal with passing “new” arguments, not selecting rows from the database. I have a table, for example: And a function: I would like to run it on data already existing in the database. It’s no problem if I would like to use it from another

How to iterate over results of query

I am creating a function in pgsql script language, and what I want to do in this point is iterate over the results of a query and for each row do something specific. My current try is the following, where temprow is declared as temprow user_data.users%rowtype. The code in question is the following: However I get the following error from

Advertisement