Same again: you need to run the generated SQL script (like last time) to create the sequence in the database.<div><br></div><div>In general, you need to do this whenever your table/sequence schema changes. In the case where you just add tables or sequences, running the SQL file again suffices. If you've modified the layout of a table, you might need to manually drop the table first. If you want to modify a table while keeping the existing data... well, I'm sure there's a way, but I <span></span>don't know what it is.<div><br><br>On Friday, April 1, 2016, Yves Cloutier <<a href="mailto:yves.cloutier@gmail.com">yves.cloutier@gmail.com</a>> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div><div><div><div><div><div><div>Hello, <br><br></div>I would like to refactor some code to use a sequence instead of manually incrementing a counter to serve as a unique db table index.<br><br></div>Following an example, I simply did:<br><br>...<br></div>sequence expId<br>...<br><br></div>Then when I want to increment:<br><br>...<br></div>nextId <- nextval expId;<br>...<br><br></div>I recompile, but when I execute I get the following error:<br><br>Fatal initialization error: Sequence 'uw_Portfolipro_expId' does not exist.<br><br></div><div>IS there something else that I need to do, create or initialise in order to use sequences?<br></div><div><br></div>Below is my full code:<br><br>table experienceTable : { Id : int, Description : string}<br> PRIMARY KEY Id<br><br>sequence expId<br><br>fun refresh () =<br> rows <- queryX (SELECT * FROM experienceTable)<br> (fn row => <xml><tr><br> <td>{[<a href="http://row.ExperienceTable.Id" target="_blank">row.ExperienceTable.Id</a>]}</td> <td>{[row.ExperienceTable.Description]}</td><br> <td><form><submit action={deleteExperience <a href="http://row.ExperienceTable.Id" target="_blank">row.ExperienceTable.Id</a>} value="Delete"/></form></td><br> </tr></xml>);<br> return <xml><br> <table border=1><br> <tr> <th>Id</th> <th>Description</th></tr><br> {rows}<br> </table><br><br> <br/><hr/><br/><br><br> <form><br> <table><br> <tr> <th>Description:</th><td><textbox{#Description}/></td> </tr><br> <tr> <th/> <td><submit action={addExperience} value="Add"/></td> </tr><br> </table><br> </form><br> </xml><br><br>(* Add a new experience *)<br>and addExperience experience =<br> nextId <- nextval expId;<br> dml (INSERT INTO experienceTable (Id, Description)<br> VALUES ({[nextId]}, {[readError experience.Description]}));<br> page <- refresh ();<br> return <xml><body><br> {page}<br> </body></xml><br><br>(* Delete a given experience *)<br>and deleteExperience experienceId () =<br> dml (DELETE FROM experienceTable<br> WHERE t.Id = {[experienceId]});<br> page <- refresh ();<br> return <xml><body><br> {page}<br> </body></xml><br><br>fun main () =<br> content <- refresh ();<br> return <xml><body><br> {content}<br> </body></xml><br><br><div><br><br><div><div><div><br><br></div></div></div></div></div>
</blockquote></div></div>