简体   繁体   中英

Passing a variable in Oracle APEX PL/SQL

I'm building a simple application in APEX. One of my pages is a report and for the region source I have some code to this effect. The error message I'm receiving is

ORA-00904: "var_out": invalid identifier

Essentially the variable :form_variable is coming from a search box, and I can pass that into the query string fine (ie replacing "variable" with ":form_variable", but I want to pass it into a function first and put that output into the string instead. I'm sure this is something simple but for the life of me I can't work out what to do.

DECLARE
variable VARCHAR2(10);
query VARCHAR2(1000);

-- Where var_out is an output
BEGIN
myfunction(:form_variable, var_out);
variable := var_out;

query := 'SELECT * FROM TABLE WHERE column = variable';

RETURN query;

END;

Thanks

You need to declare your out variable, var_out , in your declaration block.

    DECLARE
    var_out VARCHAR2(10);
    query VARCHAR2(1000);

    -- Where var_out is an output
    BEGIN
    myfunction(:form_variable, var_out);
    --variable := var_out;

    query := 'SELECT * FROM TABLE WHERE column = '''||var_out||'''';

    RETURN query;

    END;

Also, your query string is not doing any replacement in your example. You could concatenate it if your procedure myfunction output cleans the variable.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM