[GENERAL] Re: Get the difference between two timestamp cells but in a special format in PostgreSQL

2015-06-26 Thread litu16
Hi Adrian, but I would like to get the time diff in this format 0years 0months 0days 00:00:00.000 not only hours, minutes, seconds. is this possible??? Thanks Advanced. -- View this message in context:

[GENERAL] How to convert a text variable into a timestamp in postgreSQL?

2015-06-26 Thread litu16
I know how to convert a text to timestamp in postgreSQL using *SELECT to_timestamp('05 Dec 2000', 'DD Mon ')* but how can I convert a text variable (inside a function) to timestamp?? In my table (table_ebscb_spa_log04) time is a character varying column, in which I have placed a

[GENERAL] Re: INSERT a real number in a column based on other columns OLD INSERTs

2015-06-25 Thread litu16
Thanks to everybody I already solved, the correct syntax was... SELECT t.time_index FROM table_ebscb_spa_log04 t WHERE t.fn_name = NEW.fn_name AND (t.time_type = 'Start' OR time_type = 'Lap') ORDER BY t.stmtserial DESC LIMIT 1 INTO t_ix; Thanks for all again. -- View this message in context:

[GENERAL] Get the difference between two timestamp cells but in a special format in PostgreSQL

2015-06-25 Thread litu16
This is my table... http://postgresql.nabble.com/file/n5855074/screenshot.jpg I would like to get the time difference between 'time_type = Lap' AND 'time_type = Start' in order to fill 'time_elapse'. Im almost sure that this code works... *CREATE OR REPLACE FUNCTION timediff()

[GENERAL] INSERT a real number in a column based on other columns OLD INSERTs

2015-06-24 Thread litu16
In PostgreSQL I have this table... (there is a primary key serial column in the most left side stmtserial which is not shown in this image) http://postgresql.nabble.com/file/n5854916/screenshot.jpg in the table above, all columns are entered via querrys, except the time_index which I is

Re: [GENERAL] INSERT a number in a column based on other columns OLD INSERTs

2015-06-21 Thread litu16
Hi, thanks yes I was using AFTER, but it only works with BEFORE so finally I got it to work. thanks to all Im just still wondering why here... *BEGIN IF NEW.time_type = 'Start' THEN SELECT t.time_index FROM table_ebscb_spa_log02 t WHERE t.fn_name = NEW.fn_name AND t.time_type = 'Start'

Re: [GENERAL] INSERT a number in a column based on other columns OLD INSERTs

2015-06-21 Thread litu16
Yes I have tried with t_ix = 1; or t_ix := 1; I get the same result, it just doesn't do anything, I have also tried with AFTER and BEFORE, when I use BEFORE I get this error ERROR: cannot return non-composite value from function returning composite type CONTEXT: PL/pgPSQL function on_ai_mytable()

Re: [GENERAL] INSERT a number in a column based on other columns OLD INSERTs

2015-06-21 Thread litu16
Thanks again to all Thanks Charles, fortunately I only need to do INSERTS in my database, however I know I have to read postgreSQL documentation, my respect to programmers who have to learn one language after another, after another, an so on. I just know python and other shorter scripting

[GENERAL] INSERT a number in a column based on other columns OLD INSERTs

2015-06-20 Thread litu16
In PostgreSQL I have this table... (there is a primary key in the most left side timestamp02 which is not shown in this image) in the table above, all columns are entered via querrys, except the time_index which I would like to be filled automatically via a trigger each time each row is filled.