SQL Programming Manual for TAL

Examples of Static NonStop SQL Programs
HP NonStop SQL Programming Manual for TAL527887-001
B-8
Insertion Program
Page 8 [1] $VOL1.S04.TALTEST 1991-10-15 13:40:20
195. 000000 0 0 PROC NOT^FOUND;
196. 000000 1 0 BEGIN
197. 000000 1 1 CALL CLOSE^CURSOR;
198. 000002 1 1 sbuf ':=' "SUPPLIER NOT FOUND: SUPPNUM IS "->@buf^end;
199. 000013 1 1
200. 000013 1 1 --Call DNUMOUT to convert INTeger supplier^of^parts value
to
201. 000013 1 1 --ASCII characters for display on the terminal. DNUMOUT is
202. 000013 1 1 --used (with $DBL) instead of using NUMOUT because DNUMOUT
203. 000013 1 1 --suppresses leading zeroes while NUMOUT does not.
204. 000013 1 1 @buf^end := @buf^end '+' DNUMOUT(buf^end,
205. 000013 1 1 $DBL(supplier^of^parts), 10, -1);
206. 000034 1 1 CALL WRITE(home^term^num,ibuf,@buf^end '-' @sbuf);
207. 000046 1 1 CALL ABORT^TRANSACTION;
208. 000047 1 1 CALL ABEND;
209. 000054 1 1
210. 000054 1 1 END; --end of NOT^FOUND
211. 000000 0 0
212. 000000 0 0
213. 000000 0 0 PROC SQLERROR;
214. 000000 1 0 BEGIN
215. 000000 1 1 -- Local variable for SQLCODE. Since we might be changing
216. 000000 1 1 -- the sign of SQLCODE for display, we want to preserve the
217. 000000 1 1 -- global SQLCODE value for future debugging.
218. 000000 1 1 INT errcode;
219. 000000 1 1 errcode := sqlcode;
220. 000003 1 1
221. 000003 1 1 -- Test for negative value in SQLCODE. If the value is an
SQL
222. 000003 1 1 -- error and not a warning, it will be negative. We must
then
223. 000003 1 1 -- change the value to positive in order to display it with
224. 000003 1 1 -- DNUMOUT, because DNUMOUT expects an unsigned number.
225. 000003 1 1 IF errcode < 0 THEN
226. 000006 1 1 BEGIN
227. 000006 1 2 sbuf ':=' "SQL ERROR: -"->@buf^end;
228. 000017 1 2 errcode := -errcode;
229. 000022 1 2 END
230. 000022 1 1 ELSE IF errcode > 0 THEN
231. 000026 1 1 sbuf ':=' "SQL WARNING: "->@buf^end;
232. 000037 1 1
233. 000037 1 1 @buf^end := @buf^end '+' DNUMOUT(buf^end, $DBL(errcode),
10, -1);
234. 000060 1 1 CALL WRITE(home^term^num,ibuf,@buf^end '-' @sbuf);
235. 000072 1 1 CALL ABORT^TRANSACTION;
236. 000073 1 1 CALL ABEND;
237. 000100 1 1 END;
238. 000000 0 0
239. 000000 0 0