locked
Oracle dynamic SQL RRS feed

  • Question

  • User926484134 posted

    hi there,

    trying to do a simple sp which will take tablename, where condition, and fieldname , will return data into out parameter.

    1) Please tell a way to do so.

    2) Is it beneficial to write a SP for such calls? under what circumstances?, like i dont want other ppl to analyse my code and see what i am doing so i insist in coding SP's

    create or replace
    procedure getvalue
    (
    tblname in varchar2
    , field in varchar2
    , condition in varchar2
    , val out varchar2
    ) as
    begin
    declare com varchar2(200);
    com := '
    BEGIN
    SELECT :P1
    INTO :P2
    FROM :P3
    WHERE :P4
    END';
    EXECUTE IMMEDIATE COM USING field,VAL,tblname,condition;
    end getvalue;

    Tuesday, April 2, 2013 10:45 PM

Answers

  • User926484134 posted

    finally got the answer .....

    create or replace
    procedure getvalue
    (
    tblname in varchar2
    , field in varchar2
    , condition in varchar2
    , val out varchar2
    ) as
    com varchar2(200);
    begin
    com := ' BEGIN
    SELECT :P1
    INTO :P2
    FROM :P3
    WHERE :P4
    END';
    EXECUTE IMMEDIATE COM USING field,VAL,tblname,condition;
    end getvalue;

     

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, April 3, 2013 1:12 AM

All replies

  • User926484134 posted

    finally got the answer .....

    create or replace
    procedure getvalue
    (
    tblname in varchar2
    , field in varchar2
    , condition in varchar2
    , val out varchar2
    ) as
    com varchar2(200);
    begin
    com := ' BEGIN
    SELECT :P1
    INTO :P2
    FROM :P3
    WHERE :P4
    END';
    EXECUTE IMMEDIATE COM USING field,VAL,tblname,condition;
    end getvalue;

     

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, April 3, 2013 1:12 AM
  • User-1280676833 posted

    Congratulations! Im glad to hear that you have solved this issue by yourself. Welcome to post your question on here in the future programming.

    Regards

    Thursday, April 25, 2013 11:29 PM