Re: [SQL] Entering data in serial column
Hi There, If you omit the column names, the values are assumed to follow the order of the column names in the table definition. So if you have the columns with default values at the end of the table definition, then you don't need to insert a value for them. Same as in C. It is better practice though to name the columns, as then if you rebuild your schema, or alter the table (Effecting the order of the columns) then the insert statement retains its meaning. If you have 40 columns, then you are going to have an awfull lot of trouble maintaining the insert statement anyway. Whats an extra few lines of SQL with the column names (they will probably help you keep track of which one you are up to anyway). Devrim GUNDUZ <[EMAIL PROTECTED]> Wrote: > Now, since id is a serial, while inserting data into info I write: > > INSERT INTO info (name,surname,address) VALUES ('$name','$surname', > '#address'); > > Is there a shorter way of doing this? I mean, if I had 40 fields in this > table, would I have to write all the fields? I mean, is there a syntax > beginning like > > INSERT INTO info VALUES ( -- David Stanaway ---(end of broadcast)--- TIP 6: Have you searched our list archives? http://archives.postgresql.org
Re: [SQL] TEXT in select
I've tried (column indexdef is of type text) select indexdef from pg_indexes where indexdef like '%pg_proc%' ; select indexdef from pg_indexes where position('pg_proc' in indexdef) > 0 ; select upper(indexdef) from pg_indexes where position('pg_proc' in indexdef) > 0 ; and all three worked as intended. Sorry, but I can't see any reason why it doesn't work on your machine. Regards, Christoph > Hi, > > does anybody know a way, how to implement the content of a field of type > TEXT > into a query? > > if i am trying: > select * from testtable WHERE testTEXT LIKE '%testString%' > > i am getting always an empty selection, although there is a record existing. > The same with > > select * from testtable WHERE position ('testString' in testTEXT) > > 0; > > Additional, is there a way to use the UPPER()-function to the content of the > TEXT-field? > > Thanks in advance, > Michael ---(end of broadcast)--- TIP 1: subscribe and unsubscribe commands go to [EMAIL PROTECTED]
Re: [SQL] What is wrong?
On 28 Sep 2001, Wei Weng wrote: > Hi there. I wrote a simple postgresql sql function as follows: > > create function test() returns integer as ' > begin > fixed_path := translate (''/text'', ''\\'', ''/''); > raise notice ''fixed_path:'', fixed_path; > return 1; > end > ' language 'plpgsql'; > > And when I ran it as > > pgsql>select test(); > > I got: > > NOTICE: plpgsql: ERROR during compile of test near line 8 > ERROR: unterminated string starting on line 10 > > What is wrong? (something fishy about translate function?) Could anyone > enlighten me on this? I think you need to use four backslashes to do the quoting for the backslash. Plus you're going to need to declare that variable. ---(end of broadcast)--- TIP 2: you can get off all lists at once with the unregister command (send "unregister YourEmailAddressHere" to [EMAIL PROTECTED])
[SQL] Entering data in serial column
Hi all, Let's say I have a table named "info" having the following fields: name char(40), surname char(40), address char(40), id serial Now, since id is a serial, while inserting data into info I write: INSERT INTO info (name,surname,address) VALUES ('$name','$surname', '#address'); Is there a shorter way of doing this? I mean, if I had 40 fields in this table, would I have to write all the fields? I mean, is there a syntax beginning like INSERT INTO info VALUES ( ? Regards and best wishes, Love, respect,sharing,Linux and PostgreSQL -- Devrim GÜNDÜZ Web & System Administrator Web ve Sistem Yoneticisi (www.oper.metu.edu.tr) [EMAIL PROTECTED] [EMAIL PROTECTED] Phone : +90-535-328-9594 (cellular) Phone : +90-312-295-9595 (work : 09:00/17:00 on weekdays+Saturday) Phone : +90-312-286-5906 (home) http://devrim.oper.metu.edu.tr -- ---(end of broadcast)--- TIP 6: Have you searched our list archives? http://archives.postgresql.org