Hello,
Below is my requirement. Is there any way i can acheive that?
If i fire the query " Select * from customer ", the o/p is like below(display is vertical):
Customer_no : 101
Fname : Ravi
Lname : Kumar
...
...
...
My requirement is to display the results in horizontal way, like below...
Customer_no Fname lname ...
------------------ ---------- ---------
101 Ravi kumar
102 Ajay xyz
....
Thanks in advance for all your assistance.
Regards,
Ravikumar.
---------------------------------
Heres a new way to find what you're looking for - Yahoo! Answers
scottishpoet - 28 Mar 2007 10:27 GMT
This really depends what tool you are using to display the data. Are
you using dbaccess? can you limit the query to only display the
columns you want to see and if so does that resolve your problem?
In dbaccess when I do "select customer_name, fname,lname from
customer" from the stores database I get
customer_num fname lname
101 Ludwig Pauli
102 Carole Sadler
103 Philip Currie
104 Anthony Higgins
...
If I do "select * from customer" I get the vertical display. This is
because there is not enough space on the screen to display the rows
across the screen
More sophisticated tools such as ISQL / 4GL, Excel allow you more
control over the display format
Snaggles - 28 Mar 2007 10:40 GMT
Hello,
you can use a script like following:
(database must be changed to pass y/req.)
#!/bin/ksh
~informix/bin/dbaccess database -<<@ 1>/dev/null 2>&1
UNLOAD TO "/tmp/table.unl" DELIMITER "|"
SELECT Customer_no, Fname, Lname FROM table WHERE 0=0;
@
echo "Customer_no|Fname|Lname" > /tmp/output # It could be that
anyone can select the fieldnames using "syscolumns"
cat /tmp/table.unl >> /tmp/output
rm /tmp/table.unl # we dont't need it anymore
cat /tmp/output # this will give you the output to screen (if u
don't like Pipe as separator, define an other separator)
# end of script
next opinion is:
#!/bin/ksh
~informix/bin/dbaccess database -<<@ 1>/dev/null 2>&1
OUTPUT TO screen_file
SELECT Customer_no, Fname, Lname FROM table WHERE Fname matches "A*";
@
cat screen_file
# end of script2
Bye
Andy
> Hello,
>
[quoted text clipped - 24 lines]
> ---------------------------------
> Here's a new way to find what you're looking for - Yahoo! Answers
Art S. Kagel - 28 Mar 2007 17:45 GMT
> Hello,
>
[quoted text clipped - 12 lines]
> My requirement is to display the results in horizontal way, like below...
>
This is what dbaccess does if the output is wider than 80 characters. Your
options are:
1- There's a package in the IIUG Software Repository with a Perl script that
can reformat the output.
2- Use unload to a delimited file and post-process the file using awk, Perl,
or whatever to get the output format you want.
3- Get Jonathan Leffler's sqlcmd package and use that instead of dbaccess.
By default it outputs in delimited format, but there are options for
fixed format and others as well.
Art S. Kagel
> Customer_no Fname lname ...
> ------------------ ---------- ---------
[quoted text clipped - 12 lines]
> Here’s a new way to find what you're looking for - Yahoo! Answers
> <http://us.rd.yahoo.com/mail/in/yanswers/*http://in.answers.yahoo.com/>