Computing.Net > Forums > Unix > Informix Sql query

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Informix Sql query

Reply to Message Icon

Name: braveking
Date: July 14, 2004 at 12:34:43 Pacific
OS: solaris, AIX
CPU/Ram: 512
Comment:

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.0000000000000

I 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 00024

Can 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




Sponsored Link
Ads by Google

Response Number 1
Name: Dlonra
Date: July 14, 2004 at 14:55:13 Pacific
Reply:

this is a unix forum. You need an informix forum google:
informix forum


0

Response Number 2
Name: Jernand
Date: July 14, 2004 at 16:52:58 Pacific
Reply:

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


0

Response Number 3
Name: nails
Date: July 15, 2004 at 10:01:45 Pacific
Reply:

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


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More


korn or unix choosing the right unix d...



Post Locked

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


Go to Unix Forum Home


Sponsored links

Ads by Google


Results for: Informix Sql query

Informix SQL www.computing.net/answers/unix/informix-sql/6663.html

sql query in unix scritp www.computing.net/answers/unix/sql-query-in-unix-scritp/6420.html

SQL in shell script www.computing.net/answers/unix/sql-in-shell-script/5703.html