Skip to Main Content

Oracle Database Express Edition (XE)

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Interested in getting your voice heard by members of the Developer Marketing team at Oracle? Check out this post for AppDev or this post for AI focus group information.

returning wrong ID from query

User_AJEV2Feb 6 2021

hello guys i not really expert on oracle . I am a python developer and i have too work with oracle 11 G in a project .
I have a simple table with 3 field the problem is the first field .
I have created the numeric field called ID and after that i created a sequence and a trigger for that to build an auto increment primary key field.
everything works fine but there is a problem. when i use query to get data from table like SELECT id FROM table , the query returns ids started from 1 to end (like rownum) and not the real id from datas and ids is really important to me to get some slice of the return of query and do some thins
my python is 3.6.8
lib is cx_oracle
db version is oracle 11G standard eddition

Comments

User_AJEV2

is there any one here??

Billy Verreynne

Too little detail to assist.
The query in Python is the #1 suspect though. A server typically does exactly what the client requests - which can be different than what you think you've requested.
You can copy and paste the query into command line sqlplus - in fact using sqlplus as a baseline testing tool for any and all Oracle client development is a primary recommendation.

User_CC65I

@user-ajev2
I have a hunch that, when when you created the id field with a sequence, that was initiated with 1 and so on... so, basically if you refer to that column, you will only get the sequence like output
Could you share the table structure i.e. columns and primary keys and if possible some dummy data.

Regards,
Pratyush
https://www.linkedin.com/in/pratyush-basu-26b70b52/

1 - 3

Post Details

Added on Feb 6 2021
3 comments
201 views