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: John_McCarthy at WellspringRes dot com
Subject: RE:Updating only certain records in a query...
Date: Oct 28 1999 4:55PM

A cursor would be your best bet.  You didn't mention how your table is
organized.  For this to work, you must ensure that you process the rows in
some order that makes sense for using last non null value encountered.
Jack

> -----Original Message-----
> From:	Robert Banniza [SMTP:hunt127588@home.com]
> Sent:	Wednesday, October 27, 1999 8:03 AM
> To:	SybPerl Discussion List
> Subject:	Fwd: RE: Updating only certain records in a query...
> 
> I did forget to mention that the reason I can't just do the following:
> "update my_table set comment_type='hi mom' where comment_type is null"
> is b/c some comment_types DO have a value. Therefore, if I come to a
> comment_type with a value, I want to populate a variable and use that
> variable
> to update the subsequent nulls until I come to another record with a
> comment
> type of null where the variable will be re-populated with the new comment
> type.
> 
> Table looks like this:
> 
> comment_type
> ----------
> QA
> null
> null
> null
> UF
> null
> null
> 
> And I want to do this:
> 
> comment_type
> ----------
> QA
> QA
> QA
> QA
> UF
> UF
> UF
> 
> Thanks for any help.
> 
> Robert
> 
> ----------  Forwarded Message  ----------
> Subject: RE: Updating only certain records in a query...
> Date: Tue, 26 Oct 1999 22:49:39 -0600
> From: Rob Fenstermacher 
> 
> 
> maybe I'm not understanding the question, but how about something like
> 
> $ref = $d->ct_sql("select id from my_table where comment_type is
> null",\&my_routine);
> then update each row separately...
> 
> or maybe 
> $d->ct_execute("update my_table set comment_type='hi mom' where
> comment_type is null");
> if you want to set them all the same....
> 
> but, it is more likely that I am misunderstanding your question.
> 
> Have a good one
> 
> Robert
> 
> ---
> Robert Fenstermacher
> Conversion Specialists, Inc
> Denver, CO
> fence@bwn.net
> 
> ----------
> From: 	Robert Banniza[SMTP:hunt127588@home.com]
> Reply To: 	SYBPERL-L@listproc.net
> Sent: 	Tuesday, October 26, 1999 10:38 PM
> To: 	SybPerl Discussion List
> Subject: 	Updating only certain records in a query...
> 
> Guys,
> 	I'm trying to write some Sybperl using CTlib that uses $ref =
> $d->ct_sql("select id, comment_type from my_table", \&my_routine );
> As I grab each row of data, I'm using an if statement as a conditional to
> check whether to update that particular comment_type in that record. How
> would I go about doing this?? This query is more of a table scan to check
> for null values in comment_type. If comment_type eq null, I want to insert
> a
> value in comment_type. Could someone show me how to do this? I have tried
> many different ways but still haven't figured out the right solution.
> 
> Thanks,
> Robert
> 
> P.S. I have also looked at the solutions in /sybperl*/eg/ and couldn't
> find
> anything.