--- title: "Merging APEX Working Copies with APEXlang" date: 2026-07-24 description: A practical workflow for combining parallel Oracle APEX development by using working copies, APEXlang, and SQLcl together. tags: - oracle-apex - apexlang - sqlcl - git --- Two developers make different changes to the same Oracle APEX application. One branch is merged into the repository, but another version of the application is still active in the APEX workspace. Both streams contain valuable work, and some of the changes affect the same page. How do we combine them without losing either developer's work? I demonstrated one approach during an APEX Instant Tips broadcast. The technique uses three capabilities together: - APEX working copies preserve and compare application state. - APEXlang makes conflicting page definitions editable as source. - SQLcl validates and imports the reconciled application. The result is a practical workflow for resolving application drift and merging parallel development, including cases where both developers changed the same page.
## The demo application The demo uses application 120, a deliberately small application that makes each change easy to see. The original version has a blue region on page 1 containing the text: > I am blue like the sky. Selecting it opens a picture of the sky on page 2. I will call this the **Blue version**. Another developer has changed the same application independently. Their version has a yellow region on page 1. Selecting it opens a picture of wheat on page 3. I will call this the **Yellow version**. The desired result must retain both sets of behavior: - the Blue region, page 2, and `sky.jpg`; and - the Yellow region, page 3, and `wheat.jpg`. The separate pages and static files are straightforward. The complication is page 1, because both developers changed it. ## Step 1: Preserve the current application as a working copy Before importing the incoming Yellow version, create a working copy of the current application and name it **Blue**. At this point, the working copy and the main application are identical. The working copy is a preserved APEX-side snapshot of the Blue stream of work. This step should happen before replacing the main application. If the current application contains changes that exist nowhere else, verify that the working copy was created successfully before continuing. ## Step 2: Import the incoming version as the main application Use SQLcl `apex import` to install the incoming application from the repository into the same workspace as the new main application. In this workflow, importing the application replaces the main application while leaving the existing Blue working copy available. After the import: - the Blue version is preserved as the working copy; and - the incoming Yellow version is installed as the main application. Run the application and confirm that the incoming behavior is present. In the demo, page 1 is now yellow, and its action opens the wheat image on page 3. ## Step 3: Compare the working copy with the main application Open the Blue working copy and select **Compare with Main**. The comparison identifies the two kinds of changes we need to handle: | Component | Blue working copy | Yellow main application | Conflict? | |---|---|---|---| | Static file | `sky.jpg` | `wheat.jpg` | No | | Separate page | Page 2 | Page 3 | No | | Shared page | Blue changes on page 1 | Yellow changes on page 1 | Yes | Page 2, page 3, and the two images are independent changes. The normal working-copy merge can preserve them. Page 1 requires more care. Its comparison shows differences in regions, buttons, dynamic actions, and other page components. Choosing either complete version of the page would discard some of the other developer's work. ## Step 4: Reconcile the conflicting page in APEXlang This is where APEXlang changes the workflow. Open the page 1 APEXlang source for the incoming Yellow version in Visual Studio Code. Add the required Blue components to that source: in this example, the Blue region, button, and dynamic action. The Yellow source becomes the base, and the Blue changes are applied deliberately to it. The resulting page definition contains both streams of work. This is a semantic merge rather than a blind text merge. Review the component structure and relationships carefully. In particular, check that: - component identifiers and names do not collide; - buttons still target the correct dynamic actions; - region and item references remain valid; - page-level processing order is intentional; and - both developers' behavior is represented in the combined source. ## Step 5: Validate and import the reconciled source Validate the updated APEXlang before importing it: ```sql apex validate -input