PEPPLER.ORG
Michael Peppler
Sybase Consulting
Menu
Home
Sybase on Linux
Install Guide for Sybase on Linux
General Sybase Resources
General Perl Resources
Freeware
Sybperl
Sybase::Simple
DBD::Sybase
BCP Tool
Bug Tracker
Mailing List Archive
Downloads Directory
FAQs
Sybase on Linux FAQ
Sybperl FAQ
Personal
Michael Peppler's resume

sybperl-l Archive

Up    Prev    Next    

From: Oliver Scheit <oscheit at quoka dot com>
Subject: Re: searching through text field
Date: Jun 11 1999 2:43PM

thank you!
I figured it out - it works now.

Regards, Oli

Pochet Frédéric schrieb:

> Hello,
>
> First of all, you have to know that the text type in a sybase sql server is
> not a type like the other. The sybase string function doesn't work with text
> col (they are working on the first 255 character).
>
> You have 3 possibilities:
>         - retrieve all row in perl (thanks Michael) and test them with
> regexp
>         - having no text col but char col (keep out, the string "a_char_col
> like %blabla%" will be interpreted by perl. You have to write "a_char_col
> like \%blabla\%" or with the single quote as delimiter (saying perl not to
> interpret the string))
>         - having a second table with key word
>
> For the first solution, you 'll find below an example of how to get text
> col. see also the pod (perldoc sybperl).
>
>         $dbh->ct_execute("select id, not_a_text_col, a_text_col from
> my_table"); ## keep out, all text col have to be the last col of the select
> clause.
>
>         while($dbh->ct_results($restype,0) == CS_SUCCEED)  { ## 0 = not to
> bind text col
>           next unless($dbh->ct_fetchable($restype));
>           while(@row = $dbh->ct_fetch()) {
>              ($ret, $a_text_col) = $dbh -> ct_get_data(3); ## 3 = col num in
> the select
>                 some action
>           }
>         }
>
> Best regard
>
> F.Pochet
>
> > ----------
> > De :  Oliver Scheit[SMTP:oscheit@quoka.com]
> > Répondre à :  SYBPERL-L@listproc.net
> > Date :        jeudi 10 juin 1999 14:36
> > A :   SybPerl Discussion List
> > Objet :       searching through text field
> >
> > Sorry to bother you, but I've got this stupid problem:
> >
> > I want to search through a text field in a table using the "like
> > %somestring%" method.
> > I read about the "readtext"-sql-statement, but I don't understand it.
> >
> > Here's what I want to do: (using Sybperl::CTLib)
> >
> > $query = $q->ct_sql( " select * from mytable where textcol like
> > '%searchstring%' " ) ;
> >
> > now, "textcol" is of the type text.
> > How do I have to change my code so it'll work ?
> >
> > Regards, Oli
> >