Native Database Embedding with @DBFUNCTION
Oracle GoldenGate provides powerful transformation capabilities during data replication, including the ability to invoke database-resident functions through the @DBFUNCTIONconstruct. This feature enables organizations to integrate AI-driven processing—such as vector embedding generation—directly into the data replication pipeline, eliminating the need for separate post-processing steps and enabling true real-time AI data enrichment.
The @DBFUNCTION capability allows GoldenGate Replicat processes to execute database-side functions inline as data is applied to the target system. This means that as each transaction is replicated, additional logic—such as generating embeddings from text—can be executed within the database context. By embedding transformation logic directly into the replication stream, organizations can ensure that vector data is created synchronously with data ingestion, maintaining consistency and minimizing latency.
A typical real-time embedding workflow using GoldenGate and @DBFUNCTION proceeds as follows:
-
A source transaction is captured by the GoldenGate Extract process.
-
The change data is transmitted to the target environment using the GoldenGate trail file.
-
The Replicat process applies the transaction and invokes @DBFUNCTION to call a database-resident embedding function. In the following example, the
@DBFUNCTIONcall is actually calling a PL/SQL wrapper function that would perform the more complex embedding function. -
The embedding is generated in real time and stored in a target table, typically within a
VECTORcolumn for downstream AI and similarity search use cases. This tightly integrated flow ensures that embeddings are always synchronized with their corresponding source data while maintaining transactional consistency. The following example illustrates how@DBFUNCTIONcan be used within a GoldenGate mapping configuration to generate embeddings from text data:MAP schema.source_table, TARGET schema.target_table, COLMAP ( USEDEFAULTS, vector_col = @DBFUNCTION( OGGADMIN.CREATE_VECTOR(@AFTER.address, @AFTER.city) ) );
In this example, the OGGADMIN.CREATE_VECTOR function is executed for each replicated row, using the incoming data from address and city as input to transform raw text into a vector representation at apply time. The OGGADMIN.CREATE_VECTOR is going to embed the data. Common ways are through VECTOR_EMBEDDING() or DBMS_VECTOR.UTL_TO_EMBEDDING() package calls.
@DBFUNCTION Best Practices
To ensure efficient and reliable operation, several best practices should be followed when using @DBFUNCTION for real-time embedding. Embedding functions should be designed to be deterministic and highly performant, as they are executed within the replication path and can directly impact throughput.
Where possible, organizations should leverage Oracle AI Vector Search capabilities or invoke external AI services through optimized PL/SQL wrappers for embedding generation. Robust error handling and retry mechanisms should be implemented to address transient failures in embedding generation, particularly when external services are involved.
Finally, long-running or resource-intensive functions should be avoided or offloaded, as they can introduce replication lag and reduce overall system scalability.
Embedding pattern summary: choose @AISERVICE for external or GPU-backed inference, choose @DBFUNCTION for database-resident embedding logic, and consider asynchronous embedding when synchronous calls create apply lag.