Advise Needed - Trying to get Results of a SQL Command

Post

Posted
Rating:
#1 (In Topic #1563)
Enthusiast
AndyGable is in the usergroup ‘Enthusiast’
Hello Everyone on the Forum,

I am in need of some wisdom from someone.

I have the following SQL Command

UPDATE journalroll SET journalentry = Replace(journalentry, '?ú', '£') WHERE INSTR(journalentry, '?ú');

When I run it with in my Gambas App I don't get any results back but If I run it in the HeidiSQL interface it reports
back to me 4,278 rows affected

How Do I capture the affected rows and show it on screen?  I did think to try the following

Code (gambas)

  1. SQLCommand = "UPDATE journalroll SET journalentry = Replace(journalentry, '?ú', '£') WHERE INSTR(journalentry, '?ú');"
  2.     Dim ResultData As Result = Global.$DBBackOfficeCon.Exec(SQLCommand)
  3.  
  4.     Debug ResultData.Count
  5.  
  6.     If Error Then ErrorMessagesToShow &= Error.Text & gb.NewLine

but in the Debug panel  get a 0

IF Someone has a better way of remove the ?ú and replacing it with a £ I am willing to update my code as I would like to keep the database as clean as I can.

I look forward to hearing from you all with your idea's

Andy
Online now: No Back to the top

Post

Posted
Rating:
#2
Avatar
Administrator
sholzy is in the usergroup ‘unknown’
In the process of creating our new website I have to clean up the the database to remove over 40 different tags in 11000+ posts that phpbb injects into the posts before I can do an import into the new db. I broke down the process into 3 separate steps:
1. reading the database and assigning the offending database field to a variable
2. cleaning up the data
3. writing the cleaned up data back into the database

Each step is a separate routine. I did it this way to make it easier to keep the thought process in my head clear and to make debugging easier.

It looks like you are combining steps 2 and 3 together.

My step 2 is straight forward:

Code (gambas)

  1. sPost_Text = Replace$(sPost_Text, "<r>", "")
  2. ' I have 40+ of these to pass sPost_Text through
"sPost_Text" is the variable to hold the field data I'm changing. Once I've cleaned up the data in sPost_Text, I pass sPost_Text onto writing the data back into the database.

My step 3 is:

Code (gambas)

  1. MGlobal.hDB.Begin
  2. sCriteria = "post_id = &1"
  3. MGlobal.hResData = MGlobal.hDB.Edit("phpbb_posts", sCriteria, iRecordID)
  4. MGlobal.hResData!post_text = sPost_Text
  5. MGlobal.hResData.Update()
  6. MGlobal.hDB.Commit
(MGlobal is a module where I store my global variables.)

sholzy
Gambas One Site Director

To report bugs in the Gambas IDE:
Official Gambas Bug Tracker
Online now: No Back to the top
1 guest and 0 members have just viewed this.