SQL

Creating bar codes using SQL queries

This is a basic SQL query to select myfield from table mytable

SELECT myfield;
FROM mytable

To add a bar code to the result we use a bar code function expression;

SELECT myfield, PADR( CIA_CODE128 ( RTRIM ( myfield ) ), 254, " ");
FROM mytable

CIA_CODE128 calculates the bar code.

RTRIM is required to remove trailing spaces from the field (because you don't want spaces in the bar code usually).

PADR is required so that calculated bar code are not truncated.

Naming the created bar code field

This will name the bar code field as mybarcode.

SELECT myfield, PADR( CIA_CODE128 ( RTRIM ( myfield ) ), 254, " ") AS mybarcode;
FROM mytable

AS mybarcode names the calculated field mybarcode.

SELECT myfield, PADR( CIA_CODE128 ( RTRIM ( myfield ) ), 254, " ") AS mybarcode;
FROM mytable

Creating new tables using an SQL query

This will create/overwrite a table called newtable.dbf containing fields; myfield, myhuman and mybarcode.

SELECT myfield, PADR( CIA_ITF_A_H ( RTRIM ( myfield ) ), 254, " ") AS myhuman,;PADR( CIA_ITF_A ( RTRIM ( myfield ) ), 254, " ") AS mybarcode;
FROM mytable;
INTO TABLE newtable.dbf

Field myhuman will contain myfield with an added Interleaved 2-of-5 (ITF) check digit. Print this field using Arial text font.

Field mybarcode will contain myfield as an Interleaved 2-of-5 (ITF) bar code (with check digit). Print this field using CIA ITF Normal bar code font (or any font that starts CIA ITF ...).

 


Copyright 2000 CIA (BAR CODES) UK. All rights reserved. Reproduction prohibited.