Re: [SQL] need help

2013-02-21 Thread Carlos Chapi
Hello, Maybe this query can help you SELECT p.name, l.name FROM location l INNER JOIN product_move m ON m.source_location = location.id INNER JOIN product p ON m.product_id = p.id WHERE p.id = $product_id AND m.datetime < $given_date ORDER BY datetime DESC LIMIT 1 It will return the name of the

[SQL] Understanding Binary Data Type

2012-05-22 Thread Carlos Mennens
Hello everyone! I wanted to ask the list a question about the 'bytea' data type & how I can picture this in my head. I've been reading SQL for about a few months now and since then, I've only been working with textual data. Basically I'm familiar with storing text and numerical characters into tabl

Re: [SQL] Finding Max Value in a Row

2012-05-13 Thread Carlos Mennens
the primary key constraint so I don't know if that was a good / bad idea. Thanks for any info / help! -Carlos -- Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-sql

Re: [SQL] Finding Max Value in a Row

2012-05-11 Thread Carlos Mennens
On Fri, May 11, 2012 at 3:43 PM, Adrian Klaver wrote: > Well the question to ask is if it is declared CHAR was that done for a > legitimate reason? One reason I can think of is to have leading 0s in a > 'number'. Might want to double check that code downstream is not depending > on CHAR behavior.

Re: [SQL] Finding Max Value in a Row

2012-05-11 Thread Carlos Mennens
On Fri, May 11, 2012 at 3:44 PM, Thomas Kellerer wrote: > Use this: > > alter table users >    alter column users_id type integer using to_number(users_id, '9'); > > (Adjust the '9' to the length of the char column) When you wrote "Adjust the '9' to the length of the char column, do y

Re: [SQL] Finding Max Value in a Row

2012-05-11 Thread Carlos Mennens
Thanks for all the help thus far everyone! I sadly didn't create/design the table and would love to create a SEQUENCE on that particular field but not sure how unless I DROP the table and create from scratch. Currently the data TYPE on the primary key field (users_id) is CHAR and I have no idea wh

[SQL] Finding Max Value in a Row

2012-05-11 Thread Carlos Mennens
I have a problem in SQL I don't know how to solve and while I'm sure there are 100+ ways to do this in ANSI SQL, I'm trying to find the most cleanest / efficient way. I have a table called 'users' and the field 'users_id' is listed as the PRIMARY KEY. I know I can use the COUNT function, then I kno

[SQL] UPDATE Multiple Records At Once?

2012-04-11 Thread Carlos Mennens
FROM customers forza-# WHERE cust_name = 'iamUNIX' forza-# ; cust_id | cust_name | cust_address | cust_contact | cust_email +---+---++ 16 | MobileNX | 200 South Shore Drive | Carlo

[SQL] Type Ahead Issue

2012-03-07 Thread Carlos Mennens
I don't know if this is an issue with my client (Psql) or if it's something I'm doing wrong but I've noticed this issue before and can't figure it out. When I'm using the psql client, I really rely on the tab / type ahead auto completion. When I run my command on one single line, it works fine but

Re: [SQL] Change Ownership Recursively

2012-03-01 Thread Carlos Mennens
I changed to the suggested database which is owned by 'Carlos' and did as instructed. Everything worked fine. Thank you! On Thu, Mar 1, 2012 at 11:23 AM, Carlos Mennens wrote: > I did do a Google search for "PostgreSQL 9.1 change ownership > recursively" but eithe

Re: [SQL] Change Ownership Recursively

2012-03-01 Thread Carlos Mennens
E-RSA-AES256-SHA, bits: 256) You are now connected to database "postgres" as user "carlos". postgres=# REASSIGN OWNED BY carlos TO lauren; REASSIGN OWNED postgres=# DROP OWNED BY carlos; DROP OWNED iamunix=# \d List of relations Sc

[SQL] Change Ownership Recursively

2012-03-01 Thread Carlos Mennens
Ctype| Access privileges ---+--+--+-+-+--- iamunix | lauren | UTF8 | en_US.UTF-8 | en_US.UTF-8 | All tables still owned by Carlos: iamunix=# \d List of relations Schema | Name | Type

[SQL] Display Length Between Var & Varchar

2012-01-31 Thread Carlos Mennens
I've noticed when I set a field to char, it takes up lots of space over varchar: iamunix=# SELECT * FROM music; id | band| album |date| asin|label +---+--+---

[SQL] Update Mass Data in Field?

2012-01-26 Thread Carlos Mennens
I'm new to SQL so I'm looking for a way to change several email addresses with one command. For example everyone has a 'holyghost.org' domain and I need to change a few 100 email addresses in the field 'emp_email'. I need to UPDATE employees table which has a COLUMN 'emp_email' and change %holyghos

[SQL] Unable To Modify Table

2012-01-12 Thread Carlos Mennens
I seem to have an issue where I can't modify a table due to another tables foreign key association: [CODE]trinity=# \d developers Table "public.developers" Column| Type | Modifiers --++--- id | character(10) | not null name

Re: [SQL] Unable To Alter Data Type

2012-01-11 Thread Carlos Mennens
On Wed, Jan 11, 2012 at 7:13 PM, David Johnston wrote: > However, I will say again, you DO NOT WANT TO ACTUALLY DO THIS! > > The specific issue is that some US Postal Code begin with a zero ( 0 ) and > so whenever you want to the zip_code value you need to pad leading zeros if > the length is less

[SQL] Unable To Alter Data Type

2012-01-11 Thread Carlos Mennens
I have an issue I can't figure out. I have the following TABLE: tysql=# \d customers Table "public.customers" Column| Type | Modifiers --++--- cust_id | character(10) | not null cust_name| character(50) | not null cust_a

[SQL] DECIMAL or NUMERIC Data Types

2012-01-05 Thread Carlos Mennens
Does it matter when writing SQL code in PostgreSQL if I use DECIMAL or NUMERIC date types for a column named 'price' assuming it's to store the associated items actual dollar amount? Reading the fine manual*, I can't find a single difference between either and they both are supported / recognized

[SQL] When To Use Quotes

2012-01-05 Thread Carlos Mennens
I'm trying to understand when in SELECT statements should and should I not use single quotes to filter my results. For example: SELECT * FROM people WHERE fname = 'James'; or SELECT * FROM price WHERE msrb BETWEEN 50 AND 100; Now is it correct to say that in PostgreSQL or ANSI SQL in general I

Re: [SQL] problems with copy

2007-09-28 Thread Luis Carlos Ferreira
El Lun 24 Sep 2007 21:38, chester c young escribió: > I'm getting lots of delimited files from Excel and MySQL users that, > mid-file, begin truncating lines if ending in null values. > > for example: > 1781: "one","two","three",, > 1782: "one","two","three",, > 1783: "one","two","three",, >

[SQL] How can I know if a row is Locked?

2007-04-13 Thread Carlos Santos
uals to '1' will be locked to other transactions until the COMMIT command be executed. So, how can I detect if this row is locked? Tks Carlos Henrique Iazzetti Santos Compels Informática Santa Rita do Sapucaí - MG www.compels.net

[SQL] LOCK command inside a TRANSACTION

2007-04-03 Thread Carlos Santos
LOCK command inside a TRANSACTION but I didn't see how I could do that yet. Does anybody have any ideas? Carlos Henrique Iazzetti Santos Compels Informática Santa Rita do Sapucaí - MG Brazil www.compels.net __ Fale com seus amigos de graça

[SQL] Query a select that returns all the fields of an specific value of primary key without knownig the name of the single column's primary key?

2006-12-19 Thread Carlos Santos
Hi! I need to query a select that returns all the fields of an specific primary key, but I don't have the single column's name that is constrained as primary key. How can I do that? Something like: SELECT * FROM myTable WHERE myTable.pkey = 'foo'; Thanks Carlos Henr

Res: [SQL] SELECT with WHERE clause by column number

2006-12-18 Thread Carlos Santos
All my columns have the same data type: text. So it's much easier. Carlos Henrique Iazzetti Santos Compels Informática Santa Rita do Sapucaí - MG www.compels.net - Mensagem original De: Richard Huxton Para: Carlos Santos <[EMAIL PROTECTED]> Cc: Lista PostgreSQL SQ

[SQL] SELECT with WHERE clause by column number

2006-12-18 Thread Carlos Santos
nternal function or through a Procedural Language? Thanks Carlos Henrique Iazzetti Santos Compels Informática Santa Rita do Sapucaí - MG BRAZIL www.compels.net ___ Você quer respostas para suas p

RES: [SQL] Left join?

2006-07-02 Thread Carlos H. Reimer
It´s just want I need! Perfect! Thanks! Carlos > -Mensagem original- > De: Richard Broersma Jr [mailto:[EMAIL PROTECTED] > Enviada em: sábado, 1 de julho de 2006 18:45 > Para: [EMAIL PROTECTED]; pgsql-sql@postgresql.org > Assunto: Re: [SQL] Left join? > > >

[SQL] Left join?

2006-07-01 Thread Carlos H. Reimer
=# select * from reqtran; codreq | codsol | codate | codfec +++ 1 ||| 2 | 1 || 3 | 1 | 1 | 4 | 1 | 1 | 1 (4 rows) Thanks in advance, Carlos

Re: [SQL] row-attribute in EXPLAIN-output doesn't match count(*)

2005-04-18 Thread Carlos Moreno
of waiting until the COMMIT is issued :-) Carlos -- ---(end of broadcast)--- TIP 2: you can get off all lists at once with the unregister command (send "unregister YourEmailAddressHere" to [EMAIL PROTECTED])

Re: [SQL] Update aborted if trigger function fails?

2005-04-12 Thread Carlos Moreno
Andrew Sullivan wrote: On Tue, Apr 12, 2005 at 10:55:30AM -0400, Carlos Moreno wrote: I guess the concern came up as result of a particular situation, in which failing to properly process the trigger function is not that crucial (I wanted to update some additional information that is "opt

Re: [SQL] Update aborted if trigger function fails?

2005-04-12 Thread Carlos Moreno
you deal with this? Well, you test. Fair enough. Thanks! Carlos -- ---(end of broadcast)--- TIP 4: Don't 'kill -9' the postmaster

[SQL] Update aborted if trigger function fails?

2005-04-11 Thread Carlos Moreno
op it). Isn't this a little fragile? Is there something I could do to avoid this situation? Should trigger functions be extremely simple as to guarantee that an error would never happen? Thanks, Carlos -- ---(end of broadcast)--- TIP 3: if posti

Re: [SQL] Question on triggers and plpgsql

2005-04-09 Thread Carlos Moreno
been and is currently in use? My guess is that there should be no problem and no risk in doing that -- but being my first steps in PL, I wouldn't like to trust a beginner's intuition for a production system. Thanks, Carlos -- ---(end of broadcast)-

[SQL] Question on triggers and plpgsql

2005-04-07 Thread Carlos Moreno
t is necessary, or what implications -- positive or negative -- it may have) Am I doing the right thing? Have I introduced some sort of catastrophe waiting to happen? Thanks for any guidance you may offer to this PL/PGSQL beginner! Carlos -- ---(end of broadcast)-

[SQL] bigger problem

2002-11-11 Thread Carlos Sousa
in postgres database i created a table with a field like create table (...) (...) var text default '' not null (...) now i need to import the data from this table into a oracle database i used pg_dump I altered the field data type to (...) var varchar2(50) default '' not null (...) but when i

[SQL] small proble

2002-11-11 Thread Carlos Sousa
hi to all I am doing a webpage and i manipulate data from a postgres database. I need to do the same thing with a oracle database. I am using pg_dump to transfer the database data from postgres to oracle but there are a few problems with same data types in a table when i try to import it to a ora

[SQL] small problem

2002-11-11 Thread Carlos Sousa
hi to all I am doing a webpage and i manipulate data from a postgres database. I need to do the same thing with a oracle database. I am using pg_dump to transfer the database data from postgres to oracle but there are a few problems with same data types in a table when i try to import it to a ora

[SQL] problem with a query

2002-10-23 Thread Carlos Sousa
hi to all i need to do a query to a small postgres database my best efort to the pretended query is in the attached file 'query.txt' but i need that some rows don't be selected of thouse that the query returns. i send in another attached file 'result.txt' with the query result. looking at conte

[SQL] Select distinct and order by.

2001-07-17 Thread Carlos
elect distinct field1, field2, field3 from table1 order by field1, field2;" WORKS FINE. These last situation are in a transaction whith some tables locked, that aren't table1. TIA Carlos. Solaria Mediterranea, S.L.L: P.S.: please send me the answers directly, because I isn't su