Forum OpenACS Development: Re: Removing single quote from SQL variables

Posted by Matthew Geddert on

Although there are a number of ways of doing this, I like to use the template::util::tcl_to_sql_list proc. So from a list of forums_ids the select in the on_submit needs to be in quotes not curly braces:

# I am setting it here, but this list should be supplied by your form
set forumcheck [list 1241053 1240526 1242123 1241683]

db_foreach select_my_stuff "
   select name ....
    where forum_id in ([template::util::tcl_to_sql_list $forumcheck])

This converts forum_ids to '1241053','1240526','1242123','1241683' which is what you want.