PEPPLER.ORG
Michael Peppler
Sybase Consulting
Menu
Home
Sybase on Linux
Install Guide for Sybase on Linux
General Sybase Resources
General Perl Resources
Freeware
Sybperl
Sybase::Simple
DBD::Sybase
BCP Tool
Bug Tracker
Mailing List Archive
Downloads Directory
FAQs
Sybase on Linux FAQ
Sybperl FAQ
Personal
Michael Peppler's resume

sybperl-l Archive

Up    Prev    Next    

From: Julia Stone <Julia dot Stone at msdw dot com>
Subject: Here document troubles w/ SQL
Date: Jun 20 2000 8:42PM

I am having a problem with using a scalar variable in my here document.
Here is a small example of my problem:

     my $dept_name;

      my $sql = <<"EOSQL";
      SELECT count(students)
      FROM newStudents
      WHERE dept = "$dept_name"
       EOSQL

I want to loop through department names.  I have done this before
without a loop.  But this time I continually end up with an empty
string!

        foreach my $school_dept (@all_depts)
      {

        $dept_name = $school_dept;
        # I'll check to make sure the value of $dept_name is correct,
and it has been
        print "Value of dept_name: $dept_name \n";
        my @row = $data_dbh->nsql($query,"ARRAY");
        die "$cmdname: $DB_ERROR, stopped at" if $DB_ERROR;
        print "Query: $sql \n";
       }

When I print the $sql value it consistently returns with the following:

      SELECT count(students)
      FROM newStudents
      WHERE dept = " "

All values are in place, but somehow this $sql isn't able to resolve
$dept_name ... anyone have any ideas why?

Thanks.