I have never heard someone with stomach ulcers were prescribed colonoscopy. Colonoscopy is not going to reach your stomach. Endoscopy will. Also none of these procedures will hurt your stomach.
Why are you obsessed with fasting? I recall that we exchanged a few ideas to heal your ulcers. You should include probiotics with your meals to balance stomach and gut flora.
Fasting will not interfere with Endoscopy or Colonoscopy.