You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@openjpa.apache.org by Patrick Linskey <pl...@gmail.com> on 2007/09/06 23:11:52 UTC

DB2: CAST and VARCHAR

Hi,

Is it ever valid in DB2 to just do a 'CAST(? AS VARCHAR)', or must it
always be a 'CAST(? AS VARCHAR(<length>))'?

The current DB2 dictionary does the former; I'm working on some code
that puts a parameter into the SELECT clause, and to get that to work,
I need to make the CAST include the length information.  Should I be
changing the addCastAsType() method in DB2Dictionary, or just doing
the length bit in my particular situation?

-Patrick

-- 
Patrick Linskey
202 669 5907

Re: DB2: CAST and VARCHAR

Posted by Patrick Linskey <pl...@gmail.com>.
I've opened OPENJPA-354 and attached a potential patch. Please review
and let me know what you think.

-Patrick

On 9/6/07, catalina wei <ca...@gmail.com> wrote:
> Hi Patrick,
> Yes, <length> is required.
>
> I would suggest you use appendLength() method in DB2Dictionary for varchar
> type.
>
> Catalina
> On 9/6/07, Patrick Linskey <pl...@gmail.com> wrote:
> >
> > Hi,
> >
> > Is it ever valid in DB2 to just do a 'CAST(? AS VARCHAR)', or must it
> > always be a 'CAST(? AS VARCHAR(<length>))'?
> >
> > The current DB2 dictionary does the former; I'm working on some code
> > that puts a parameter into the SELECT clause, and to get that to work,
> > I need to make the CAST include the length information.  Should I be
> > changing the addCastAsType() method in DB2Dictionary, or just doing
> > the length bit in my particular situation?
> >
> > -Patrick
> >
> > --
> > Patrick Linskey
> > 202 669 5907
> >
>


-- 
Patrick Linskey
202 669 5907

Re: DB2: CAST and VARCHAR

Posted by catalina wei <ca...@gmail.com>.
Hi Patrick,
Yes, <length> is required.

I would suggest you use appendLength() method in DB2Dictionary for varchar
type.

Catalina
On 9/6/07, Patrick Linskey <pl...@gmail.com> wrote:
>
> Hi,
>
> Is it ever valid in DB2 to just do a 'CAST(? AS VARCHAR)', or must it
> always be a 'CAST(? AS VARCHAR(<length>))'?
>
> The current DB2 dictionary does the former; I'm working on some code
> that puts a parameter into the SELECT clause, and to get that to work,
> I need to make the CAST include the length information.  Should I be
> changing the addCastAsType() method in DB2Dictionary, or just doing
> the length bit in my particular situation?
>
> -Patrick
>
> --
> Patrick Linskey
> 202 669 5907
>