Michael Peppler
Sybase Consulting
Sybase on Linux
Install Guide for Sybase on Linux
General Sybase Resources
General Perl Resources
BCP Tool
Bug Tracker
Mailing List Archive
Downloads Directory
Sybase on Linux FAQ
Sybperl FAQ
Michael Peppler's resume

sybperl-l Archive

Up    Prev    Next    

From: =?iso-8859-1?Q?Pochet_Fr=E9d=E9ric?= <Frederic dot Pochet at cockerill-sambre dot com>
Subject: RE: searching through text field
Date: Jun 11 1999 2:29PM


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
	- 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

	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


> ----------
> De : 	Oliver Scheit[]
> Répondre à :
> 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