Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

How To Represent varchar(max) in DBIx::Class

by phildeman (Scribe)
on Jan 08, 2018 at 00:40 UTC ( [id://1206870]=perlquestion: print w/replies, xml ) Need Help??

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

I am using SQL Server, and I can't find any documentation on how to define the syntax that will address varchar(max).

For example:

__PACKAGE__->table( 'myTable' ); =head ACCESSORS =head2 id data_type: 'integer' is_nullable: 0 =head2 title data_type: 'varchar' is_nullable: 0 size: 200 =head2 Description data_type: 'varchar' is_nullable: 1 size: max =cut __PACKAGE__->add_columns( "id" { data_type => "integer", is_nullable => 0 } "title" { data_type => "varchar", is_nullable => 0, size => 200 } "Description" { data_type => "varchar", is_nullable => 1, size => max } ); __PACKAGE__->set_primary_key("id");

I get the following error when attempting to run perl -wc app.pm:

Bareword "max" not allowed while "strict subs" in use at mydbapp.pm

I attempted to use dbcidump to build the database package, but ran into difficulties with SQL Server.
So, I build the package myself, based previous DBIx::Class database packages for SQL Server.

Is there any one with experience on this issue that can guide me. Thanks.

Replies are listed 'Best First'.
Re: How To Represent varchar(max) in DBIx::Class
by 1nickt (Canon) on Jan 08, 2018 at 01:44 UTC

    Hi, try

    { data_type => "varchar", is_nullable => 1, size => "max" } # ^ ^
    ... that's what the Perl error is reporting.

    That may lead to a DBIx::Class error, I don't know whether the syntax is supported.

    I wasn't familiar with VARCHAR(MAX) so I looked it up; it seems it's not recommended except in the specific case of having data of potentially large size (e.g. VARCHAR(MAX) vs VARCHAR(255)). Is that your case?

    Hope this helps!



    The way forward always starts with a minimal test.

      Yep, that worked. That is it got rid of the error. However, regarding you point about
      varchar(max) not being supported, I read that too. I will see if it works. If not, I will see if
      my DBA can change the data size to accommodate this package.

      Thanks again for your help.

      -Phil-

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others browsing the Monastery: (4)
As of 2024-04-24 03:19 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found