
400 S.E.2d 742 (1991)
101 N.C. App. 699
John W. SCROGGS, Petitioner-Appellee,
v.
NORTH CAROLINA CRIMINAL JUSTICE EDUCATION AND TRAINING STANDARDS COMMISSION, Respondent-Appellant.
No. 9023SC642.
Court of Appeals of North Carolina.
February 19, 1991.
*743 Atty. Gen. Lacy H. Thornburg by Asst. Atty. Gen. Robin Perkins Pendergraft, Raleigh, for respondent-appellant.
Vannoy, Colvard, Triplett, Freeman & McLean by Howard C. Colvard, Jr., and Anthony R. Triplett, North Wilkesboro, for petitioner-appellee.
LEWIS, Judge.
On 18 December 1987 respondent sent a letter to petitioner notifying him that his law enforcement certification had been revoked because of alleged material misrepresentations in a Personal History Statement submitted on 31 December 1982 in his application for certification regarding his prior use of marijuana and other narcotics. The record shows that on 2 November 1982 petitioner had admitted to an investigating officer that he used drugs periodically during the course of four years from the age of 17 to the age of 21 and that he occasionally exchanged drugs for money with his friends, but had not used drugs for at least one year. In the Personal History summary submitted by the petitioner on 31 December 1982, petitioner wrote, in response to the question of whether he ever used marijuana or non-prescription drugs, that *744 he did so on a "teenage experimental basis." The record shows that respondent agency has had this information available to it since those dates in 1982 and that petitioner has an exemplary record as a police officer since his certification.
Appellant argues that the trial court erred in concluding that petitioner's substantial rights had been prejudiced by the revocation procedure because he did not receive opportunity for a hearing prior to the revocation of his license and hence did not receive proper notice. Appellant argues that the administrative hearing requirement of N.C.G.S. § 150B-38(b) is not triggered until after petitioner receives notice of revocation. We note that the statute states specifically that the agency shall give the parties an opportunity for hearing and notice "(p)rior to any agency action in a contested case." N.C.G.S. § 150B-38(b) (1986). In Lloyd v. Babb, 296 N.C. 416, 251 S.E.2d 843 (1979), the North Carolina Supreme Court defined a "contested case" as (1) an agency proceeding that (2) determines the rights of a party. Id. at 296 N.C. 424-25, 251 S.E.2d 850. In that case the Court held that a meeting of the state Board of Elections did not constitute a contested case because the Board did not, at the meeting in question, exercise any adjudicatory powers which affected the rights of the parties. Unlike the action of the State Board of Election in Lloyd v. Babb, supra, the action of the respondent in the present case both exercised an adjudicatory function in revoking the petitioner's license, and therein affected his rights. We hold that respondent's action constituted agency action on a contested case which affected the substantive rights of the petitioner. The petitioner was entitled to both notice and an opportunity to be heard prior to the revocation of his license.
Appellant argues that the reviewing court erred in concluding that respondent-commission's decision was arbitrary and capricious and thus prejudiced petitioner's substantial rights. The reviewing court's scope of review is set out in N.C. G.S. § 150B-51, which states in relevant part that the court may:
[r]everse or modify the agency's decision if the substantial rights of the petitioners may have been prejudiced because the agency's findings, inferences, conclusions or decisions are:
(1) In violation of consitutional provisions;
(2) In excess of the statutory authority or jurisdiction of the agency;
(3) Made upon unlawful procedure;
(4) Affected by other error of law;
(5) Unsupported by substantial evidence... in review of the entire record as submitted; or
(6) Arbitrary and capricious.
(1987). Our review of the Superior Court's determination under N.C.G.S. § 150B-52, is limited to whether the Superior Court made any errors in law in light of the record as a whole. Henderson v. N.C. Dept. of Human Resources, 91 N.C.App. 527, 372 S.E.2d 887, 890 (1988). The reviewing court concluded as a matter of law that the final revocation action was arbitrary and capricious because the respondent "had notice of the conduct complained of by it (for) approximately six years before taking action, in spite of the fact that the petitioner had an exemplary record during this period." Appellant argues that respondent was not, in fact, aware of the relevant information until 1987, at which time action was taken. The record, however, indicates that the respondent commission had received a memorandum detailing the extent of petitioner's drug use in November of 1982, and had access if not actual possession of all other necessary documents from 1982, since which petitioner has passed review both for probationary certification and general certification, and since which time petitioner's files have been subject to periodic review by appellant's representatives. In light of the passage of time since petitioner's original application, respondent's long-term access to the information, petitioner's exemplary service, and the fact that petitioner volunteered to the commission the extent of his drug use near the beginning of the process and prior to the submission of the 30 December 1982 personal history statement, we agree with the *745 reviewing court that the agency's decision was "arbitrary and capricious." Lewis v. Dept. of Human Resources, 92 N.C.App. 737, 740, 375 S.E.2d 712, 714 (1989).
Appellant argues that the reviewing court exceeded its authority by making erroneous findings at variance with the findings of the respondent, and by substituting its own judgment for that of the agency. Where the reviewing court determines that the findings of the agency are not supported by substantial evidence, the court may make findings at variance with those of the agency. Appeal of A.M.P. Inc., 287 N.C. 547, 561, 215 S.E.2d 752, 761 (1975). Our review of the record as a whole reveals that those findings of the reviewing court upon which the reviewing court reached its conclusions are supported by substantial evidence even where they are at variance with the findings of respondent agency. We hold that the reviewing court acted entirely within the scope of its authority as outlined by N.C.G.S. § 150B-51.
Affirmed.
ARNOLD and JOHNSON, JJ., concur.
