Re: [SQL] User defined types -- Social Security number...

2004-02-29 Thread Christopher Browne
The world rejoiced as [EMAIL PROTECTED] (Michael Chaney) wrote: > Look, you're thinking way too hard on this. An SSN is a 9-digit number, > nothing more. There are some 9-digit numbers which aren't valid SSN's, > and you might want to get fancy and create a constraint for that. > > Regardless, yo

Re: [SQL] Field list from table

2004-02-29 Thread Denis
To get the list.. use SELECT a.attname as "Columns" FROM pg_attribute a, pg_class c WHERE c.relname = '' AND a.attnum > 0 AND a.attrelid = c.oid ORDER BY a.attnum Thanx Denis - Original Message - From: "Jan Pips" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Thursday, Februar

Re: [SQL] How to get Rows Count

2004-02-29 Thread Iain
howabout: select sum(case when c = '*' then 0 else 1 end) as count_not_star from tablename If you want to process all records but only count thouse without a * in c then this will do the trick. regards iain - Original Message - From: "Abdul Wahab Dahalan" <[EMAIL PROTECTED]> To: <[EMAI

Re: [SQL] PLSQL Question regarding multiple inserts

2004-02-29 Thread V i s h a l Kashyap @ [Sai Hertz And Control Systems]
Dear Humble Geek , -- id is primary key insert into users (id, username) values (nextval('someSeq'),'somename'); -- id is also a PK insert into log (id, uid, message) values (nextval('someOtherSeq'),XXX,'New Account'); Assume XXX is the id from the first insert. How do I get that number? Not currv

Re: [SQL] User defined types -- Social Security number...

2004-02-29 Thread Michael Chaney
On Sun, Feb 22, 2004 at 04:45:51PM -0800, Greg Patnude wrote: > Thanks Josh -- I understand that there are valid and invalid SSN's -- > similar rules apply to zip codes and area codes... > > I tried this: > > SELECT to_char(123456789, '000-00-'); > which yields 123-45-6789 -- nicely, I might ad

Re: [SQL] Postgres DB

2004-02-29 Thread Michael Chaney
On Mon, Feb 23, 2004 at 02:24:32PM +0530, Sumita Biswas wrote: > The following Query string , when executed does not give an Error, even > though the table Tbl_Billing_Data is not present. > > QueryToPopulateTemp := ''INSERT INTO Tmp_Conference(ConferenceType, > CallManagerId, ClusterId, DestConve

[SQL] How to get Rows Count

2004-02-29 Thread Abdul Wahab Dahalan
a b dc 01 02 b* 01 02 a* 02 03 02 04 b* 02 04 a* 03 05 04 06 If I've a table like above, how do I make a query to get rows count that doesnt have '*' in it. Can we have other queries than thi

Re: [SQL] plpgsql function returning SETOF RECORD Question

2004-02-29 Thread Joe Conway
[EMAIL PROTECTED] wrote: When I run the function below I recieve an error message saying that column definitions need to be specified for a function returing a type RECORD. I was under the impression that the FOR row IN SELECT... loop would assign a column structure to the RECORD type. Am I wrong a

Re: [SQL] Trouble with composite types

2004-02-29 Thread Joe Conway
Yasir Malik wrote: [attempts to use a composite type as a field data type of another composite type] When I enter that into the command prompt, I the following message: ERROR: Attribute "street" has composite type street_type Why is it giving me error message for something I know is true? Also,

Re: [SQL] Field list from table

2004-02-29 Thread rixder
On Thu, Feb 26, 2004 at 10:51:41AM +0100, Jan Pips wrote: > How can I, using SELECT, get the full list of fields from a given table? > > Pips > > Hi ! Try it: select * from table limit 0; rixder ---(end of broadcast)--- TIP 5: Have you checked

[SQL] Trouble with composite types

2004-02-29 Thread Yasir Malik
Hello, I don't know why this message is not going through! I have the following types: create type street_type as ( street_number smallint, street_name text, apt_number smallint ); create type address_type as ( street street_type, citytext, state char(2),

[SQL] PLSQL Question regarding multiple inserts

2004-02-29 Thread Humble Geek
Hi all. Quick and perhaps silly question, but... I am using Pg 7.3. I am writing a function using pgplsql. This function will perform multiple inserts. Let's say two of the inserts are as follows: -- id is primary key insert into users (id, username) values (nextval('someSeq'),'somename'); -- id

Re: [HACKERS] [SQL] Materialized View Summary

2004-02-29 Thread Jonathan Gardner
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On Tuesday 24 February 2004 01:48 pm, Robert Treat wrote: > On Tue, 2004-02-24 at 12:11, Richard Huxton wrote: > > On Tuesday 24 February 2004 16:11, Jonathan M. Gardner wrote: > > > I've written a summary of my findings on implementing and using > > >

[SQL] CURSORS - Please help urgent.

2004-02-29 Thread Sumita Biswas (sbiswas)
The follow code gives me Error: DECLARE CURSOR_GET_ALL_CONFERENCE_RECORDS CURSOR FOR Select ConferenceType,CallManagerId,ClusterId,DestConversationId,AppConfId,Fina lDestination FROM Tmp_Conference; OPEN CURSOR_GET_ALL_CONFERENCE_RECORDS; FETCH FROM CURSOR_GET_ALL_CONFERENCE_RECORDS IN

[SQL] Unicode Support

2004-02-29 Thread Sumita Biswas (sbiswas)
Hi All, This is regarding Unicode Encoding(UTF8) in Postgres. I have the following assumptions, please correct me if I am wrong: 1. Postgres Supports unicode encoding(UTF8). 2. Any database takes the default encoding unless specified. Hence we can configure a Database to support unicode(UTF8) whi

Re: [HACKERS] [SQL] Materialized View Summary

2004-02-29 Thread Hans-Jürgen Schönig
Richard Huxton wrote: On Tuesday 24 February 2004 16:11, Jonathan M. Gardner wrote: I've written a summary of my findings on implementing and using materialized views in PostgreSQL. I've already deployed eagerly updating materialized views on several views in a production environment for a company

[SQL] unicode(utf-8) problem !

2004-02-29 Thread john
the chinese utf-8 code haves  3 bytes   When I use the query command Like   "  select * from phpbb_users where username='阿至' "   the Result is Too Much Records! :-( user_id=9522, username= 阿貝user_id=8261, username= 阿超user_id=6364, username= 阿聰user_id=6141, username= 阿菲use

[SQL] Field list from table

2004-02-29 Thread Jan Pips
How can I, using SELECT, get the full list of fields from a given table? Pips ---(end of broadcast)--- TIP 3: if posting/reading through Usenet, please send an appropriate subscribe-nomail command to [EMAIL PROTECTED] so that your mess

[SQL] VIEW on lookup table

2004-02-29 Thread JJ Gabor
Hello all, I have a lookup table consisting of 100,000+ rows. 99% of the lookup values resolve to 'Unknown'. Building the lookup table takes a long time. I would like to remove the 'Unknown' entries from the table and provide a VIEW to emulate them. The VIEW would need to provide all 100,000+

[SQL] plpgsql function returning SETOF RECORD Question

2004-02-29 Thread jbduffy
Hi When I run the function below I recieve an error message saying that column definitions need to be specified for a function returing a type RECORD. I was under the impression that the FOR row IN SELECT... loop would assign a column structure to the RECORD type. Am I wrong about this? CREATE

[SQL] Execute Query in Postgres Function

2004-02-29 Thread Sumita Biswas (sbiswas)
How do we execute a Query String in Postgresql function? Or what is the equivalent of the following Code in MSSQL Stored Procedure: SET @QueryToPopulateTemp = "INSERT INTO #Tmp_ConferenceDetail(ConferenceType, ConnectTime, DisconnectTime,DestConversationId, Duration, AppConfId, OrigDevice

Re: [SQL] User defined types -- Social Security number...

2004-02-29 Thread Greg Patnude
Thanks Josh -- I understand that there are valid and invalid SSN's -- similar rules apply to zip codes and area codes... I tried this: SELECT to_char(123456789, '000-00-'); which yields 123-45-6789 -- nicely, I might add... the trick is getting postgreSQL to do this without having to create

[SQL] Triggers

2004-02-29 Thread Philip J. Boonzaaier
The technical reference gives an example of a trigger on a table - employee Just to test this, I have created the following table, CREATE TABLE employee (name VARCHAR(30), age int4, state VARCHAR(2), manager VARCHAR(3), adult VARCHAR(3)); The I created a simple Function, as follows : CREATE FUNC

Re: [SQL] returning a recordset from PLpg/SQL

2004-02-29 Thread Tom Lane
Terence Kearns <[EMAIL PROTECTED]> writes: > I tried > RETURNS SETOF RECORD > but that doesn't work Sure it does, if you use it correctly. Better show us what you did. regards, tom lane ---(end of broadcast)--- TIP 2: you c

[SQL] returning a recordset from PLpg/SQL

2004-02-29 Thread Terence Kearns
Looking at the datatypes you can RETURN, it doesn't seem that there is a way to return a recordset I tried RETURNS SETOF RECORD but that doesn't work I even tried RETURNS SETOF fooTable%ROWTYPE What I would like to do is not that simple, I need to be able to build/declare a record definition wit