Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

DBIx can't read SQL server 2008 varchar(max) column

by Thai Heng (Beadle)
on Jun 12, 2014 at 01:41 UTC ( #1089630=perlquestion: print w/replies, xml ) Need Help??

Thai Heng has asked for the wisdom of the Perl Monks concerning the following question:

I use DBIx to retrieve some varchar(max) column, but the program is dead, not executed when retrieve only one row. The following is the output:
c:\temp\perl\DBIx\hengaini>perl ecis_odbc.pl MyApp::Schema=HASH(0x33c928) select * from T_SEARCH where %s
my script as follows:
#!/usr/bin/perl use v5.14.2; use strict; use warnings; use utf8; use MyApp::Schema; use open ":encoding(gbk)", ":std"; my $schema = MyApp::Schema->connect('dbi:ODBC:DSN=ecis_yl','sa','73545 +00', {odbc_trace_file => 'c:\temp\odbc.trc', odbc_trace => 1} ); say $schema; my $rs = $schema->resultset('Search'); while (my $search = $rs->next) { say $search->mysql; }
I use DBIx, and result 'Search' file Search.pm as follows:
package MyApp::Schema::Result::Search; use base qw/DBIx::Class::Core/; __PACKAGE__->table('dbo.t_search'); __PACKAGE__->add_columns(qw/ searchid searchname title mysql /); __PACKAGE__->set_primary_key('searchid'); 1;
The table "T_search" in SQL Server 2008 defination as follows :
CREATE TABLE [dbo].[T_Search]( [searchId] [varchar](10) NOT NULL, [searchName] [varchar](50) NOT NULL, [mysql] [varchar](max) NOT NULL, [formName] [varchar](30) NULL, [formAction] [varchar](30) NULL, [mykey] [varchar](30) NULL, [title] [varchar](120) NULL, [orderBy] [varchar](64) NULL, [groupBy] [varchar](30) NULL, [pageSize] [smallint] NOT NULL, [entityName] [varchar](30) NULL, [ds] [varchar](12) NULL, [remark] [varchar](80) NULL, CONSTRAINT [PK_T_SearchValue22] PRIMARY KEY NONCLUSTERED ( [searchId] ASC )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY + = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY] ) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY] GO select max(len(mysql)) from T_Search --10516
My questions are: 1. how to debug this question? 2. What's wrong? Thanks!

Replies are listed 'Best First'.
Re: DBIx can't read SQL server 2008 varchar(max) column
by mje (Curate) on Jun 13, 2014 at 07:55 UTC

    Forget the ODBC tracing for the moment. If you have a recentish DBI and DBD::ODBC set DBI_TRACE=DBD=trace.log, export it (if unix shell) and rerun. What is in trace.log?

    If you haven't got a recentish DBI/DBD::ODBC set DBI_TRACE=15=trace.log. There will be more output but alot of it will be irrelevant.

Re: DBIx can't read SQL server 2008 varchar(max) column
by sundialsvc4 (Abbot) on Jun 12, 2014 at 13:58 UTC

    Hmmm... don’t see it right-away, but is there anything in that ODBC trace-file?

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://1089630]
Approved by boftx
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (4)
As of 2019-09-20 01:02 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    The room is dark, and your next move is ...












    Results (253 votes). Check out past polls.

    Notices?