[rt-devel] retrieving Keywords
    Grant Miller 
    grant at pico.apple.com
       
    Fri Sep 27 18:33:25 EDT 2002
    
    
  
I need a little help with my perl script.  I'm trying to write a function
that when passed a Ticket id, it returns the keywords in that ticket.
I'm having difficulty figuring out how to get the keywords from a ticket id.
Here's the two functions.  I call getkeywords with the ticket number and
try to get back a string that has all the keywords.
Much Thanks in advance, 
Grant
(a working solution will be rewarded with a tasty case of beer or a fine
wine from the nearby Napa or Sonoma wineries)
sub getkeyword {
    my($keywordid) = shift;
    my($statement,$sth, at row,$keyname,$keyparent) = '';
    $statement = "select * from Keywords where id='$keywordid'";
    $sth = execute_sql_statement($statement);
    @row = $sth->fetchrow_array;
    $keyname = $row[1];
    $keyparent = $row[3];
    $sth->finish;
    if ($keyparent == 0) {
        return($keyname);
    } else {
        return(" " . &getkeyword($keyparent) . " / $keyname " );
    }
}
sub getkeywords {
    my($ticketid) = shift;
    my($statement,$sth,$email,$statement1,$sth1, at row, at keywords) = '';
    $statement = "select * from ObjectKeywords where ObjectType='Ticket' AND Obj
ectId='$ticketid'";
    $sth = execute_sql_statement($statement);
    while (@row = $sth->fetchrow_array) {
        $keyid = $row[1];
        push @keywords, &getkeyword($keyid);
    }
    $sth->finish;
    return(@keywords);
}
-- 
-Grant Miller    grant at pico.apple.com     
 Unix Systems Admin, Engineering Computer Services, Apple Computer
    
    
More information about the Rt-devel
mailing list