473,465 Members | 1,976 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

functions in postgresql!!!

38 New Member
i have a table of car. In my table there is a column of time which stores traveling time of individual car in "HH:MM:SS" format. I write a query and get time in the same format. i will write my problem below.

Can i write a function for this table that whenever i select this column, i must get time in seconds i.e integers.

thnx
@rtist
Nov 10 '06 #1
3 2050
michaelb
534 Recognized Expert Contributor
Did you try to use a format function?
select to_char(column-name, 'SSSS') ;
Nov 10 '06 #2
artistlikeu
38 New Member
thnx a lot... it is working now....

can i define it as a function rather than using query all the time... may be as views.???

if so plz can u guide me...
regards
Nov 14 '06 #3
michaelb
534 Recognized Expert Contributor
Of course you can have your own function, or you can create a view... but why bother?

- you would still run a query to execute your function and you can hardly expect it'll be better or faster than the one you're using now.

- a view does have its advantages, but let's first understand what seems to be inefficient with using a function inside your query.

Suppose what you had before looks like this:
select field1, field2, field3 from myTable;
And this is what you have now:
select field1, to_char(field2, 'SSSS'), field3 from myTable;

Again, depending on your situation a view may have a perfect sense, but you need to see a reason why would you benefit from it.
Perhaps it'll help if you provide more details.

michael.
Nov 14 '06 #4

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

Similar topics

20
by: Ivar | last post by:
Hi, For my supprise I found that functions have 32 parameter limit. Where to find more info about this limitation or similar limitations ? I need at least 50, 100 would be ok. Real life...
1
by: giant food | last post by:
Hi, I'm in the process of converting an Oracle database into postgresql. One thing I've noticed is that postgresql functions keep the entire function body in a string, e.g.: CREATE OR REPLACE...
5
by: Rich Hall | last post by:
Can somebody tell me how Stored Functions are kept in the database? I've gone through the catalog several times. I've found many interesting things but NOT the 300-odd functions I've created. ...
29
by: Paul Ganainm | last post by:
Hi all, Following up on another thread, here is a comparison between FB and PG from an FB'ers POV. BTW, FB is the love-child of Open-Source-Interbase. BTW, I have tried to be as accurate as I...
4
by: Chris Travers | last post by:
Hi all; A few years ago, I set about porting a PHP application from MySQL to PostgreSQL, after realizing that MySQL wasn't going to be able to handle it. In order to do this, I built a light,...
3
by: Robert Abi Saab | last post by:
Hi everyone. I just finished a course on PostgreSQL and I found out that PostgreSQL doesn't provide any object relational features (as claimed in the official documentation), except table...
0
by: phil campaigne | last post by:
Phil Campaigne wrote: > Hi Ron, > I had a couple of questions on your instructions: > 1. what is this for? > >#make install-all-headers According to the docs you need it if you are going...
10
by: Laimis K | last post by:
Hi, I'm oracle man. So, how about features in postgesql which exists in oracle db (order is casual) ? 1. Sequences 2. Packages 3. Functions/procedures 4. Full-text 5. Triggers
5
by: Robert Fitzpatrick | last post by:
Can someone point me to some more information or perhaps show an example of returning a recordset from a plpgsql function. I'd like to send an argument or arguments to the function, do some queries...
0
by: Bruno Lavoie | last post by:
Hello, i'm etablishing a naming convention for a new project under postgresql. For tables, sequences, views, that's ok! I used good naming conventions for this in the past and i'll keep these...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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...
1
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...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.