The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

UnixODBC::RSS.pm - Create RSS output from a UnixODBC query.

SYNOPSIS

    use UnixODBC;
    use UnixODBC::RSS;

    my $rdf = new UnixODBC::RSS;  

    $rdf -> Channel ({'title' => 'feed_title',
                      'description' => 'feed_description',
                      'link' => 'url'});
                     
    $rdf -> ChannelImage ('url' => 'image_url',
                          'title' => 'alt_title',
                          'description' => 'image_description');

    $rdf -> TextInput ({'title' => 'resource_title',
                        'description' => 'resource_description',
                        'name' => 'resource_name',
                        'link' => 'resource_uri'});

    $rdf -> ColumnHeadings ($array_ref);

    $rdf -> ItemColumns ({'column_name_of_title_content' => 'title',
                         'column_name_of_description_content' => 'description',
                         'column_name_of_name_content' => 'name',
                         'column_name_of_link_content' => 'link'});

    # @resultset is an array of row references.
    $rdf -> Output (\@resultset, *STDOUT);  

DESCRIPTION

UnixODBC::RSS.pm formats query results as a RSS version 1.0 RDF file. The result set array that is the Output () method's first argument is an array of row array references, as described below.

The Channel() method's argument is an anonymous hash or hash reference that provides RSS channel identification for <channel> and member tags: <title>, <description>, and <url>.

ChannelImage() optionally provides information about an image resource, if any. An <image><link> member content is identical to the <channel><link> member content.

The method, ItemColumns(), takes as its argument an anonymous hash or hash reference. Each key-value pair describes the result set column that provides content for an <item> member: <title>, <name>, <description>, or <link>.

ColumnHeadings() saves a query's column headings as an array reference. Refer to the example below.

The TextInput() arguments, given as a hash reference, provide the content of a <textinput> section.

Output() takes as its arguments the result set as an array reference and an output filehandle.

Creating a RSS RDF file follows approximately these steps.

  # Allocate Environment, Connection, and statement handles, and connect 
  # to DSN.... 

  $r = SQLPrepare ($sth, $Query, length ($Query));
  $r = SQLExecute ($sth);

  my $ncols;

  $r = SQLNumResultCols ($sth,$ncols);

  my ($col, $buf, $rfetch, $rget, $colarrayref, @rowarray, $rlen, $n);

  my $colheadref = new_array_ref ();

  # Get column headings

  for ($col = 1; $col <= $ncols; $col++) {
      $r = SQLColAttribute ($sth, $col, $SQL_COLUMN_NAME, $buf, 
                          $SQL_MAX_MESSAGE_LENGTH, $rlen, $n);
      $$colheadref[$col - 1] = $buf;
  }

  $rss -> ColumnHeadings ($colheadref);

  # Get column data

  while (1) {
      $rfetch = SQLFetch ($sth);
      last if $rfetch == $SQL_NO_DATA;
      $colarrayref = new_array_ref ();
      for ( $col = 1; $col <= $ncols; $col++) {
          $rget = SQLGetData ($sth, $col, $SQL_CHAR, $buf, 
                         $SQL_MAX_MESSAGE_LENGTH, $rlen);
          $$colarrayref[$col - 1] = $buf;
      }
      push @rowarray, ($colarrayref);
  }

  $rss -> Output (\@rowarray, *STDOUT);

  sub new_array_ref { my @a; return \@a; }

VERSION INFORMATION AND CREDITS

Version 0.02

Copyright © 2004 Robert Kiesling, rkies@cpan.org.

Licensed under the same terms as Perl. Refer to the file, "Artistic," for details.

BUGS

Does not perform validation and does not check for required content.

SEE ALSO

UnixODBC(3), XML::RSS(3), rssoutput(1)

1 POD Error

The following errors were encountered while parsing the POD:

Around line 184:

Non-ASCII character seen before =encoding in '©'. Assuming CP1252