create procedure ots_mx_assetcalresult(in asset_num char(60)) result(
SOURCE char(3),
C2301 date,
C2302 integer,
C2303 date,
C2304 integer,
C2306 date,
C2307 char(15),
C2309 numeric(12,2),
C2310 numeric(5,1),
C2311 numeric(5,1),
C2312 integer,
C2313 char(15),
C2314 char(12),
C2316 date,
C2320 char(80),
C2321 char(55),
C2322 char(1),
C2323 char(1),
C2324 numeric(5,1),
C2326 char(44),
C2327 char(15),
C2328 numeric(5,1),
C2329 char(44),
C2330 char(10),
C2331 char(1),
C2332 integer,
C2333 char(8),
C2334 char(8),
C2335 timestamp,
C2336 char(16),
C2337 timestamp,
C2338 char(16),
C2339 integer,
C2341 char(254),
C2362 integer,
C2308 char(10),
C2315 numeric(5,1),
C2342 date,
C2343 char(8),
C2317 numeric(5,1),
C2318 char(13),
C2319 char(1),
C2325 char(1),
C2350 integer,
C2351 integer,
C2352 integer,
C2353 integer,
C2354 char(64),
C2355 char(64),
C2356 char(64),
C2357 char(64),
C2358 char(64),
C2359 char(64),
C2360 char(64),
C2361 char(64),
C2363 char(1),
C2364 char(48),
C2365 char(48),
C2366 char(48),
C2367 char(48),
C2368 char(48),
C2369 char(48),
C2370 char(48),
C2371 date,
C2372 date,
C2373 date,
C2374 date,
C2375 numeric(12,2),
C2376 numeric(12,2),
C2377 numeric(12,2),
C2378 numeric(12,2),
C2379 numeric(12,2),
C2380 date,
C2381 char(8),
C2382 char(1),
C2383 integer,
CPUBLISH   char(32),
CTAG  char(60),
cdsrc char(3),
I4201 char(60),
I4202 char(30),
I4203 char(30),
I4204 char(60),
I4205 char(1),
I4206 char(30),
I4207 char(24),
I4208 char(29),
I4209 char(1),
I4210 char(12),
I4211 char(15),
I4212 date,
I4213 char(10),
I4214 char(8),
I4215 char(5),
I4216 char(5),
I4217 char(30),
I4218 char(4),
I4219 numeric(12,2),
I4220 integer,
I4221 date,
I4222 char(12),
I4223 char(16),
I4224 date,
I4225 char(8),
I4226 char(1),
I4228 char(1),
I4229 integer,
I4230 integer,
I4231 char(32),
I4232 char(32),
I4233 char(32),
I4234 char(32),
I4235 char(32),
I4236 timestamp,
I4237 char(16),
I4238 timestamp,
I4239 char(16),
I4240 char(8),
I4299 char(1),
I4241 char(80),
I4242 char(80),
I4243 char(80),
I4244 char(48),
I4245 char(48),
I4246 char(48),
I4247 char(48),
I4248 char(48),
I4249 char(48),
I4250 date,
I4251 date,
I4252 date,
I4253 date,
I4254 numeric(12,2),
I4255 numeric(12,2),
I4256 numeric(12,2),
I4257 numeric(12,2),
I4258 char(1),
I4259 integer,
MTAG  char(60),
ktag  char(60),
idsrc char(3),
IPUBLISH  char(32),
replic char(1),
L2801 char(15),
L2802 char(10),
L2803 char(20),
L2804 char(10),
L2805 char(8),
L2806 date,
L2807 date,
L2808 integer,
L2809 date,
L2810 char(8),
L2811 timestamp,
L2812 char(16),
L2813 timestamp,
L2814 char(16),
L2815 integer,
L2816 char(15),
L2817 numeric(12,2),
L2818 numeric(12,2),
L2819 numeric(12,2),
L2820 numeric(12,2),
L2821 numeric(12,2),
L2822 date,
L2823 date,
L2824 date,
L2825 date,
L2826 char(48),
L2827 char(48),
L2828 char(48),
L2829 char(48),
L2830 char(48),
L2831 char(48),
L2832 char(48),
L2833 char(48),
L2834 char(48),
L2835 char(48),
LPUBLISH char(32),
ltag  char(60),
ldsrc char(3),
C2430	char(60),
C2501	char(128),
C2502 integer,
std_4201 char(60),
std_4202 char(30),
std_4203 char(30),
std_4204 char(60),
std_4205 char(1),
std_4206 char(30),
std_4207 char(24),
std_4208 char(29),
std_4241 char(80),
std_4242 char(80),
std_4243 char(80),
std_4244 char(48),
std_4245 char(48),
std_2301 date,
std_2333 char(8),
std_2303 date,
std_2334 char(8),
std_2323 char(1),
std_ctag char(60),
std_2308 char(1),
std_2354 char(64),
std_2355 char(64),
std_2356 char(64),
K4601 char(48),
K4602 char(48),
K4603 char(48),
K4604 char(48),
K4605 char(48),
K4606 char(48),
K4607 char(48),
K4608 char(48),
K4609 char(48),
K4610 char(48),
K4611 char(48),
K4612 char(48),
K4613 char(48),
K4614 char(48),
K4615 char(48),
K4616 char(48),
K4617 char(48),
K4618 char(48),
K4619 char(48),
K4620 char(48),
K4621 date,
K4622 date,
K4623 date,
K4624 date,
K4625 numeric(12,2),
K4626 numeric(12,2),
K4627 numeric(12,2),
K4628 numeric(12,2),
K4629 timestamp,
K4630 char(16),
K4631 timestamp,
K4632 char(16),
K4640 char(8),
KPUBLISH char(32),
KDSRC char(3),
operator char(60), 
oper_level integer,
oper_seg char(8))
begin
  declare asset_ctag char(60);
  set asset_ctag = (select ctag from calibration where mtag = (select mtag from inventory where i4201 = asset_num) and c2339 = 1);
  call mccalresult(asset_ctag);
end;
grant execute on mt.ots_mx_assetcalresult to public;
commit;