Re: [cx-oracle-users] How do you use Aliases?
Brought to you by:
atuining
From: Shai B. <sh...@pl...> - 2015-06-09 22:50:04
|
I work with Oracle almost exclusively through cx_oracle, and it's been hit- and-miss with using reserved words as names. Sometimes quoting them works, sometimes it doesn't. Haven't researched it to find more accurate descriptions. Glad your problem is solved, Shai. On Wednesday 10 June 2015 01:38:43 Jay wrote: > Hah! That was it. I didn't realize UID was a reserved word. Porting > from MySQL to Oracle, and it didn't occur to me that UID would be reserved > in Oracle. > > I suspect there's something in Python that treats UID differently as a > reserved word. I did have to quote it in all other clients, so EMPLID "UID" > so perhaps they handle the quoted differently or something. Not sure. > > Anyhow, thanks for the pointer. (: > > -= Jay =- > > On Tue, Jun 9, 2015 at 4:02 PM, Shai Berger <sh...@pl...> wrote: > > I suspect this is because UID is a reserved word. > > > > That does not explain why the query would work on plsql or perl and not > > with > > Python; but see if it works with a different name, say "UIZ". > > > > HTH, > > > > Shai. > > > > On Wednesday 10 June 2015 00:50:56 Jay wrote: > > > Yes, > > > > > > It also results in "cx_Oracle.DatabaseError: ORA-00923: FROM > > > keyword > > > > > > not found where expected" > > > > > > I know when I run the command from plsql, or perl, I can quote the > > > > > > Alias "UID" and the query works as expected. But I've tried every way I > > > > can > > > > > find on the Internet of quoting a string to Oracle with Python, and > > > none > > > > of > > > > > it seems to work. for some reason, python just refuses to pass that > > > > string > > > > > to Oracle as a quoted value it would seem. > > > > > > -= Jay =- > > > > > > > > > On Tue, Jun 9, 2015 at 3:27 PM, Fawcett, David (MNIT) < > > > > > > Dav...@st...> wrote: > > > > Have you tried > > > > > > > > 'SELECT EMPLID AS UID FROM TABLE WHERE EMPLID=:emplid' > > > > > > > > > > > > > > > > *From:* Jay [mailto:ja...@sc...] > > > > *Sent:* Tuesday, June 09, 2015 3:49 PM > > > > *To:* cx-...@li... > > > > *Subject:* [cx-oracle-users] How do you use Aliases? > > > > > > > > > > > > > > > > Trying to use an alias with cx_Oracle and nothing I'm trying seems to > > > > work: > > > > > > > > > > > > > > > > cursor.execute('SELECT EMPLID "UID" FROM TABLE WHERE EMPLID=:emplid', > > > > {'emplid':'123456'}): > > > > > > > > > > > > > > > > fails with: > > > > > > > > > > > > > > > > cx_Oracle.DatabaseError: ORA-00923: FROM keyword not found where > > > > expected > > > > > > I've tried every way I can find on the internets to quote/insert that > > > > Alias, but nothing seems to work. All I'm trying to do is alias > > > > EMPLID > > > > as > > > > > > UID. > > > > > > > > > > > > > > > > Is this just something that can't be done with this driver?? or > > > > Python? or?? > > > > > > > > > > > > > > > > -= Jay =- > > > > ------------------------------------------------------------------------- > > > > > > ----- > > > > > > > > _______________________________________________ > > > > cx-oracle-users mailing list > > > > cx-...@li... > > > > https://lists.sourceforge.net/lists/listinfo/cx-oracle-users > > > > ------------------------------------------------------------------------- > > ----- _______________________________________________ > > cx-oracle-users mailing list > > cx-...@li... > > https://lists.sourceforge.net/lists/listinfo/cx-oracle-users |