Get Sequence Name (Oracle)?
I don't have access to see the database, but I have the ability to create database objects (via an xml file). The xml documentation says that if I set an attribute called "identity" to true then a sequence will be created. Is i开发者_如何学Got possible for me to write logic that would return the name of the sequence so that I can use nextVal when I'm writing INSERT statements?
Robert
Here's the documentation, do a find on the word "identity"...
If you can run select statements, then you might be able to try select * from user_sequences to get the names of sequences. Otherwise, could you please send the documentation for this database creation utility that you are using, if it is public. Otherwise, it will be very difficult to answer this question.
EDIT:
After a review of the documentation, it said that if you created a table with a primary key, it would create a sequence with the following rules, quoted directly from the documentation:
Primary keys must contain one columnref subelement that includes a single attribute, name, that references the column name to include in the primary key. In SQL Server, the key is mapped as an identity field with an auto-incremented value. On Oracle, a sequence is automatically created with the table name plus _seq suffix.
Thus, your query would be:
select * from all_sequences where sequence_name = upper(tablename || '_SEQ');
精彩评论