Hi Michael,
when I do a
$char_attrib = { ora_type => 5 };
$sth=$dbh->prepare("INSERT INTO test (x) values (?)");
$sth->bind_param(1,$str,$char_attrib);
$sth->execute;
I get a
DBD::Oracle::st execute failed: ORA-01461: can bind a LONG value only
for insert into a LONG column (DBD ERROR: OCIStmtExecute) at x.pl line
24.
at the execute command.
what do I do wrong???
thanks for help!
Harald
----- Original Message -----
From: "Michael A Chase" <[EMAIL PROTECTED]>
To: "Harald Meier" <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]>; "Tim Bunce"
<[EMAIL PROTECTED]>
Sent: Tuesday, October 16, 2001 9:43 PM
Subject: Re: trim trailing spaces when inserting varchar2
> Tim,
> I'm trying to remember if we discussed why the default ora_type for
> strings was changed from 5 to 1 so many moons ago. It looks to me that 1
is
> causing more trouble than 5 would and the problem appears on the list
every
> month or so. I feel that if someone really doesn't want trailing spaces
in
> their VARCHAR columns, they can trim them before feeding them to the
> database.
>
> Harald,
> This is the current default behavior for DBD::Oracle. The following is in
> the Oraperl docs (perldoc Oraperl), but also applies to DBD::Oracle. The
> ora_open() and ora_bind() subroutines are similar to the prepare() and
> execute() methods.
>
> ==== begin perldoc Oraperl ====
> DBD: Substitution variables are now bound as type 1 (VARCHAR2)
> and not type 5 (STRING) by default. This can alter the behaviour of
> SQL code which compares a char field with a substitution variable.
> See the String Comparison section in the Datatypes chapter of the
> Oracle OCI manual for more details.
>
> You can work around this by using DBD::Oracle's ability to specify
> the Oracle type to be used on a per field basis:
>
> $char_attrib = { ora_type => 5 }; # 5 = STRING (ala oraperl2.4)
> $csr = ora_open($dbh, "select foo from bar where x=:1 and y=:2");
> $csr->bind_param(1, $value_x, $char_attrib);
> $csr->bind_param(2, $value_y, $char_attrib);
> ora_bind($csr); # bind with no parameters since we've done
bind_param()'s
> ==== end perldoc Oraperl ====
>
> --
> Mac :})
> ** I normally forward private questions to the appropriate mail list. **
> Give a hobbit a fish and he eats fish for a day.
> Give a hobbit a ring and he eats fish for an age.
> ----- Original Message -----
> From: "Harald Meier" <[EMAIL PROTECTED]>
> To: <[EMAIL PROTECTED]>
> Sent: Monday, October 15, 2001 05:24
> Subject: trim trailing spaces when inserting varchar2
>
>
> > Hi All,
> >
> > when I do a
> >
> > $str="abc ";
> > $sth=$dbh->prepare("INSERT INTO test (x) values ( ? )");
> > $sth->bind_param(1,$str);
> > $sth->execute;
> >
> > the string will be cutted off to "abc".
> > is there a way to switch off this -feature- ?
> > i dont want any strings to be trimmed.
> >
> > I know about $str=$dbh->quote($str);
> > but I want something globally, not only for one string.
>
>