<tt><font size=2>David Schmidt &lt;davewood@gmx.at&gt; wrote on 06/13/2012
04:15:57 PM:<br>
<br>
&gt; From:</font></tt>
<br><tt><font size=2>&gt; <br>
&gt; David Schmidt &lt;davewood@gmx.at&gt;</font></tt>
<br><tt><font size=2>&gt; <br>
&gt; To:</font></tt>
<br><tt><font size=2>&gt; <br>
&gt; The elegant MVC web framework &lt;catalyst@lists.scsys.co.uk&gt;</font></tt>
<br><tt><font size=2>&gt; <br>
&gt; Date:</font></tt>
<br><tt><font size=2>&gt; <br>
&gt; 06/13/2012 04:16 PM</font></tt>
<br><tt><font size=2>&gt; <br>
&gt; Subject:</font></tt>
<br><tt><font size=2>&gt; <br>
&gt; Re: [Catalyst] Can't get value from model</font></tt>
<br><tt><font size=2>&gt; <br>
&gt; Hi Kenneth,<br>
&gt; <br>
&gt; that's a DBIC question<br>
&gt; <br>
&gt; <br>
&gt; anyways, what is the output of ...<br>
&gt; <br>
&gt; if ( $dept ) {<br>
&gt; &nbsp; &nbsp;warn &quot;REF: &quot; . ref $dept . &quot; DEPT_ID:
&quot; . $dept-&gt;department_id;<br>
&gt; } else {<br>
&gt; &nbsp; &nbsp;warn &quot;No dept found&quot;;<br>
&gt; }<br>
&gt; <br>
&gt; ... after your query?<br>
&gt; <br>
&gt; On 13 June 2012 22:54, Kenneth S Mclane &lt;ksmclane@us.ibm.com&gt;
wrote:<br>
&gt; &gt; I am trying to get the value from a model call into a variable
so I can use<br>
&gt; &gt; it for creating a DB record. I have tried multiple ways and cannot
get the<br>
&gt; &gt; value to return. Here is my current attempt:<br>
&gt; &gt;<br>
&gt; &gt; my $dept = $c-&gt;model('ORANGES::Departments')-&gt;search_rs({'department_code'<br>
&gt; &gt; =&gt; $departmentcode}, {<br>
&gt; &gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; columns
=&gt; ['department_id'] });<br>
&gt; &gt;<br>
&gt; &gt; This returns &quot;1&quot;.<br>
&gt; &gt;<br>
&gt; &gt; I tried this:<br>
&gt; &gt;<br>
&gt; &gt; my $dept = $c-&gt;model('ORANGES::Departments')-&gt;search_rs({'department_code'<br>
&gt; &gt; =&gt; $departmentcode}, {<br>
&gt; &gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; columns
=&gt; ['department_id'] })-&gt;single;<br>
&gt; &gt;<br>
&gt; &gt; and got a hash reference. I know I am missing something very
simple. If I<br>
&gt; &gt; was putting this into the stash I know I could access the value,
but I am at<br>
&gt; &gt; a loss as to how to get to it inside my code.<br>
&gt; &gt;<br>
&gt; &gt;<br>
</font></tt><font size=2 face="sans-serif">[error] Caught exception in
dbms::Controller::Account-&gt;add &quot;Can't locate object method &quot;department_id&quot;
via package &quot;DBIx::Class::ResultSet&quot; at /home/ksmclane/catalyst/dbms/script/../lib/dbms/Controller/Account.pm
line 49.&quot;<br>
</font>
<br>