Subject | Simple Simple format question |
---|---|
Author | colincoleman2002 |
Post date | 2006-10-18T15:48:36Z |
We are running Fb 1.5.3 and have a table that has five fields
CREATE TABLE PARTS (
ZPART INTEGER NOT NULL,
ZPLENGTH NUMERIC(15,5) NOT NULL,
ZTYPE INTEGER NOT NULL,
ZPARTDESC VARCHAR(75),
ZTMPART VARCHAR(40)
);
ALTER TABLE PARTS ADD PRIMARY KEY (ZPART, ZPLENGTH);
ALTER TABLE PARTS ADD CONSTRAINT REF_219 FOREIGN KEY (ZTYPE)
REFERENCES TYPES (ZTYPE);
Using the Query :=
select p.zpart, p.zplength, (p.zpart || '-'||p.zplength) as partno
from parts p
The data looks like :-
ZPART ZPLENGTH PARTNO
35442 12 35442-12.00000
35443 15 35443-15.45000
35444 15 35444-15.00000
11678 15 11678-15.00000
55655 15 55655-15.00000
Id Like the last column to show 35442-12 , or 35443-15.45 from the
2nd line, is there
a way to do this in Firebird, maybe using some standard udf to strip
the trailing 0's and any trailing '.' ?
Thanks Colin Coleman
CREATE TABLE PARTS (
ZPART INTEGER NOT NULL,
ZPLENGTH NUMERIC(15,5) NOT NULL,
ZTYPE INTEGER NOT NULL,
ZPARTDESC VARCHAR(75),
ZTMPART VARCHAR(40)
);
ALTER TABLE PARTS ADD PRIMARY KEY (ZPART, ZPLENGTH);
ALTER TABLE PARTS ADD CONSTRAINT REF_219 FOREIGN KEY (ZTYPE)
REFERENCES TYPES (ZTYPE);
Using the Query :=
select p.zpart, p.zplength, (p.zpart || '-'||p.zplength) as partno
from parts p
The data looks like :-
ZPART ZPLENGTH PARTNO
35442 12 35442-12.00000
35443 15 35443-15.45000
35444 15 35444-15.00000
11678 15 11678-15.00000
55655 15 55655-15.00000
Id Like the last column to show 35442-12 , or 35443-15.45 from the
2nd line, is there
a way to do this in Firebird, maybe using some standard udf to strip
the trailing 0's and any trailing '.' ?
Thanks Colin Coleman