Results 1 to 2 of 2

Thread: Dynamic UPDATE

  1. #1
    Join Date
    Aug 2003
    Posts
    5

    Unanswered: Dynamic UPDATE

    Hi, I need to create a SP that let me execute a Dynamic UPDATE like :

    CREATE PROCEDURE EXAMPLE
    (IN ID_PAY INTEGER,
    IN C_SET VARCHAR(500)
    LANGUAGE SQL
    BEGIN

    EXECUTE INMEDIATE 'UPDATE PAYS ' || C_SET || ' WHERE
    ID = ' || ID_PAY;

    END;

    It does not work. I tried with EXEC SQL, making PREPARES but
    not work.
    The C_SET es a string that contains "SET " and severals fields that
    I want to UPDATE.

    Please help me.

  2. #2
    Join Date
    Jan 2003
    Posts
    4,292
    Provided Answers: 5

    Re: Dynamic UPDATE

    Try it like this:

    CREATE PROCEDURE EXAMPLE
    (IN ID_PAY INTEGER,
    IN C_SET VARCHAR(500)
    LANGUAGE SQL
    BEGIN
    DECLARE stmt varchar(1000); -- depends on how big IN parms are

    SET stmt = 'UPDATE PAYS ' || C_SET || ' WHERE
    ID = ' || ID_PAY;

    EXECUTE INMEDIATE stmt;

    END;



    Originally posted by cedutang
    Hi, I need to create a SP that let me execute a Dynamic UPDATE like :

    CREATE PROCEDURE EXAMPLE
    (IN ID_PAY INTEGER,
    IN C_SET VARCHAR(500)
    LANGUAGE SQL
    BEGIN

    EXECUTE INMEDIATE 'UPDATE PAYS ' || C_SET || ' WHERE
    ID = ' || ID_PAY;

    END;

    It does not work. I tried with EXEC SQL, making PREPARES but
    not work.
    The C_SET es a string that contains "SET " and severals fields that
    I want to UPDATE.

    Please help me.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •