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

Posted by Jade Rubick on
Don, you were exactly right.

Just for everyone else that might find this thread, here's my corrected ad_form declaration:

ad_form -name add_edit -form {


    ... declaration of form elements

} -select_query_name brand_select -on_submit {

    set user_id [ad_conn user_id]
    set peeraddr [ad_conn peeraddr]

} -new_data {

    db_transaction {
      db_exec_plsql new_brand { }
      db_dml brand_update { }

    ad_returnredirect "."

} -edit_data {

    db_dml brand_update { }

    ad_returnredirect "."



The bug was in the add-edit-postgres.xql file. Here is how it was:

<fullquery name="new_brand">
      select brand__new(
          [db_nextval brand_brand_lid_seq],

If you look at the declaration of brand__new, the first parameter is brand_id. I was passing it null, so it wasn't getting the brand_id that was generated by ad_form.

Hopefully, this will help out someone else that makes the same mistake I did.

For the search engine: postgres 16 argument ad_form key changes