Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

MQSERIES-ORACLE Wrapper Function

Status
Not open for further replies.

ramlakshman

Technical User
Sep 28, 2001
7
SG
Hi,

I have created the following mq.c
#include <stdio.h>
#include <cmqc.h>

void ConnectQ(PMQCHAR QmgrName,PMQHCONN Qhandle,PMQLONG Comp,PMQLONG Reason)
{
PMQCHAR Qmgrname;
strcpy(Qmgrname,QmgrName);
MQCONN(Qmgrname,Qhandle,Comp,Reason);
}

void DisconnectQ(PMQHCONN Qhandle,PMQLONG Comp,PMQLONG Reason)
{
MQDISC(Qhandle,Comp,Reason);
}

which is a wrapper function for MQSERIES

then I compiled like this

uidpwd=/

cc -Ae +z +DAportable -I/ram/mqseries -c mq.c -o mq.o -lmqm -L$ORACLE_HOME/lib/ -lclntsh `cat $ORACLE_HOME/lib/sysliblist` -lsql8

ld +s -b -o mq.so mq.o -L/usr/lib -L$ORACLE_HOME/lib/ -lclntsh `cat $ORACLE_HOME
/lib/sysliblist` -lsql8 -L/rrtsreg1/bin

My directory is having the full permission for the oracle user

This is my library

CREATE OR REPLACE LIBRARY mqora IS '/ram/mqseries/mq.so';

This is my procedure

CREATE OR REPLACE PROCEDURE ConnectQ(QMgrName IN varCHAR2,
Qhandle OUT binary_integer,
CompCode OUT binary_integer,
ReasonCode OUT binary_integer)
IS EXTERNAL
NAME &quot;ConnectQ&quot;
LIBRARY mqora
PARAMETERS (QMgrName BY REFERENCE,
Qhandle ,
CompCode ,
ReasonCode );


CREATE OR REPLACE PROCEDURE DisconnectQ(Qhandle IN binary_integer,
CompCode OUT binary_integer,
ReasonCode OUT binary_integer)
IS EXTERNAL
NAME &quot;DisconnectQ&quot;
LIBRARY mqora
PARAMETERS (Qhandle BY REFERENCE LONG,
CompCode ,
ReasonCode );

Now I am calling the function

set serveroutput on size 10000;
set linesize 256;
define csize=500


set verify off
declare
Qmgr char(48) := 'TEST.DV';
Qname char(48) := 'TEST.LISTEN';
hConn binary_integer;
CompCode binary_integer;
Reason binary_integer;
begin
ConnectQ(Qmgr,hConn,CompCode,Reason);
dbms_output.put_line('MQCONN: CompCode='||CompCode||' Reason='||Reason||hConn);
DisconnectQ(hConn,CompCode,Reason);
dbms_output.put_line('MQDISC: CompCode='||CompCode||' Reason='||Reason);
end;

I am getting the following error

declare
*
ERROR at line 1:
ORA-06520: PL/SQL: Error loading external library
ORA-06522: I/O error
ORA-06512: at &quot;OPS$PVCSLBR1.CONNECTQ&quot;, line 0
ORA-06512: at line 8

I don't now where I made the mistake.

If any one has already wrore a wrapper function please help me .

TIA
 
Hi,

In the LISTENER.ORA

LSNRextproc =
(ADDRESS_LIST=(ADDRESS=(PROTOCOL=IPC)(KEY=extproc))
SID_LIST_LSNRextproc =
(SID_LIST=(SID_DESC=(SID_NAME=extproc)
(ORACLE_HOME=/oracle/oracle/8.1.7.64)(PROGRAM=extproc)(ENVS=LD_LIBRARY_PATH=/opt/mqm/lib)))

TIA
 
Check the syntax for ENVS='abc=xyz; dec=lmn;'

There is quote required. Check out the values you are getting in progrm by getenv() call and print it for verification. Also ,you need more than just mqm/lib. Include /usr/lib or equivalent on your system for socket etc.

MiddlewareOnline.com IBM MQ Series Certified Consultants
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top