fix #565: read ORDS vector body stream once
This commit is contained in:
@@ -48,19 +48,24 @@ BEGIN
|
||||
p_source => q'!
|
||||
DECLARE
|
||||
v_rows SYS_REFCURSOR;
|
||||
v_body_text CLOB;
|
||||
v_embedding_text VARCHAR2(32767);
|
||||
BEGIN
|
||||
cb_ords_handler_pkg.set_vpd_context(:auth_header);
|
||||
|
||||
-- ORDS exposes :body_text as a stream bind. Read it exactly once; referring
|
||||
-- to the stream bind twice causes ORA-17270 (Duplicate stream parameter).
|
||||
v_body_text := :body_text;
|
||||
|
||||
-- JSON_QUERY accepts a numeric JSON array. The JSON_VALUE fallback also
|
||||
-- permits clients that send the vector as the text "[0.1,0.2,...]".
|
||||
v_embedding_text := JSON_QUERY(
|
||||
:body_text,
|
||||
v_body_text,
|
||||
'$.embedding' RETURNING VARCHAR2(32767)
|
||||
);
|
||||
IF v_embedding_text IS NULL THEN
|
||||
v_embedding_text := JSON_VALUE(
|
||||
:body_text,
|
||||
v_body_text,
|
||||
'$.embedding' RETURNING VARCHAR2(32767)
|
||||
);
|
||||
END IF;
|
||||
|
||||
Reference in New Issue
Block a user