Sample MQ messaging code
This topic contains sample SQL statements that you can run in the stores_demo database, using DB-Access.
The sample statements are for one queue manager. However, you can use multiple queue managers.
begin;
select MQSEND ('lser.qm1', 'IDS.DEFAULT.POLICY',
TRIM(fname) || ' ' || TRIM(lname) || '|'
|| TRIM(company) || ', ' || TRIM(address1) || ', '
|| TRIM(NVL(address2,"")) || ', ' || TRIM(city) || ', '
|| state || ', ' || zipcode || '|' || TRIM(phone) || '|' ,
state)
from customer;
select MQSEND ('lser.qm1', 'IDS.DEFAULT.POLICY',
stock_num || '|' || manu_code || '|' || TRIM(description)
|| '|' || unit_price || '|' || unit
|| '|' || TRIM(unit_descr) || '|' ,
manu_code)
from stock;
commit;
select first 3 MQREAD('lser.qm1') from systables;
begin;
execute function MQREAD('lser.qm1','IDS.DEFAULT.POLICY','AZ');
rollback;
begin;
execute function MQREAD ('lser.qm1');
execute function MQREAD ('lser.qm1');
execute function MQRECEIVE ('lser.qm1');
execute function MQRECEIVE ('lser.qm1');
rollback;
begin;
select first 5 MQREAD ('lser.qm1') from systables;
select first 5 MQREAD ('lser.qm1') from systables;
select first 1 MQRECEIVE ('lser.qm1','IDS.DEFAULT.POLICY','AZ')
from systables;
select first 1 MQRECEIVE ('lser.qm1','IDS.DEFAULT.POLICY','HSK')
from systables;
rollback;
begin;
select first 5 MQREAD ('lser.qm1') from systables;
select first 5 MQREAD ('lser.qm1') from systables;
select first 1 MQRECEIVE ('lser.qm1','IDS.DEFAULT.POLICY','AZ')
from systables;
select first 1 MQRECEIVE ('lser.qm1','IDS.DEFAULT.POLICY','HSK')
from systables;
commit;
execute function mqinquire('lser.qm1',20);
execute function mqinquire('lser.qm1',"MQIA_Q_TYPE");
execute function mqinquire('lser.qm1',3);
execute function mqinquire('lser.qm1',"MQIA_CURRENT_Q_DEPTH");
execute function mqhasmessage('lser.qm1');
execute function mqhasmessage('lser.qm1','IDS.DEFAULT.POLICY','CA');
execute function mqhasmessage('lser.qm1','IDS.DEFAULT.POLICY','XY');
execute function MQCreateVtiRead("qm0vti", "lser.qm1");
execute function MQCreateVtiReceive("qm0vtir", "lser.qm1");
execute function MQCreateVtiWrite("qm0vtiw", "lser.qm1");
execute function MQCreateVtiReceive("qm1vti", "lser.qm1");
insert into qm0vtiw(msg) values ("Informix Dynamic Server");
begin;
select skip 10 first 5 * from qm0vtir;
select * from qm1vti;
insert into qm1vti(msg) values ("Informix Dynamic Server");
select * from qm1vti;
commit;