Rockwell Automation RSBizWare Administration Guide User Manual

Page 302

Advertising
background image

Appendix D Application notes for FactoryTalk Transaction Manager

INSERT INTO my_int_table values (31,32,33,34)

INSERT INTO my_int_table values (41,42,43,44)

INSERT INTO my_int_table values (5001,5002,5003,5004)

INSERT INTO my_int_table values (6001,6002,6003,6004)

INSERT INTO my_int_table values (7001,7002,7003,7004)

INSERT INTO my_int_table values (8001,8002,8003,8004)

INSERT INTO my_int_table values (9001,9002,9003,9004)

INSERT INTO my_int_table values (10001,10002,10003,10004)

CREATE PROCEDURE chunk_maker(@in_number int, @out_binary
VARBINARY(8) OUT)

AS

DECLARE

@val1 INT,

@val2 INT,

@val3 INT,

@val4 INT,

@binary1 VARBINARY(2),

@binary2 VARBINARY(2),

@binary3 VARBINARY(2),

@binary4 VARBINARY(2)

BEGIN

--------------------------------------------------------------

-- Note: This procedure only accepts positive integers. You may
modify the

-- upper word of each integer for negative integer values.

--------------------------------------------------------------

--------------------------------------------------------------

-- The following code illustrates how the substring is combined:

--------------------------------------------------------------

SELECT @val1=int1, @val2=int2, @val3=int3, @val4=int4

FROM my_int_table

WHERE record_row = @in_number

SELECT @binary1 = @val1, @binary2 = @val2, @binary3 = @val3,
@binary4 = @val4

-- The following code illustrates how the substring is combined
in reverse order

-- for byte swapping. Two substrings are created for each varbinary
that has

-- the value of the integers, then all the varbinaries are
concatenated.

SELECT @out_binary =
(SUBSTRING(@binary4,2,1)+SUBSTRING(@binary4,1,1))+(SUBSTRING(@
binary3,2,1)+SUBSTRING(@binary3,1,1))+(SUBSTRING(@binary2,2,1)
+SUBSTRING(@binary2,1,1))+(SUBSTRING(@binary1,2,1)+SUBSTRING(@
binary1,1,1))

END-- proc

302

Rockwell Automation Publication BZWARE-IN001M-EN-P-June 2014

Advertising