Oracle Sequence/ ASP.NET C# problem
Posted on 2006-11-09
I created an Oracle table in Toad, then made an ASP.NET page with a gridview and detailsview.
I got inserts, deletes and updates to work from the detailsview (very easily). But it was using an inputted number to update the ID.
Since the ID is the Primary Key I need to use an Oracle sequence to increment.
However when I created a Sequence in Oracle and then tried to substitute
NEWS_SEQ.NEXTVAL for :ID in the Insert command, I got the error:"ORA-01036: illegal variable name/number"
I can run the query in Toad:
INSERT INTO NEWS (ID, TITLE) VALUES(NEWS_SEQ.NEXTVAL, 'test')
So I think I have zeroed in on the problem.
Any Oracle/.NET Gurus out there? There seems to be a conflict between using an Oracle Sequence nextval and the way ASP.NET writes the parameter.
Do I have to look up the sequence.nextval before I do the Insert, and use that value in the insert command? If so, How would I do it?
='INSERT INTO "NEWS" ("ID", ...") VALUES (NEWS_SEQ.NEXTVAL, ...)'
<asp:Parameter Name="ID" Type="Decimal" />