a good doctor is the best solution for that.
Texas Joe, pain in joints during sleep are usually in my experience muscular cramps that pull on age weakened tendons and ligaments in knees, hip and arms. You might try getting out of bed have a cool glass of water and go back to bed in different position. Sweet dreams are made of this.