A calendar of events involving the building of the Stines’ house reveals the following facts:
Godwin Building Supply Company, Inc. [hereinafter referred to as Godwin] furnished materials for the construction of the house, but did so only with the understanding that the materials were charged to both Satterwhite and the Stines. The bills for materials furnished were not paid. On 11 April 1979, Satterwhite brought an action, case No. 79CVS2219, against the Stines for materials and labor totaling $22,267.80. The Stines answered with a general denial, but admitted the contract between themselves and Satterwhite.
Thereafter, on 24 May 1979, Godwin brought an action, case No. 79CVS3172, against both the Stines and Satterwhite for $15,726.19 in building materials furnished for the construction of the house, filed a materialman’s lien, and sought foreclosure. The Stines filed an answer which denied the debt. Satterwhite’s answer alleged that he was agent for the Stines in purchasing the materials and denied personal liability. In the same action, Satter-white filed a cross-claim against the Stines for a $4,500 supervision fee due him under the construction contract. The Stines denied liability to Satterwhite.
On 21 May 1980, the Stines brought an action, case No. 80CVS3121, against Satterwhite alleging breach of contract and negligence in the construction of the house, seeking $25,000 in damages. In his answer, Satterwhite denied the Stines’ allegations and moved to dismiss the action on two grounds: (1) that the complaint failed to state a claim upon which relief can be granted, pursuant to G.S. 1A-1, Rule 12(b)(6), and (2) for failure to bring the action as a compulsory counterclaim in either case No. 79CVS2219 or case No. 79CVS3172.
*610Satterwhite moved to consolidate case No. 79CVS2219 and case No. 79CVS3172 on 5 March 1980. Judge Farmer allowed the motion on 26 November 1980. Thereafter, on 5 December 1980, the Stines moved to amend their answer in case No. 79CVS2219 to add a counterclaim seeking damages. The Stines then alleged major defects in the house which were not known to them, and which could not have been known to them, at the time they filed their original answer in case No. 79CVS2219. The motion to amend was supported by the Stines’ affidavit.
Judge Godwin denied Satterwhite’s motion to dismiss the Stines’ complaint in case No. 80CVS3121 on 27 January 1981, and on the same day, consolidated case No. 79CVS2219 with case No. 80CVS3121. Also, on 28 January, the Stines withdrew their motion in case No. 79CVS2219 to amend and add a counterclaim, which would allege substantially the same facts as did their action against Satterwhite, case No. 80CVS3121. Thereafter, on 3 June 1981, Satterwhite moved for summary judgment against the Stines in case No. 80CVS3121.
On 23 February 1981, Satterwhite moved for summary judgment in case No. 79CVS3172, supporting his motion with an affidavit to establish that he acted as the Stines’ agent in the purchasing of building materials from Godwin. An affidavit in opposition to the motion was filed by Godwin which established that Satterwhite advised Godwin to charge materials he purchased to both the Stines and him. Judge Hobgood denied Satterwhite’s motion for summary judgment on 26 May 1981.
At the 15 June 1981 term of the superior court, a consent judgment was entered by Judge Preston in case No. 79CVS3172, which involved a claim by Godwin in the sum of $15,726.19, plus interest, for building supplies furnished for the job. In that case, Satterwhite had filed an answer and crossclaim setting out the contract between the Stines and Satterwhite, alleging agency for the Stines by him in the purchase of building supplies, and claiming $4,500 for services rendered by him in supervising the construction of the house. Judge Preston made findings of fact that all matters in controversy among Godwin, Satterwhite, and the Stines “raised by the complaint” in case No. 79CVS3172 have been compromised and settled by the parties. (Emphasis added.) Thereafter, the judge awarded judgment to Godwin against Sat-*611terwhite and the Stines jointly and severally in the sum of $15,726.19, and decreed the sum to be a lien upon the real estate in question. No disposition was made of the $4,500 claim by Sat-terwhite against the Stines.
Also during the 15 June 1981 term of superior court, the Stines made an oral motion to amend their answer in case No. 79CVS2219 and to allege a counterclaim. However, after reviewing the pleadings and hearing argument of counsel, Judge Preston, in his discretion, denied the Stines’ motion.
In the judgment entered on 18 June 1981, Judge Preston found (1) that all matters in controversy among Godwin, Satter-white, and the Stines in case No. 79CVS3172 were settled in the consent judgment filed on 15 June 1981, (2) that no genuine issue of material fact existed with respect to the liability of Satter-white to the Stines in case No. 80CVS3121, and with respect to the liability of the Stines to indemnify Satterwhite in case No. 79CVS3172 and case No. 79CVS2219, (3) that Satterwhite is thereby entitled to summary judgment in those cases, and (4) that “no just reason” exists for delaying entry of final judgment in each of the three cases. Thus, Judge Preston disposed of the three cases as follows: in case No. 80CVS3121, summary judgment was granted in favor of Satterwhite and against the Stines; in case No. 79CVS2219 and case No. 79CVS3172, summary judgment was granted in favor of Satterwhite against the Stines on the issue of indemnification and contribution among the parties for payment as provided in the consent judgment, and that Sat-terwhite recover of the Stines any sums which may be recovered against them by Godwin.
In summary, then, the three cases and other matters before us were disposed of as follows:
(1) A portion of case No. 79CVS3172 was settled by consent with both the Stines and Satterwhite jointly liable on any claim by Godwin, but leaving to be litigated the $4,500 claim by Satterwhite against the Stines for his supervision fee.
(2) In case No. 79CVS2219, such sums, if any, as may be recovered by Godwin against Satterwhite shall be recovered by Satterwhite from the Stines. That portion of *612the action dealing with labor performed and materials furnished by Satterwhite yet must be litigated, this being only a partial summary judgment.
(3) In case No. 80CVS3121, summary judgment was granted in favor of Satterwhite against the Stines dismissing the Stines’ claim for negligent construction and supervision by Satterwhite.
(4) All of the Stines’ motions to amend their answer in case No. 79CVS2219 to allege a counterclaim containing substantially the same facts as did their action against Satterwhite, case No. 80CVS3121, have been denied.
Both the Stines and Satterwhite appeal.
 We first address Satterwhite’s contention that Judge Godwin erred in denying his motion to dismiss the Stines’ action in case No. 80CVS3121 for failure to assert the claim as a compulsory counterclaim.
Rule 13(a) of the North Carolina Rules of Civil Procedure states, in pertinent part, as follows:
A pleading shall state as a counterclaim any claim which at the time of serving the pleading the pleader has against any opposing party, if it arises out of the transaction or occurrence that is the subject matter of the opposing party’s claim ....
[t]he purpose of Rule 13(a), making certain counterclaims compulsory, is to enable one court to resolve “all related claims in one action thereby avoiding a wasteful multiplicity of litigation . . . .” [Citations omitted.]
. . . [I]n order to give effect to the purpose of Rule 13(a) once its applicability to a second independent action has been determined, this second action must on motion be either (1) dismissed with leave to file it in the former case or (2) stayed until the former case has been finally determined.
*613Case No. 80CVS3121 was filed by the Stines on 21 May 1980. The basis of that action is the Stines’ discovery of “numerous defects” in the construction of their house, “many of which were hidden from a reasonable inspection by the methods of construction, which problems developed and been [sic] discovered subsequent to the alleged completion of construction of the residence.” The Stines further alleged that they “have now been forced to have substantial additional work done upon their residence to correct faulty, defective and [negligent] work . . . .” As noted above, Satterwhite moved to dismiss the complaint for failure to state a claim and for failure by the Stines to assert the action as a compulsory counterclaim in either case No. 79CVS2219 or case No. 79CVS3172. The Stines supported their verified complaint with an affidavit showing that they were not aware of the defects which had come to light since the filing of the “original lawsuit.” The affidavit was served on opposing counsel on the date of trial. G.S. 1A-1, Rule 56(c) states that “[t]he adverse party prior to the day of hearing may serve opposing affidavits.” We note that the Stines’ affidavit supported the verified complaint and in no way surprised Satterwhite. Hence, we find no prejudice.
The record does not reveal whether Judge Godwin treated Satterwhite’s motion to dismiss the Stines’ complaint for failure to state a claim by merely reviewing the pleadings, as is contemplated by G.S. 1A-1, Rule 12(b). See Sutton v. Duke, 277 N.C. 94, 176 S.E. 2d 161 (1970). However, it is obvious from a reading of the total record that Judge Godwin also considered the Stines’ affidavit. G.S. 1A-1, Rule 12(b) further provides as follows:
If, on a motion asserting the defense, numbered (6), to dismiss for failure of the pleading to state a claim upon which relief can be granted, matters outside the pleading are presented to and not excluded by the court, the motion shall be treated as one for summary judgment and disposed of as provided in Rule 56, and all parties shall be given reasonable opportunity to present all material made pertinent to such a motion by Rule 56.
Therefore, we find that Judge Godwin treated Satterwhite’s motion as a motion for summary judgment. Since the affidavit simply supported the Stines’ complaint and offered nothing as a surprise to Satterwhite, we find no error in treating the motion as one for summary judgment.
*614Satterwhite argues that case No. 80CVS3121 should have been dismissed since it constituted a compulsory counterclaim in one of the previous cases. We do not agree.
Where a cause of action, arising out of the transaction or occurrence that is the subject matter of the opposing party’s claim, matures or is acquired by a pleader after he has served his pleading, the pleader is not required thereafter to supplement his pleading with a counterclaim. Although G.S. 1A-1, Rule 13(e), permits the court to allow such supplemental pleading to assert a counterclaim, such supplemental pleading is not mandated and failure to do so will not bar the claim.
The verified complaint and supporting affidavit in case No. 80CVS3121 both assert that the defects in construction were hidden from a reasonable inspection by the methods of construction, and such defects had been discovered subsequent to the alleged completion of construction. Although the response to interrogatories reveals that the Stines may have known, or with diligence could have discovered, some of the defects, there were allegations of additional defective construction to substantiate the Stines’ complaint found after the institution of the previous cases. The Stines cannot be expected to plead that which they did not know, nor that which they were not able to reasonably ascertain with diligent inquiry. Hence, we find no error in the ruling by Judge Godwin denying Satterwhite’s motion to dismiss the Stines’ complaint.
We note that on two occasions the Stines moved to amend their answer in case No. 79CVS2219 and allege a counterclaim. In one instance, the Stines withdrew their motion after the judge refused to dismiss case No. 80CVS3121, and in another instance, they withdrew their motion when the judge refused to permit them to amend case No. 79CVS2219 to allege a counterclaim. Since Judge Godwin properly denied Satterwhite’s motion to dismiss case No. 80CVS3121 for the reasons set out above, the Stines properly withdrew their motion to amend their answer in case No. 79CVS2219 to allege a counterclaim.
*615  The same question is addressed by Judge Preston as a part of the judgment entered on 18 June 1981, wherein he acknowledged a review of the pleadings, affidavits, and interrogatories, and granted summary judgment in favor of Satterwhite and against the Stines in case No. 80CVS3121. Alleged errors by one trial judge should be corrected by appellate review and not by relitigation of the same issues by another trial judge. Carr v. Great Lakes Carbon Corp., 49 N.C. App. 631, 272 S.E. 2d 374 (1980), disc. rev. denied, 302 N.C. 217, 276 S.E. 2d 914 (1981). For the reasons set out above, we conclude that Judge Godwin committed no error in apparently treating Satterwhite’s motion to dismiss as a motion for summary judgment in case No. 80CVS3121 and in denying the motion on 27 January 1981. It was error for Judge Preston to reconsider this matter again on 18 June 1981.
However, the Stines may not complain that summary judgment was granted thereby compelling the Stines to indemnify Satterwhite for any sums recovered against Satterwhite by God-win because no prayer for relief is made by Satterwhite. The consent judgment established the amount due Godwin by the Stines and Satterwhite for materials delivered and used on the Stines’ property and on which property a materialman’s lien was created. The contract between the Stines and Satterwhite required the Stines to pay for material in construction Satterwhite had been compelled to permit billing in both his name and the Stines’ name in order to secure the materials for the Stines’ house. It is well established that the nature of the action and the relief to which the parties are entitled are to be determined by the facts alleged in the pleadings and established by the evidence, not by a prayer for relief. See generally 10 Strong’s N.C. Index 3d, Pleadings § 7, pp. 217-18.
Therefore, we reverse that portion of the judgment entered by Judge Preston on 18 June 1981 which granted summary judgment in favor of Satterwhite and against the Stines in case No. 80CVS3121, wherein Stines alleged breach of contract and negligence in performing the contract. We affirm that portion of Judge Preston’s judgment dated 18 June 1981 in case No. 79CVS2219 and case No. 79CVS3172 granting partial summary judgment in favor of Satterwhite and against the Stines on the issue of indemnification and contribution between the parties for *616the payment of the consent judgment entered on 15 June 1981 against both parties in favor of Godwin, and further ordering that Satterwhite shall have and recover of the Stines the full amount of any sums recovered against him by Godwin. After entry of judgment, there remains for disposition the following matters: (1) Satterwhite’s action against the Stines, case No. 79CVS2219, for (a) the cost of material and labor furnished by Satterwhite to the Stines in excess of the $15,726.19 covered in the consent judgment, and (b) the $4,500 fee for Satterwhite’s supervision of the construction of the Stines’ house, and (2) the Stines’ action against Satterwhite, case No. 80CVS3121, for negligence and breach of contract.
Our disposition of these cases is as follows:
As to Case No. 80CVS3121, reversed.
As to Case No. 79CVS2219 and Case No. 79CVS3172, affirmed in part as set out herein.
The cases are remanded for further disposition in accordance with this opinion.
Judge HEDRICK concurs in the result only.
Judge BECTON concurs in the result.