RE: Only return the FIRST field from DBD/ODBC/Sql Server stored proce dure
-Original Message- From: Guangzu Wang (Houston) [mailto:[EMAIL PROTECTED]] Sent: Monday, June 04, 2001 3:57 AM To: [EMAIL PROTECTED] Subject: Only return the FIRST field from DBD/ODBC/Sql Server stored proce dure I use DBD::ODBC with Easysoft ODBC bridge to connect SQL server 6.5 from Linux. I have a stored procedure that is supposed to return several fields. It only returns the first field of my result set. I searched the archive of this mailing list and haven't found some encouraging news. The book of Programming the Perl DBI (pp 296) mentioned stored procedure can be called using {?= call procedure_name(?,?)} but then said DBD::ODBC currently does not support output parameter. Doesn't that mean I can NOT use that method? I tried but failed. I tried both escape method like {call procedure_name} and direct run as exec procedure_name, same result. Not sure what you mean. What does the sp do? If it's just returning a rowset as you seem to imply by the term field then it is not different from any SELECT, PREPARE, FETCH, FETCH ... etc operation. If this isn't so you will be better off to clarify this to the list. The same book mentioned in several places (like pp 223) that fetchrow_array returns the value of the first field if used in a scalar context. I am not sure about this scalar context, is this something related @list = $sth-fetchrow_array; # ie (1,2,3,4) $scalar = $sth-fetchrow_array; # only gets 1st element $list[0] Which is probably what you are doing, though I am sure the book has clear examples. I would also suggest a read of your perlvar manpage if you are not fammiliar with the concept of scalars. Neil to my problem about the stored procedure? Does any one has a clue? Thanks a lot in advance. Guangzu __ Please Note : Only the intended recipient is authorised to access or use this e-mail. If you are not the intended recipient, please delete this e-mail and notify the sender immediately. The contents of this e-mail are the writer's opinion and are not necessarily endorsed by the Gunz Companies unless expressly stated. We use virus scanning software but exclude all liability for viruses or similar in any attachment.
RE: Only return the FIRST field from DBD/ODBC/Sql Server stored proce dure
-Original Message- From: Neil Lunn [mailto:[EMAIL PROTECTED]] Sent: Sunday, June 03, 2001 8:44 PM To: 'Guangzu Wang (Houston)'; [EMAIL PROTECTED] Subject: RE: Only return the FIRST field from DBD/ODBC/Sql Server stored proce dure -Original Message- From: Guangzu Wang (Houston) [mailto:[EMAIL PROTECTED]] Sent: Monday, June 04, 2001 3:57 AM To: [EMAIL PROTECTED] Subject: Only return the FIRST field from DBD/ODBC/Sql Server stored proce dure I use DBD::ODBC with Easysoft ODBC bridge to connect SQL server 6.5 from Linux. I have a stored procedure that is supposed to return several fields. It only returns the first field of my result set. I searched the archive of this mailing list and haven't found some encouraging news. The book of Programming the Perl DBI (pp 296) mentioned stored procedure can be called using {?= call procedure_name(?,?)} but then said DBD::ODBC currently does not support output parameter. Doesn't that mean I can NOT use that method? I tried but failed. I tried both escape method like {call procedure_name} and direct run as exec procedure_name, same result. Not sure what you mean. What does the sp do? If it's just returning a rowset as you seem to imply by the term field then it is not different from any SELECT, PREPARE, FETCH, FETCH ... etc operation. If this isn't so you will be better off to clarify this to the list. The same book mentioned in several places (like pp 223) that fetchrow_array returns the value of the first field if used in a scalar context. I am not sure about this scalar context, is this something related @list = $sth-fetchrow_array; # ie (1,2,3,4) $scalar = $sth-fetchrow_array; # only gets 1st element $list[0] I believe that in a scalar contex it will return true or undef, but in the list context ($scalar) = $sth-fetchrow_array it will return the first element. Ilya Sterin Which is probably what you are doing, though I am sure the book has clear examples. I would also suggest a read of your perlvar manpage if you are not fammiliar with the concept of scalars. Neil to my problem about the stored procedure? Does any one has a clue? Thanks a lot in advance. Guangzu __ Please Note : Only the intended recipient is authorised to access or use this e-mail. If you are not the intended recipient, please delete this e-mail and notify the sender immediately. The contents of this e-mail are the writer's opinion and are not necessarily endorsed by the Gunz Companies unless expressly stated. We use virus scanning software but exclude all liability for viruses or similar in any attachment.
RE: Only return the FIRST field from DBD/ODBC/Sql Server stored proce dure
-Original Message- From: Sterin, Ilya [mailto:[EMAIL PROTECTED]] Sent: Monday, June 04, 2001 1:02 PM To: Neil Lunn; 'Guangzu Wang (Houston)'; [EMAIL PROTECTED] Subject: RE: Only return the FIRST field from DBD/ODBC/Sql Server stored proce dure @list = $sth-fetchrow_array; # ie (1,2,3,4) $scalar = $sth-fetchrow_array; # only gets 1st element $list[0] I believe that in a scalar contex it will return true or undef, but in the list context ($scalar) = $sth-fetchrow_array it will return the first element. Ilya Sterin You're right, that's what fetchrow_array does. I never do this though, it was just to illustrate a point about scalar context as oposed to list context. This may have ben misread from the docs on selectrow_array: the first row of data from the statement. If called in a scalar context, it returns the first field of the first row. The $statement parameter can be a previously prepared statement handle, in which case the prepare is skipped. Neil __ Please Note : Only the intended recipient is authorised to access or use this e-mail. If you are not the intended recipient, please delete this e-mail and notify the sender immediately. The contents of this e-mail are the writer's opinion and are not necessarily endorsed by the Gunz Companies unless expressly stated. We use virus scanning software but exclude all liability for viruses or similar in any attachment.