Skip to Main Content
  • Questions
  • How do I call MySQL Stored Procedure from oracle using HS link ?

Breadcrumb

Question and Answer

Connor McDonald

Thanks for the question, ar.

Asked: January 07, 2017 - 10:16 am UTC

Last updated: January 08, 2017 - 11:46 am UTC

Version: 11gR2

Viewed 1000+ times

You Asked

How do I call MySQL Stored Procedure from oracle using HS link ?
HS link is correct and I can get the tables data just by adding '@' at the end of the table name ,but I can't call the SP same way !
Help please.

and Connor said...

Check out whether you can use DBMS_HS_PASSTHROUGH for this. The intent of this package is that it simply passes a statement through to the remote datbaase.

https://connormcdonald.wordpress.com/2012/07/18/dbms_hs_passthroughthe-magic-package/

I have not tried it for MySQL stored procs.

Rating

  (1 rating)

Is this answer out of date? If it is, please let us know via a Comment

Comments

MySQL Stored Procedure from oracle using HS link

Mark Battle, March 25, 2019 - 11:38 am UTC

Hi,
this site has a simple case.
I have a procedure on MySQL with an OUT parameter.

I can't obtain the OUT parameter. I have an error: "Internal error on heterogeneous remote agent".

There's no example on Oracle documentation nor internet.

I've tried a lot of things with the code I attach below. I replaced the "?" by a "@variable_name" too.

Can you help me, please?

Thanks!!



MySQL Procedure:

sp_proc_do_something(

<{OUT pIdOut int}>

<{IN pCodeIn varchar(45)}>

<{IN pCodeIn2 tinyint}>

<{IN pText varchar(250)}>

);



My call on Oracle:

DECLARE

vSql VARCHAR2(32767);

l_cursor BINARY_INTEGER;

vId NUMBER;

vFecth number;

BEGIN



vSql :='CALL sp_proc_do_something(

?,

''00001'',

1,

''message'');';



l_cursor := DBMS_HS_PASSTHROUGH.open_cursor@DataBaseRemote;



DBMS_HS_PASSTHROUGH.parse@DataBaseRemote(l_cursor,vSql);



DBMS_HS_PASSTHROUGH.BIND_OUT_VARIABLE@DataBaseRemote(l_cursor, 1, vId);



vFecth := DBMS_HS_PASSTHROUGH.EXECUTE_NON_QUERY@DataBaseRemote(l_cursor);



DBMS_HS_PASSTHROUGH.get_value@DataBaseRemote(l_cursor, 1, vId);



dbms_output.put_line('vId: ' || vId);



DBMS_HS_PASSTHROUGH.close_cursor@DataBaseRemote(l_cursor);



commit;



EXCEPTION

WHEN OTHERS then

IF (l_cursor IS NOT NULL) THEN

DBMS_HS_PASSTHROUGH.CLOSE_CURSOR@DataBaseRemote(l_cursor);

END IF;

rollback;

raise_application_error(-20000, substr(sqlerrm || DBMS_UTILITY.FORMAT_ERROR_BACKTRACE, 1, 2000));

END;

More to Explore

PL/SQL demos

Check out more PL/SQL tutorials on our LiveSQL tool.

PL/SQL docs

PL/SQL reference manual from the Oracle documentation library