Results 1 to 2 of 2
  1. #1
    Join Date
    May 2004
    Posts
    14

    Unanswered: Similar Oracle feature in Sybase

    Dear all,

    I'm a new user for Sybase
    Is there anyone whether there is any similar oracle feature in Sybase:-

    procedure exec_sql(intext varchar2)
    begin
    EXECUTE IMMEDIATE intext;
    end;

    Then I can call this sp by:-
    execute exec_sql('delete from student');


    So that I can create a procedure which can execute any sql statement passed in.

    Regards,

    Thomas HO

  2. #2
    Join Date
    Jul 2004
    Posts
    1
    You can do this with the exec keyword; see example below. But, in general I would not recommend doing this because you lose the primary benefit of creating the stored procedure which is the precompilation of the query plan.



    create procedure exec_sql
    @pCMD varchar(255)
    as
    begin
    exec (@pCMD)
    end
    go


    To test this proc, try executing:
    exec exec_sql "select getdate()"




    Quote Originally Posted by thomasmsho
    Dear all,

    I'm a new user for Sybase
    Is there anyone whether there is any similar oracle feature in Sybase:-

    procedure exec_sql(intext varchar2)
    begin
    EXECUTE IMMEDIATE intext;
    end;

    Then I can call this sp by:-
    execute exec_sql('delete from student');


    So that I can create a procedure which can execute any sql statement passed in.

    Regards,

    Thomas HO

Posting Permissions

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