473,395 Members | 2,222 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Can anyone help me to writ a function in postgresql

Hi Everyone
I've worked with Postgres Database but i havn't written any user defined function.now i want to produce some reports so can anyone help me to write the function to get my report please see the following details.

In table i have following Data
Batch No OrderNo

127 81294
127 80009
128 13344
129 80379
130 82534
131 25626
132 69103
132 69102
132 64753


I want to produce Report Like this from postgres DataBase
Batch No OrderNo

127 81294,80009
128 13344
129 80379
130 82534
131 25626
132 69103,69102,64753
Apr 4 '08 #1
1 3214
rski
700 Expert 512MB
Hi Everyone
I've worked with Postgres Database but i havn't written any user defined function.now i want to produce some reports so can anyone help me to write the function to get my report please see the following details.

In table i have following Data
Batch No OrderNo

127 81294
127 80009
128 13344
129 80379
130 82534
131 25626
132 69103
132 69102
132 64753


I want to produce Report Like this from postgres DataBase
Batch No OrderNo

127 81294,80009
128 13344
129 80379
130 82534
131 25626
132 69103,69102,64753
Do you really need a function? You can do it by a onr query like this (test2 is your table name)
Expand|Select|Wrap|Line Numbers
  1. select distinct  i as BatchNo, array_to_string((array(select j from test2 where i=k.i)),',') as OrderNo from test2 k;
  2.  
If you want i can write you a function doing the same job.
Apr 4 '08 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

11
by: Angel Todorov | last post by:
Hello, sometimes I get a strange error from postgresql when I try to connect using ssl to the server: LOG: parse_hba: invalid syntax in pg_hba.conf file at line 46, token "hostssl" FATAL: ...
4
by: Christopher Murtagh | last post by:
Greetings, Thanks to a lot of help on this list, I've managed to get my pl/perl function working. However, I have an unexpected result. Here's a simple way to reproduce this problem: CREATE...
1
by: John Sidney-Woollett | last post by:
Is it possible to call a Postgres stored function (as if it were a procedure), using a PreparedStatement which will receive no return value, instead of having to use a CallableStatement and ignore...
2
by: Karl O. Pinc | last post by:
I'm sure I saw something like this on the postgresql web site but the the search function is down in the documentation area. I'm unable to pass a function arguments in a CREATE TRIGGER...
14
by: Karl O. Pinc | last post by:
Hi, Thought perhaps some other eyes than mine can tell if I'm doing something wrong here or if there's a bug somewhere. I've never passed a ROWTYPE varaible to a function but I don't see where...
8
by: Vinay Jain | last post by:
Hi.. I am newbe in postgresql so please help me though the question may be very easy to answer.. Is there any formatting function to get output with fix lengths..for example my query is.. schema...
2
by: Jiri Nemec | last post by:
Hello all, sorry about beginner question, but I'm sure function has correct structure, buw PostgreSQL reports error. (This function is only on approbation.) CREATE FUNCTION foo(int2) RETURNS...
169
by: JohnQ | last post by:
(The "C++ Grammer" thread in comp.lang.c++.moderated prompted this post). It would be more than a little bit nice if C++ was much "cleaner" (less complex) so that it wasn't a major world wide...
1
by: Slapo | last post by:
Hello everyone, I could use some help with this function I've created (see below) that runs flawlessly on PostgreSQL 8.3.6 on my development machine but ends with an error on the production server...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.