How to Call Native Procedure with Variables

Comments

3 comments

  • Comment actions Permalink
    Official comment
    Avatar
    Nick Golovin

    Hi Eralper, 

    the solution you posted certainly works, thank you. One thing one would need to care about in this case would be to make sure that all special characters like quote etc. in the parameters would be properly escaped. 

    Alternatively, you could use one of the following (Example for Postgres):

     

    call "PostgreSQL.native"(
    'select ? where 1=?','2',(select 1)
    );;

    or

    call "PostgreSQL.native"(
    "request" => 'select ? where 1=?',
    "variable" => array('2',(select 1))
    );;

    In this case, any special characters in the parameters would be escaped automatically. 

    Hope this helps,

    best regards,

    Nick

     

  • 0
    Comment actions Permalink
    Avatar
    Eralper Yilmaz

    Hello,

    Is there a sample procedure call script where parameters are passed as part of the native call?

  • 0
    Comment actions Permalink
    Avatar
    Eralper Yilmaz

    OK, a colleague suggested to use as follows; defining the parameter before calling the native procedure

     

    begin

    declare string country;
    country = 50000121;

    select
    *
    from
    (
    Call "HANA_B1P.native"
    (
    "request" =>'
    SELECT * FROM "system-local.bw.bw2hana::ASOPCSD"
    where asserorgc = '|| country ||'
    '
    )
    ) as a;

    end;;

Please sign in to leave a comment.

Powered by Zendesk