Re: [SQL] Comparing two tables of different database

2009-05-02 Thread Lucas Brito
e_Name text, Column_Name text) on ST.Table_Name = DV.Table_name and ST.Column_Name = DV.Column_Name where ST.Column_Name is null or DV.Column_Name is NULL -- Lucas Brito

Re: [SQL] Comparing two tables of different database

2009-05-02 Thread Lucas Brito
dblink(db_database1(), 'select "id", "name", "time" from pr_1') as pr_1("id" integer, "name" text, "time" time) then you will see the table "pr_1" on the datbase2 -- Lucas Brito

[SQL] Count field in query

2006-12-06 Thread lucas
nce')": select *,nextval('mysequence') from mytable; But I think its not the best way to do this! Couse I need to set sequence value to 1 everytime. Can Someone help me? Thanks Lucas Vendramin (Brazil) ---(end of broadcast)--- T

Re: [SQL] Default on update

2005-11-23 Thread lucas
Quoting Richard Huxton : [EMAIL PROTECTED] wrote: Hi. Is there a way to create "default" constraint on UPDATE query. It's becouse I have a bool field that may NOT support NULL value, but the Front-End calls null for FALSE values. Sounds like your frontend is broken. Yes, it is. But I have no

[SQL] Default on update

2005-11-23 Thread lucas
e1_check), any are complex... Is it a problem??? My tests are with few regs and run fine. Where can I read more about triggers and performance? Thanks for all. --- Lucas Vendramin ---(end of broadcast)--- TIP 9: In versions below 8.0, the planner will

[SQL] Extract date from week

2005-11-08 Thread lucas
urns-- date_part | 1 | It is the first week of year (2005), and how can I get what is the first date references the week 1? Ex: select week 1 --should return--- date | 20050103 | -- 3 Jan 2005 Thank you. Lucas Vendramin ---(end of broadcast)-

Re: [SQL] date question

2005-11-03 Thread lucas
- integer How can drop a day to now()?? Try using "now()::date", or "interval". Like: select * from clientes_proceso where fecha_mod::date <= now()::date -1; or: select * from clientes_proceso where fecha_mod::date <= now() - '1 day'::interval; --- Lu

Re: Fwd: Re: [SQL] Referencing

2005-10-31 Thread lucas
Quoting Daryl Richter <[EMAIL PROTECTED]>: [EMAIL PROTECTED] wrote: > Quoting Daryl Richter <[EMAIL PROTECTED]>: >> It's hard to say without knowing more precisely what you are trying to >> model, but I think this push you in the right direction: >> > Okay, but references between (output/input) a

Re: Fwd: Re: [SQL] Referencing

2005-10-28 Thread lucas
Quoting Daryl Richter <[EMAIL PROTECTED]>: It's hard to say without knowing more precisely what you are trying to model, but I think this push you in the right direction: -- This table takes the place of both SEND and BUY create table activity( id serial primary key, prod

Fwd: Re: [SQL] Referencing

2005-10-28 Thread lucas
Ok, But the problem is becouse the "buy" and "send" tables referencing with other father table, wich is different. I shoud not create a spent table to put the "buy" and "send" values becouse the entire database is more complex than it. look: create table output( id serial primary key, client integ

[SQL] Referencing

2005-10-27 Thread lucas
Hi. Is there a way to references dynamic tables? I.E: I have a table called "buy" that create some records in "financial" table, but there is other table called "send" that create other records in "financial". "Financial" table have the moneys' movements and needs to be referenciable by "buy or sen

[SQL] Select problems

2005-08-14 Thread Lucas Grijander
Hi: I've just migrated from Linux/PostgreSQL 7.2 to Windows/PostgreSQL 8.0.3. I have a large view. When I make: "Select . WHERE mydate = 'anydate'" the view lasts 19 seconds to complete. But, when I make: "Select . WHERE mydate >= 'anydate'" the view lasts 7 minutes. With PostgreSQL 7

[SQL] Convert numeric to money

2005-07-22 Thread lucas
Hi. I have searched in mailing-list archives about converting types, but I couldn't found a function or clause that convert a numeric type to money type. How Can I convert this types? => select '1234'::money; money R$1.234,00 => select '1234'::numeric::money; ERROR: cannot cast

[SQL] Cursor need it?

2005-06-08 Thread Lucas Hernndez
cursors Here is what I am trying to do for each table on the list Select tablename, count(*) tables from ( list of tables) tablename tables table1 25 table2 35 Any Idea would be appreciated Thanks Lucas ---(end of broadcast)--- TIP 2: you can get

Re: [SQL] Sum() rows

2005-06-01 Thread lucas
Hi. The function works well... I will use your function and rewrite it to accept more than one select, becouse in this case you selected all records from tb1 table. In real case the table is bigger with many fields and I will work with some filters and some ordering (dynamically)... Thank you.

Re: [SQL] Sum() rows

2005-06-01 Thread lucas
Yes, I tried it. In this table the query works fine, but in a big table (with aprox. 200.000 records) the query performace is very bad. I tried it (in the example table): SELECT *,(select sum(value) from tb1 as tb1_2 where tb1_2.id<=tb1_1.id) as subtot from tb1 as tb1_1 order by id; In a small

[SQL] Sum() rows

2005-05-31 Thread lucas
Hi. How can I sum a row and show the sum for each row??? For example, in a finances table that have the total movimentation(debit/credit) in the bank. i.e: CREATE TABLE TB1 (id integer primary key, value numeric); insert into tb1 values (1,20); insert into tb1 values (2,2); insert into tb1 values

Re: [SQL] Duplicated records

2005-05-25 Thread lucas
Thanks CTAS (Create Table As Select) command works fine!!! With great performance. I think it is the best way to correct the data...(apparently) I didnt know about "select DISTINCT". I am going to read about it. Thank you. Quoting Bricklen Anderson <[EMAIL PROTECTED]>: Is there a way to del

Re: [SQL] Duplicated records

2005-05-25 Thread lucas
Hi. Thanks for the article... But, I have read it and the query works very slow... My table have aprox. 180.000 records (correct) and in entire table it has aprox.360.000 records(duplicated)... I tried to execute a query to delete the duplicated records, but it worked very very slow... look: #

[SQL] Duplicated records

2005-05-24 Thread lucas
way to delete the duplicated data without build another table with constraints and copy those data to the new table? Something like "delete from table1 where ...???" Thanks, Lucas ---(end of broadcast)--- TIP 1: subscribe and unsubscribe commands go to [EMAIL PROTECTED]

Re: [SQL] Function or Field?

2005-05-03 Thread lucas
Do I have to create another table to put this data??? But, Isn't it redundancy? :-/ The question is: For example: I have a "clients" table and I have a "taxes" table that is a chield of client. Is more efficient put fields into client table that contains: -) the count for paid taxes -) the c

Re: [SQL] Record Log Trigger

2005-05-03 Thread lucas
Well... Right, I will use to_timestamp() function instead of now() function. But, what is the performance for those Triggers??? Considering that all tables will have this Trigger and will check for each update or insert. Thanks Quoting CHRIS HOOVER <[EMAIL PROTECTED]>: One change you might want to

[SQL] Function or Field?

2005-05-02 Thread lucas
Hi. What is the better way to store the last record for a translation??? I.E: The data for the last product vendding. What is better: a) Create a field in "product" table and create a Trigger (before insert or update into vendding table) to alter this field. b) Create a view or function that ch

[SQL] Record Log Trigger

2005-05-02 Thread lucas
Hi all, I am building a database in postgresql and I made a function that returns the system time and the current user... like this: CREATE OR REPLACE FUNCTION generate_idx() returns text as $$ select to_char(now(),'MMDDHHMISSUSTZ')||CURRENT_USER; $$ language 'SQL'; CREATE OR REPLACE FUNC

[SQL] Chield Serial

2005-04-04 Thread lucas
Hi. Is there a way to make a serial columm that works with father table??? I.e: I have created a table called "vending" and its chield table called "items". The items table have a serial columm, but I need the serial colum starts with 0 for each vending. create table vending ( id serial prima

Re: [SQL] New record position

2005-03-30 Thread lucas
Okay, I will use the "order by" clause. I was worried about it. I have thought that my database had crashed. Thank you. Quoting Oleg Bartunov : This is a feature of relational databases, you should explicitly specify ordering if you want persistent order. btw, why do you bothering ? Oleg

[SQL] New record position

2005-03-30 Thread lucas
Shouldn't it apper at the LAST record??? What need I do?? Thank you. Lucas Vendramin Brazil ---(end of broadcast)--- TIP 8: explain analyze is your friend

[SQL] Trigger with parameters

2005-03-18 Thread lucas
sult; IF NOT result THEN RAISE EXCEPTION 'The validate of the system field name is False'; END IF; RETURN NEW; END; $$ LANGUAGE plpgsql; CREATE TRIGGER products_codes_checkfieldvalue BEFORE INSERT OR UPDATE ON main.products_codes FOR EACH ROW EXECUTE PROCEDURE trigger_sys

Re: [SQL] Generic Function

2005-03-16 Thread lucas
Oh sorry. I was not clearly. I've wanted to create a function that suport to select a "parameter variable" table. Like: return 'select * from $1'. The Postgresql does not suport this sql function becouse the $1 variable is considerate as a table... the Postgresql return an error like: The table "$

[SQL] Generic Function

2005-03-14 Thread lucas
Hi, Can I built a generic function like: CREATE FUNCTION f (text) RETURNS TEXT as $$ return 'select * from $1'; $$ I know its impossible as writed. Also I have looked for EXECUTE procedure but it not run the correct function. Is there a way to construct this clause? Using plpgsql/pltcl/anyt

[SQL] Table like a field

2005-03-09 Thread lucas
Hello. Is there any way to build a table that contain the coluns name for the other table fields? like this: create table people(id serial primary key, name varchar(50) ); create table people_fields ( field_name varchar(30) ); insert into people_fields values ('occupation'); insert into people

[SQL] Multiples schemas

2005-03-02 Thread lucas
Hi, Is there a way to construct a multi schema in my data base? Something like: mysystem.finances.money.tables mysystem.finances.money.functions mysystem.finances.credits.tables mysystem.finances.credits.functions mysystem.amount.products.. Or can I use another database like:

Re: [SQL] Relation in tables

2005-02-17 Thread lucas
Use a view per department, which show/hide the columns according to your liking. Give each department a schema and put everything related to it inside for cleanliness. Use UPDATE triggers on the views, which in fact write to the products table, so that the departments can only update the column

[SQL] Relation in tables

2005-02-16 Thread lucas
Hello all... I am starting in Postgresql... And I have a question: I am developing a DB system to manage products, but the products may be separated by departaments (with its respectives coluns)... Like: CREATE TABLE products( id serial primary key, desc valchar(100), ... ); Okay, but

[SQL] restoring database

2003-12-22 Thread LAIN Lucas TECHTEL
Hi everybody ... i need to restore only one database from a pg_dumpall backup file... how can i do it? Thanks a lot ! -- Lucas Lain Gerencia de IngenierĂ­a TechTel Telecomunicaciones [EMAIL PROTECTED] TE. (54-11) 4000-3164 ---(end of broadcast

[SQL] restoring database

2003-12-22 Thread Lucas Lain
Hi everybody ... i need to restore only one database from a pg_dumpall backup file... how can i do it? Thanks a lot ! ---(end of broadcast)--- TIP 8: explain analyze is your friend

Re: [SQL] Configuring Problem on Solaris............

2003-08-20 Thread LAIN Lucas TECHTEL
g' for the exact reason. It may be a > problem related to locating certain shared libraries. The archives > contain several instances where this problem is dicussed. > > -- > Peter Eisentraut [EMAIL PROTECTED] > > > ---(end of broad

Re: [SQL] Change the behaviour of the SERIAL "Type"

2003-06-26 Thread Randall Lucas
Wow, I had never actually faced this problem (yet) but I spied it as a possible stumbling block for porting MySQL apps, for which the standard practice is inserting a NULL. As I have made a fairly thorough reading of the docs (but may have not cross-correlated every piece of data yet, obviousl

Re: [SQL] TR: Like and =

2003-06-23 Thread Randall Lucas
Hi Nicholas, CHAR fields, as opposed to VARCHAR, are blank-padded to the set length. Therefore, when you inserted a < 25 character string, it got padded with spaces until the end. Likewise, when you cast '100058' to a CHAR(25) in the = below, it gets padded, so it matches. The LIKE operat

[SQL] comparing querys

2003-06-18 Thread Lucas Lain
how can i compare two querys' eficiency??? TIA, -- Lucas Lain [EMAIL PROTECTED] #! /Scripting/Manager (??) ---(end of broadcast)--- TIP 6: Have you searched our list archives? http://archives.postgresql.org

Re: [SQL] Getting rid of accents..

2003-05-27 Thread Randall Lucas
Full disclosure on previously posted Perl code: I think I may have cribbed all or part of that previous code from something (Perl cookbook?). In any case, the issue is essentially a mapping of which ascii codes "look like" low-ascii, so I don't think there are any authorship issues. Best, Ra

Re: [SQL] Getting rid of accents..

2003-05-27 Thread Randall Lucas
Hi Mallah, I had this problem once, and put together this bunch of regexes. It's by no means optimal, but should solve 90% and would easily be adapted into a plperl function. Begin perl: $value =~ s/[\xc0-\xc6]/A/g; $value =~ s/[\xc7]/C/g; $value =~ s/[\xc8-\xcb]/E/g; $value =~ s/[\xcc

Re: [SQL] insert problem with special characters

2003-05-14 Thread Randall Lucas
Hi John, (added to JDBC list) 1. What is your database encoding? Does it support the unicode OK? 2. Are you sure it's getting /stored/ as a question mark rather than just displayed as such? Remember, if it is stored correctly, but you look at it from a terminal that doesn't support the charact

[SQL] alter user does not changes password

2002-10-01 Thread Lucas Brasilino
accepts! It must be a feature.. not a bug... I know I'm making a mistake.. but.. where?? bests regards -- []'s Lucas Brasilino [EMAIL PROTECTED] http://www.recife.pe.gov.br Emprel -Empresa Municipal de Informatica (pt_BR) Municipal Computing Enter

Re: [SQL] Problem with timestamp field/time function.. (upgrading

2002-08-22 Thread Lucas Brasilino
;). If PostgreSQL development group change it's point of view, I suppose there's some advantage. Do you know some advantages ?? bests regards -- []'s Lucas Brasilino [EMAIL PROTECTED] http://www.recife.pe.gov.br Emprel -Empresa Municipal de In

[SQL] Problem with timestamp field/time function.. (upgrading from 7.0 to 7.2.1)

2002-08-20 Thread Lucas Brasilino
a timestamp column? I know it's quite simple question... but I haven't find any clue! Thanks a lot in advance. Bests regards []'s Lucas Brasilino [EMAIL PROTECTED] http://www.recife.pe.gov.br Emprel -Empresa Municipal de Informatica (pt_BR) Municip