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: "Wechsler, Steven M" <WechslerSM at bernstein dot com>
Subject: RE: more text questions
Date: Jan 26 1999 10:19PM

Here's how I'm trying it (the CTlib option isn't available to me as all my
code uses DBLib):

Open connections $dbh_a and $dbh_b to the server
$dbh_a: 	create a new row in the table with the text column NULL
		call dbcmd("select char_column, numeric_column, 
			text_column from table where ...")
		call dbsqlexec;
		call dbresults;
		call dbnextrow;

$dbh_b:	call dbpreptext("table.column", $dbh_a, 3, length $complete_file)
		call dbsqlok;
		call dbresults;
		(while looping through $complete_file, use
dbmoretext(length($buffer), $buffer)
			 on 512 byte chunks until $complete_file has been
		call dbsqlok;
		cal dbresults;

Whenever I try this I get the error:
Msg 156, Level 15, State 1
Line 1
        Incorrect syntax near the keyword 'NULL'.
DB-Library error:
        General SQL Server error: Check messages from the SQL Server.

when calling the first dbsqlok to $dbh_b.

I also tried using dbwritetext and got the same error.

Any ideas?

Also, can you tell me why two connections to the server are required when
the C versions of the calls only use one?


Steve Wechsler/Senior DB Administrator/Sanford C. Bernstein & Co. 
"Never underestimate the power of human stupidity" - Lazarus Long
Support the Anti-SPAM amendment:

> -----Original Message-----
> From: Michael Peppler []
> Sent: Tuesday, January 26, 1999 4:45 PM
> To: SybPerl Discussion List
> Subject: more text questions
> >>>>> "Steve" == Wechsler, Steven M  writes:
> Steve> Why do dbpreptext/dbmoretext require the buffer size to be
> Steve> specified, while dbwritetext does not?  The documentation is
> Steve> unclear on this.
> The $size param to dbpreptext() tells DBlib the total size of 
> the TEXT 
> buffeer that is being sent, and the $size param to dbmoretext() tells
> DBlib the size of the current buffer. I realize now that the size
> param to dbwritetext() could have been omitted - I could have checked
> it in the procedure itself.
> Steve> What is the most straightforward way to write text to a text
> Steve> column?
> The simplest way is to use a regular insert statement using Client
> Library:
> $dbh->ct_sql(qq(insert the_text values($key, "$the_text")));
> THis works fine (modulo quote problems).
> Otherwise calling dbwritetext() is probably the simplest, 
> altough it's 
> by definition a two step process - you need to retrieve the TEXTPTR
> which is done internally by dbwritetext().
> I don't know if there is any advantage (apart from memory use) of
> using a multi-part insert instead of writing the whole buffer in a
> single call.
> Michael
> -- 
> Michael Peppler         -||-  Data Migrations Inc.
>       -||-
> Int. Sybase User Group  -||-
> Sybase on Linux mailing list: