Thread: SQL parse error
Hello all, My following problem is: swports=# select substring(cp from 1 for 4)::int4 from out2cp; ERROR: pg_atoi: error in "6.1,": can't parse ".1," SQL syntax is apparently OK. When I omit the typecast, the query works: swports=# select substring(cp from 1 for 4) from out2cp;substr --------318231823182 -8<- text deleted --- The cp entries are varchars in form NNNN.N, where N is numeral. So can someone explain why the parse error? Bye Borek -- ===================================================================== BOREK LUPOMESKY Usti nad Labem, Czech Republic, Europe WWW: http://www.volny.cz/borekl/ PGP keyid: B6A06AEB ==========[ MIME/ISO-8859-2 & PGP encrypted mail welcome ]===========
Hi Borek, What version of PostgreSQL are you using? This works fine for me on 7.02. Time to update, maybe? Hope this helps Francis > > Hello all, > > My following problem is: > > swports=# select substring(cp from 1 for 4)::int4 from out2cp; > ERROR: pg_atoi: error in "6.1,": can't parse ".1," > > SQL syntax is apparently OK. When I omit the typecast, the query > works: > > swports=# select substring(cp from 1 for 4) from out2cp; > substr > -------- > 3182 > 3182 > 3182 > -8<- text deleted --- > > The cp entries are varchars in form NNNN.N, where N is numeral. > So can someone explain why the parse error? >
On Tue, 12 Dec 2000, Francis Solomon wrote: FS> What version of PostgreSQL are you using? This works fine for me on FS> 7.02. Time to update, maybe? Does not seem to be the case... ld01ad02:~$ rpm -q postgresql postgresql-7.0.2-2 Bye Borek -- ===================================================================== BOREK LUPOMESKY Usti nad Labem, Czech Republic, Europe WWW: http://www.volny.cz/borekl/ PGP keyid: B6A06AEB ==========[ MIME/ISO-8859-2 & PGP encrypted mail welcome ]===========
All- <soapbox> While it is not always the case, I see many responses to questions in the form of "Why don't you just upgrade- that's supportedin version XXX". Let me give you several reasons why this is not always possible. 1. Support software is not compatible. I use Chili!soft for Linux, a webpage/asp solution. Even tho I use the most currentversion of Chili!Soft, it currently only supports Postgresql 6.5.2. I don't have the option of upgrading. My DB isused by this software, so I would break the dependancy if I upgraded. 2. DB Users may not be DBAs. If a user is not responsible for the maintenance of the server or the software running on it(such as a third party ISP or IS department), upgrading is not a choice. While suggestions can usually be made, the useris not at liberty to make it happen. Being that this is an SQL forum for help, it seems appropriate that any reply for assistance should be directed towards theversion is use. This is not intended to be a flame against this particular reply, just an observation is general. Whilestating the version that a particular solution is available is not completely inappropriate, every attempt should bemade to offer help in the version that is being presented by the request. </soapbox> Sorry if this seems long-winded- it just seems that someone needed to say it... Kenn ____________________________________________ Kenn Thompson Senior Web Architect Adesta Communications Work: 402.233.7595 Cell: 402.210.6326 >>> "Francis Solomon" <francis@stellison.co.uk> 12/12/00 04:21AM >>> Hi Borek, What version of PostgreSQL are you using? This works fine for me on 7.02. Time to update, maybe? Hope this helps Francis > > Hello all, > > My following problem is: > > swports=# select substring(cp from 1 for 4)::int4 from out2cp; > ERROR: pg_atoi: error in "6.1,": can't parse ".1," > > SQL syntax is apparently OK. When I omit the typecast, the query > works: > > swports=# select substring(cp from 1 for 4) from out2cp; > substr > -------- > 3182 > 3182 > 3182 > -8<- text deleted --- > > The cp entries are varchars in form NNNN.N, where N is numeral. > So can someone explain why the parse error? >
On Tue, 12 Dec 2000, Tom Lane wrote: TL> I can't duplicate the problem either. I tried: TL> TL> play=> select substring(cp from 1 for 4)::int4 from out2cp; TL> ?column? TL> ---------- TL> 3182 TL> 3182 TL> (2 rows) TL> TL> Does anyone else see a failure with this? If so what platform are you TL> on, and what build of Postgres are you using? Well, I'm running under RedHat Linux 6.x (ia-32) and now I don't really recall for sure where did I take the RPM, but I think I downloaded it from ftp.postgresql.org. OK, tomorrow I'll do some more tests to see where the problem lies (you know, intranet-homed machine not accessible from public Internet). Bye Borek -- ===================================================================== BOREK LUPOMESKY Usti nad Labem, Czech Republic, Europe WWW: http://www.volny.cz/borekl/ PGP keyid: B6A06AEB ==========[ MIME/ISO-8859-2 & PGP encrypted mail welcome ]===========
Borek Lupoměský <borekl@volny.cz> writes: > On Tue, 12 Dec 2000, Francis Solomon wrote: FS> What version of PostgreSQL are you using? This works fine for me on FS> 7.02. Time to update, maybe? > Does not seem to be the case... > ld01ad02:~$ rpm -q postgresql > postgresql-7.0.2-2 I can't duplicate the problem either. I tried: play=> create table out2cp(cp varchar(6)); CREATE play=> insert into out2cp values('3182.1'); INSERT 405833 1 play=> insert into out2cp values('3182.2'); INSERT 405834 1 play=> select substring(cp from 1 for 4)::int4 from out2cp;?column? ---------- 3182 3182 (2 rows) Does anyone else see a failure with this? If so what platform are you on, and what build of Postgres are you using? regards, tom lane
On Tue, 12 Dec 2000, Tom Lane wrote: TL> play=> create table out2cp(cp varchar(6)); TL> CREATE TL> play=> insert into out2cp values('3182.1'); TL> INSERT 405833 1 TL> play=> insert into out2cp values('3182.2'); TL> INSERT 405834 1 TL> play=> select substring(cp from 1 for 4)::int4 from out2cp; TL> ?column? TL> ---------- TL> 3182 TL> 3182 TL> (2 rows) When I do this, it works for me, too. But when I do it on my current database, something breaks. The table I work on is: swports=# \d out2cp Table "out2cp"Attribute | Type | Modifier -----------+-------------+----------cp | varchar(10) | outlet | varchar(10) | location | varchar(32) | Index: o2c_cp Values in cp field look like this: swports=# select cp from out2cp ; cp ---------3182.43182.73182.23182.53182.63182.83169.13169.33169.43169.73165.1 Bye Borek -- ===================================================================== BOREK LUPOMESKY Usti nad Labem, Czech Republic, Europe WWW: http://www.volny.cz/borekl/ PGP keyid: B6A06AEB ==========[ MIME/ISO-8859-2 & PGP encrypted mail welcome ]===========
Borek Lupoměský <borekl@volny.cz> writes: > When I do this, it works for me, too. But when I do it on my current > database, something breaks. Hm. The obvious question is: are you *sure* all the entries in your table look like "NNNN.N"? regards, tom lane
On Wed, 13 Dec 2000, Tom Lane wrote: TL> Borek Lupoměský <borekl@volny.cz> writes: TL> > When I do this, it works for me, too. But when I do it on my current TL> > database, something breaks. TL> TL> Hm. The obvious question is: are you *sure* all the entries in your TL> table look like "NNNN.N"? You're right -- not all of them do, there are some anomalous ones. Thanks for your help and pardon my ignorance. Bye Borek -- ===================================================================== BOREK LUPOMESKY Usti nad Labem, Czech Republic, Europe WWW: http://www.volny.cz/borekl/ PGP keyid: B6A06AEB ==========[ MIME/ISO-8859-2 & PGP encrypted mail welcome ]===========
Hi, How can I declare an array in plpgsql?? when I use declare url text[10]; ERROR: parse error at or near "[" if I use _text; declare is OK, however, when I assgin a value after BEGIN url[i]:=whatever; get same ERROR, Is it possible to return an array from a plpgsql function?? Jie LIANG Internet Products Inc. 10350 Science Center Drive Suite 100, San Diego, CA 92121 Office:(858)320-4873 jliang@ipinc.com www.ipinc.com
> Is it possible to return an array from a plpgsql function?? AICR, it is impossible. In addition, it's not suggested using arrays at all: the array based logic is foreign from SQL solutions. In fact PostgreSQL doesn't have a good array support. My friend who built our logic data model, said that the pg_group table is a bad idea in PostgreSQL, he would have created a new table to store relations between groups and users. I don't think it can be modified after such a long time. Regards, Zoltan