my $self = shift; In the next line I want to go through each item in $self->tsids which is declared as $self->{tsids} = []; thus the line
foreach my $var($self->tsids) {
This line my $name = new profile($var); is to create a new object for each value in $self->tsids

I already have a DBI handle my $connection = $self->connection;

Then I prepare my statement using a placeholder my $sth = $connection->connection->prepare( "SELECT  Last_Name = LastName, First_Name = FirstName, Middle_Name = MidName, Job_Title = JobTitle, Birthdate = Birthdate FROM table WHERE database_wide_key = ?" );

This is probably the offending line my @names = ($var);

This is the line where it diesmy $rc = $sth->execute(@names) or die "I'm sorry Dave, I can't do that";

I initially got an error message that the database MS TSQL 6.5 could not implicity convert a VARCHAR to an INT which made me think that Perl was interpolating $var into a "string".

When I use the CONVERT statement, Convert(int, varchar) ?, it tells me that it cannot convert VARCHAR ARRAY(XXXXXXX) into a INT which leads me to believe that I am incorrectly dereferencing the array.This is where I am stuck.

The rest of the code is meant to populate the properties of the object created by the foreach loop.

my $fieldnames = $sth->{NAME}; while(my $row = $sth->fetch) { for (0 .. ( scalar @{ $fieldnames } -1 )) { $_ = '' unless defined +; $_ =~ s/\s//g; my $prop = $fieldnames->[ $_ ]; my $val = $row->[ $_]; $name->$prop($val); } } }

In reply to Re: Re: Re: Re: Re: Re: Re: Re: Re: Re: Re: Dereference an array reference by fmogavero
in thread Dereference an array reference by fmogavero

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.