Bill and Bill,
   Thank you for your help.  It worked perfectly.
                                    Jason

Jason Kramer
University Archives and Records Management
002 Pearson Hall
(302) 831 - 3127 (voice)
(302) 831 - 6903 (fax)



Bill Eyring wrote:
Hey Jason,

Assuming your table column contains data such as C:\MYSUB\MyPic.jpg

Use this code;

Set v vcolname text=null
Set v voldtext text='jpg'
Set v vnewtext='png'
Drop cursor c#1
Declare c#1 cursor for select colname fro MyTable
Open c#1
Fetch c#1 into vcolname vi1
While sqlcode <> 100 the
  UPDATE MyTable set colname=(srpl(.vcolname,.voldtext,.vnewtxt,0)) whe
current of c#1
  Fetch c#1 into vcolname vi1
Endwhile
Drop cursor c#1
Return

If you want to test your code before you run it (remember to backup first !)
then use this code first;

Set v vcolname text=null
Set v voldtext text='jpg'
Set v vnewtext='png'
Set v vcolname2 text=null
Set v vmsg text=null
Drop cursor c#1
Declare c#1 cursor for select colname fro MyTable
Open c#1
Fetch c#1 into vcolname vi1
While sqlcode <> 100 the
  set v vcolname2=(srpl(.vcolname,.voldtext,.vnewtxt,0))
  --UPDATE MyTable set colname=(srpl(.vcolname,.voldtext,.vnewtxt,0)) whe
current of c#1
  set v vmsg=(.vcolname&.vcolname2)
pause 2 using .vmsg caption 'Testing Code' icon info Fetch c#1 into vcolname vi1
Endwhile
Drop cursor c#1
Return

Hope this helps !

Bill Eyring

Ps: University of Delaware looks better than University of  laware !

-----Original Message-----
From: [email protected] [mailto:[EMAIL PROTECTED] On Behalf Of Jason Kramer
Sent: Friday, December 05, 2008 4:23 PM
To: RBASE-L Mailing List
Subject: [RBASE-L] - UPDATE question

I have a table that has a list of file names as one of its columns. All of the file names are .jpg files, and we just converted to .png because
all the cool kids are using .png files for web design now (or so I'm told).
I am trying to figure out how to update the database so the file name in the
table will now have a .png extension.  Only the extension changed.  If the
old name was MyPic.jpg, the new name is MyPic.png.
    I think that I should use the UPDATE command with an expression, but I'm
not sure what expression to use.  In psudocode:

UPDATE mytable SET filename = (SMOVE(<current value in filename>,1,SLEN(<current value in filename>) - 3,'',1) + '.png') WHERE
filename IS NOT NULL

                                                 Thanks,
                                                 Jason



Reply via email to