pgvector examples for COBOL
Supports Open Cobol ESQL
Follow the instructions for your database library:
Enable the extension
EXEC SQL
CREATE EXTENSION IF NOT EXISTS vector
END-EXEC.
Create a table
EXEC SQL
CREATE TABLE items (
id bigserial PRIMARY KEY,
embedding vector(3)
)
END-EXEC.
Insert vectors
MOVE "[1,2,3]" TO EMBEDDING.
MOVE "[4,5,6]" TO EMBEDDING2.
EXEC SQL
INSERT INTO items (embedding)
VALUES (:EMBEDDING), (:EMBEDDING2)
END-EXEC.
Get the nearest neighbor
MOVE "[3,1,2]" TO EMBEDDING.
EXEC SQL
SELECT id INTO :NEAREST-ID FROM items
ORDER BY embedding <-> :EMBEDDING LIMIT 5
END-EXEC.
See a full example
Everyone is encouraged to help improve this project. Here are a few ways you can help:
- Report bugs
- Fix bugs and submit pull requests
- Write, clarify, or fix documentation
- Suggest or add new features
To get started with development:
git clone https://github.com/pgvector/pgvector-cobol.git
cd pgvector-cobol
createdb pgvector_cobol_test
ocesql example.cbl example.cob
export COBCPY=path/to/Open-COBOL-ESQL/copy
cobc -x -locesql example.cob
./example