Forum OpenACS Q&A: Re: ad_form and getting around postgres

Collapse
Posted by Tilmann Singer on
I cannot see where your brand_id is getting set and why it thus works at all.

Anyway, to do it correctly you should either get the return value of the __new function call which is the brand_id and use it for the update statement, like that:

-new_data {
  set brand_id [db_exec_plsql ...]
  db_dml update {...}
}

or set the brand_id manually before that and explicitely pass it on to the __new function:

-new_data {
  set brand_id [db_nextval acs_object_id_seq]
  db_exec_plsql new {
    select brand__new (
      :brand_id,
      :name,
    ....
  );
  }
  db_dml update {...}
}

Collapse
Posted by Jade Rubick on
Tilmann, your suggestion worked. Thank you.

Thank you.

Thank you!

Eduardo, I'm not sure how to make it transactional. I don't know if wrapping the two statements in db_transaction is legitimate or not, but you might experiment with that. I'd look at the underlying ad_form code first, though, to make sure that they look compatible.

I'm really looking forward to upgrading Postgres as some point soon 😊