-- name: CreateDocumentCode :one
INSERT INTO document_codes (
    dccode
 ) VALUES (
    $1
 ) RETURNING *;

-- name: GetDocumentByCode :one
SELECT * FROM document_codes
WHERE dccode = $1 LIMIT 1;

-- name: CheckDocumentCode :one
SELECT EXISTS (
    SELECT 1 
    FROM document_codes 
    WHERE dccode = $1
) AS record_exists;


-- name: SearchDocumentCode :many
SELECT * FROM document_codes
WHERE LOWER(dccode) LIKE '%' || LOWER($1) || '%';
