Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
Hi
I have the following informix query
SELECT
iinvd.dc_id
,iinvd.whse_id
,iinvd.lic_plt_id
,iinvd.prod_qty/iprdd.unit_ship_cse
FROM iprdd, iplas, iinvd
WHERE
iplas.dc_id = iprdd.dc_id
AND iplas.prod_id = iprdd.prod_id
AND iplas.prdd_id = iprdd.prdd_id
AND iinvd.dc_id = iplas.dc_id
AND iinvd.whse_id = iplas.whse_id
AND iinvd.plas_id = iplas.plas_id
AND iinvd.prod_qty > 0
The data from the query looks like the below.21 1 100013276 24.0000000000000
21 1 100013277 24.0000000000000
21 1 100013278 24.0000000000000I would like the data to be in the following fashion. The fourth field is giving a seq number to the row.
21 01 000000000100013276 1 00024
21 01 000000000100013277 2 00024
21 01 000000000100013278 3 00024Can somebody help me?
Note: The informix datatypes for the columns are as follows
dc_id smallint
whse_id smallint
lic_plt_id decimal(18,0)
prod_qty integer
unit_ship_cse smallint

you might have to study the UNIONS of the sql statements.
or you might want to unload the output in a file using the statement "unload to somefile.dat" and let thewrite a script usinf awk and sed to do what you want taking that somefile.dat as an input file.
Regards,
Jern

Hi:
When I need to add a serial value to select output, I add a serial column to a temp table. Then I select into that temp table. Here's an example:
create temp table b (
sn char(20),
idx serial,
wo char(15)
) with no log;insert into b
select a.sn, "0", a.workorder from o_sn a, o_workorder b where a.workorder = b.workorder;
select * from b;You still might want to consider Jern's suggestion to unload and modify the data file.
Regards,
Nails

![]() |
korn or unix
|
choosing the right unix d...
|

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |