Re: How do you use Aliases?

Jay <[email protected]> Tue, 9 Jun 2015 16:38:43 -0600
Newsgroups gmane.comp.python.db.cx-oracle
Message-ID <CAJsMCEhU1jrZLo-fc6HYT1k6cYgatbCUJz=RsiL2aoqHV7YpMQ@mail.gmail.com>
     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 <shai-9mtU2oJkgntWk0Htik3J/[email protected]> 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) <
> >
> > [email protected]> wrote:
> > >  Have you tried
> > >
> > > 'SELECT EMPLID AS UID FROM TABLE WHERE EMPLID=:emplid'
> > >
> > >
> > >
> > > *From:* Jay [mailto:[email protected]]
> > > *Sent:* Tuesday, June 09, 2015 3:49 PM
> > > *To:* cx-oracle-users-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org
> > > *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-oracle-users-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org
> > > https://lists.sourceforge.net/lists/listinfo/cx-oracle-users
>
>
> ------------------------------------------------------------------------------
> _______________________________________________
> cx-oracle-users mailing list
> cx-oracle-users-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org
> https://lists.sourceforge.net/lists/listinfo/cx-oracle-users
>

------------------------------------------------------------------------------

_______________________________________________
cx-oracle-users mailing list
cx-oracle-users-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org
https://lists.sourceforge.net/lists/listinfo/cx-oracle-users