Forum OpenACS Q&A: ERROR in mailing-list/index .tcl

Collapse
Posted by amit singh on
ERROR in mailing-list/index .tcl <p>
I get an error like
<pre>[04/Jan/2001:17:20:12]
    Error: Ns_PgExec: result status: 7 message: ERROR:  parser: parse
error at or near "("

[04/Jan/2001:17:20:12]
    Error: dbinit: error(localhost::iigfdb,ERROR:  parser: parse error
at or near "("
    ): 'select c.category, c.category_id,
decode(ui.category_id,NULL,NULL,'t') as selected_p
    from categories c, (select * from users_interests where user_id =
1) ui
    where c.enabled_p = 't'
    and c.category_id = ui.category_id(+)'

[04/Jan/2001:17:20:12]
    Error: Database operation "select" failed (exception NSDB, "Query
was not a statement returning rows.")
    Database operation "select" failed (exception NSDB, "Query was not
a statement returning rows.")
        while executing
    "ns_db select $db "select c.category, c.category_id,
decode(ui.category_id,NULL,NULL,'t') as selected_p
    from categories c, (select * from users_interes ..."
        invoked from within
    "set selection [ns_db select $db "select c.category,
c.category_id, decode(ui.category_id,NULL,NULL,'t') as selected_p
    from categories c, (select * fro ..."
        invoked from within
    "if { $user_id == 0 } {
        # not a logged-in user
        set selection [ns_db select $db "select category_id, category
    from categories
    where enabled_p  ..."
        (file "/web/iig.org.in/www/mailing-list/index.tcl" line 5)
        invoked from within
    "source $ad_conn(file)"
        invoked from within
    "if { $extension == ".tcl" } {
        # Tcl file - use source.
        source $ad_conn(file)
        } elseif { $extension == ".adp" } {
        # ADP file - parse and return  ..."
        (procedure "ad_handle_abstract_url" line 65)
        invoked from within
    "ad_handle_abstract_url cns368 {}"
    Notice: dbdrv: opening database 'postgres:localhost::iigfdb'</pre>

<p>
Is the file ported in open acs?
Can some one help me with this.

Collapse
Posted by Dan Wickstrom on
You've found an unported query. The following query (untested) should work:
            "select c.category, c.category_id, 
                    case when ui.category_id is NULL then NULL::char else 't'::char end as selected_p
               from categories c, users_interests ui
              where c.enabled_p = 't' 
                and ui.user_id = $user_id
                and c.category_id = ui.category_id
    union all
             select c.category, c.category_id, 
                    NULL::char as selected_p
               from categories c
              where c.enabled_p = 't' 
                and ui.user_id = $user_id
                and not exists (select 1 from user_interests 
                                 where category_id = c.category_id 
                                   and user_id = $user_id)"
Collapse
Posted by Dan Wickstrom on
Oops. The query should be:
 "select c.category, c.category_id, 
                           case when ui.category_id is NULL then NULL::char else 't'::char end as selected_p
                      from categories c, users_interests ui
                     where c.enabled_p = 't' 
                       and ui.user_id = $user_id
                       and c.category_id = ui.category_id
           union all
                    select c.category, c.category_id, 
                           NULL::char as selected_p
                      from categories c
                     where c.enabled_p = 't' 
                       and not exists (select 1 from user_interests 
                                        where category_id = c.category_id 
                                          and user_id = $user_id)"

The new version is checked into cvs.

Further errors after getting the updates from CVS

[05/Jan/2001:11:58:25]
    Error: Ns_PgExec: result status: 7 message: ERROR:  Relation 'user_interests' does not exist
    

[05/Jan/2001:11:58:25]
    Error: dbinit: error(localhost::iigfdb,ERROR:  Relation 'user_interests' does not exist
    ): 'select c.category, c.category_id, 
                               case when ui.category_id is NULL then NULL::char else 't'::char end as selected_p
                          from categories c, users_interests ui
                         where c.enabled_p = 't' 
                           and ui.user_id = 1
                           and c.category_id = ui.category_id
               union all
                        select c.category, c.category_id, 
                               NULL::char as selected_p
                          from categories c
                         where c.enabled_p = 't' 
                           and not exists (select 1 from user_interests 
                                            where category_id = c.category_id 
                                              and user_id = 1)'

[05/Jan/2001:11:58:25]
    Error: Database operation "select" failed (exception NSDB, "Query was not a statement returning rows.")
    Database operation "select" failed (exception NSDB, "Query was not a statement returning rows.")
        while executing
    "ns_db select $db $sql"
        invoked from within
    "set selection [ns_db select $db $sql]..."
        invoked from within
    "if { $user_id == 0 } {
        # not a logged-in user 
        set selection [ns_db select $db "select category_id, category
    from categories 
    where enabled_p  ..."
        (file "/web/iig.org.in/www/mailing-list/index.tcl" line 5)
        invoked from within
    "source $ad_conn(file)"
        invoked from within
    "if { $extension == ".tcl" } {
        # Tcl file - use source.
        source $ad_conn(file)
        } elseif { $extension == ".adp" } {
        # ADP file - parse and return  ..."
        (procedure "ad_handle_abstract_url" line 65)
        invoked from within
    "ad_handle_abstract_url cns1 {}"
    Notice: Querying 'select ad_group_member_p(1, system_administrator_group_id()) from dual;'
Collapse
Posted by Dan Wickstrom on
There was a typo in the subselect.  user_interests should be users_interests.    This is fixed in cvs.
Collapse
Posted by amit singh on
Thanks Fixed an error in /mailing-list/subscribe.tcl
($user_id, $category_id, sysdate)
The line should read ($user_id, $category_id, sysdate())
Collapse
Posted by amit singh on
Ok i got the mailing list working
I have created categories in the categories module which show up on the
maling list index.tcl page. I can also subscribe to these categories.
uptil now it is fine but the problem is how do i associate contents /
modules with these categories. Or what cahnges in the site will be
mailed to the users. I dont know how top use these features can u takre
some time and explain me the functionality of the same. or refer me to
some documentation on the same.

regards
amit