<html><head><style>body{font-family:Helvetica,Arial;font-size:13px}</style></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;"><div id="bloop_customfont" style="font-family:Helvetica,Arial;font-size:13px; color: rgba(0,0,0,1.0); margin: 0px; line-height: auto;">Hmm, it seems to me that your db schema is suboptimal here but without knowing the schema this remains of course guessing.</div><div id="bloop_customfont" style="font-family:Helvetica,Arial;font-size:13px; color: rgba(0,0,0,1.0); margin: 0px; line-height: auto;">I would expect your schema to be something like this</div><div id="bloop_customfont" style="font-family:Helvetica,Arial;font-size:13px; color: rgba(0,0,0,1.0); margin: 0px; line-height: auto;"><br></div><div id="bloop_customfont" style="font-family:Helvetica,Arial;font-size:13px; color: rgba(0,0,0,1.0); margin: 0px; line-height: auto;">tbl_voyages</div><div id="bloop_customfont" style="font-family:Helvetica,Arial;font-size:13px; color: rgba(0,0,0,1.0); margin: 0px; line-height: auto;"><br></div><div id="bloop_customfont" style="font-family:Helvetica,Arial;font-size:13px; color: rgba(0,0,0,1.0); margin: 0px; line-height: auto;">voyage_id,</div><div id="bloop_customfont" style="font-family:Helvetica,Arial;font-size:13px; color: rgba(0,0,0,1.0); margin: 0px; line-height: auto;">fk_vessel_id,</div><div id="bloop_customfont" style="font-family:Helvetica,Arial;font-size:13px; color: rgba(0,0,0,1.0); margin: 0px; line-height: auto;">from,</div><div id="bloop_customfont" style="font-family:Helvetica,Arial;font-size:13px; color: rgba(0,0,0,1.0); margin: 0px; line-height: auto;">to,</div><div id="bloop_customfont" style="font-family:Helvetica,Arial;font-size:13px; color: rgba(0,0,0,1.0); margin: 0px; line-height: auto;">departure,</div><div id="bloop_customfont" style="font-family:Helvetica,Arial;font-size:13px; color: rgba(0,0,0,1.0); margin: 0px; line-height: auto;">arrival,</div><div id="bloop_customfont" style="font-family:Helvetica,Arial;font-size:13px; color: rgba(0,0,0,1.0); margin: 0px; line-height: auto;">….</div><div id="bloop_customfont" style="font-family:Helvetica,Arial;font-size:13px; color: rgba(0,0,0,1.0); margin: 0px; line-height: auto;"><br></div><div id="bloop_customfont" style="font-family:Helvetica,Arial;font-size:13px; color: rgba(0,0,0,1.0); margin: 0px; line-height: auto;"><br></div><div id="bloop_customfont" style="font-family:Helvetica,Arial;font-size:13px; color: rgba(0,0,0,1.0); margin: 0px; line-height: auto;">tbl_vessels</div><div id="bloop_customfont" style="font-family:Helvetica,Arial;font-size:13px; color: rgba(0,0,0,1.0); margin: 0px; line-height: auto;"><br></div><div id="bloop_customfont" style="font-family:Helvetica,Arial;font-size:13px; color: rgba(0,0,0,1.0); margin: 0px; line-height: auto;">vessel_id,</div><div id="bloop_customfont" style="font-family:Helvetica,Arial;font-size:13px; color: rgba(0,0,0,1.0); margin: 0px; line-height: auto;">vessel_name,</div><div id="bloop_customfont" style="font-family:Helvetica,Arial;font-size:13px; color: rgba(0,0,0,1.0); margin: 0px; line-height: auto;">vessel_capacity,</div><div id="bloop_customfont" style="font-family:Helvetica,Arial;font-size:13px; color: rgba(0,0,0,1.0); margin: 0px; line-height: auto;">…</div><div id="bloop_customfont" style="font-family:Helvetica,Arial;font-size:13px; color: rgba(0,0,0,1.0); margin: 0px; line-height: auto;"><br></div><div id="bloop_customfont" style="font-family:Helvetica,Arial;font-size:13px; color: rgba(0,0,0,1.0); margin: 0px; line-height: auto;">both voyage_id and vessel_id are sequences.</div><div id="bloop_customfont" style="font-family:Helvetica,Arial;font-size:13px; color: rgba(0,0,0,1.0); margin: 0px; line-height: auto;">fk_vessel_id is the foreign key holding the vessel_id for the vessel that is doing the voyage (voyage_id).</div><div id="bloop_customfont" style="font-family:Helvetica,Arial;font-size:13px; color: rgba(0,0,0,1.0); margin: 0px; line-height: auto;"><br></div><div id="bloop_customfont" style="font-family:Helvetica,Arial;font-size:13px; color: rgba(0,0,0,1.0); margin: 0px; line-height: auto;">If this is your schema then please elaborate on the problem your having.</div><div id="bloop_customfont" style="font-family:Helvetica,Arial;font-size:13px; color: rgba(0,0,0,1.0); margin: 0px; line-height: auto;"><br></div><div id="bloop_customfont" style="font-family:Helvetica,Arial;font-size:13px; color: rgba(0,0,0,1.0); margin: 0px; line-height: auto;">regards</div><div id="bloop_customfont" style="font-family:Helvetica,Arial;font-size:13px; color: rgba(0,0,0,1.0); margin: 0px; line-height: auto;"><br></div><div id="bloop_customfont" style="font-family:Helvetica,Arial;font-size:13px; color: rgba(0,0,0,1.0); margin: 0px; line-height: auto;">bart</div><div id="bloop_customfont" style="font-family:Helvetica,Arial;font-size:13px; color: rgba(0,0,0,1.0); margin: 0px; line-height: auto;"><br></div><div id="bloop_customfont" style="font-family:Helvetica,Arial;font-size:13px; color: rgba(0,0,0,1.0); margin: 0px; line-height: auto;"><br></div> <div id="bloop_sign_1388789864311614976" class="bloop_sign"><span style="font-family:helvetica,arial;font-size:13px"></span>— <div><div apple-content-edited="true"><div style="font-family: Helvetica; font-size: medium; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2; word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;"><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;"><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;"><div style="margin: 0px; color: rgb(34, 34, 34); font-family: arial, sans-serif; font-size: 13px;"><span class="Apple-style-span" style="border-collapse: separate; border-spacing: 0px;"><b><i><u><span lang="EN-US" xml:lang="EN-US" style="font-size: 10pt; font-family: 'Century Gothic', sans-serif; color: red;">Our office will be closed on:</span></u></i></b></span></div><div style="margin: 0px; color: rgb(34, 34, 34); font-family: arial, sans-serif; font-size: 13px;"><b><i><span style="font-size: 10pt; font-family: 'Century Gothic', sans-serif; color: red;">24 (afternoon) - <a href="tel://25 - 31/12/2013">25 - 31/12/2013</a> & <a href="http://airmail.calendar/2014-01-01%2012:00:00%20GMT+1">01/01/2014</a></span></i></b></div></div></div></div></div></div><div><br>Bart Pietercil<br><span>Sent with aMac</span></div></div> <br><p style="color:#A0A0A8;">On 3 Jan 2014 at 23:55:08, william humphrey (<a href="mailto://bill@bluewatermaritime.com">bill@bluewatermaritime.com</a>) wrote:</p> <blockquote type="cite" class="clean_bq"><span><div><div>Bart
<br>
<br>Thank you for the clear description. I'm still trying to decide which
<br>would be more useful for me. There are like thirty vessels and each
<br>new voyage will be for one of the vessels. Only one vessel in each new
<br>voyage. But if I just auto increment for voyages it is not as useful
<br>as auto increment that is unique only to each vessel for that voyage.
<br>That would mean the field would not be a unique value for the voyages
<br>as it would only be the combination of vessel number and voyage number
<br>only that is unique.
<br>
<br>Bill
<br>
<br>On Fri, Jan 3, 2014 at 5:56 PM, Bart Pietercil
<br><bart.pietercil@cognosis.be> wrote:
<br>> Theoretically you can. What I don’t know is whether the Valentina Engine
<br>> already supports it.
<br>> The sequence generator has been added to vStudio in order to support the
<br>> Postgresql engine.
<br>> In Postgresql you would do
<br>>
<br>> add field vessel_nr serial (or big serial).
<br>> This is shorthand for
<br>>
<br>> add field vessel_nr integer (or bigint) unique
<br>> create sequence seq_vessel_nr
<br>> set default value of field vessel_nr to nextval(seq_vessel_nr)
<br>>
<br>> so now you have a field vessel_nr with an autoincrementing value on every
<br>> insert (creation of vessel trip?)
<br>> the only thing left to do is , if you already have data in your vessel
<br>> table, generate numbers for the existing values.
<br>> And the last thing to do is set the startvalue of seq_vessel_nr to
<br>> max(vessel_nr)+1.
<br>>
<br>> From hereon your vessel_nr will autoincrement with the correct number
<br>>
<br>> hth
<br>>
<br>> bart
<br>> —
<br>> Our office will be closed on:
<br>> 24 (afternoon) - 25 - 31/12/2013 & 01/01/2014
<br>>
<br>> Bart Pietercil
<br>> Sent with aMac
<br>>
<br>> On 3 Jan 2014 at 16:47:59, william humphrey (bill@bluewatermaritime.com)
<br>> wrote:
<br>>
<br>> Can that kind of create sequence be done after the fact of table
<br>> finished and data already in?
<br>>
<br>> On Fri, Jan 3, 2014 at 11:23 AM, Ruslan Zasukhin
<br>> <ruslan_zasukhin@valentina-db.com> wrote:
<br>>> On 1/3/14, 4:46 PM, "william humphrey" <bill@bluewatermaritime.com> wrote:
<br>>>
<br>>>> I've been thinking that a sequence maintained with a trigger might be
<br>>>> very useful for other things too. I never thought of numbering
<br>>>> sequentially the voyages of each vessel. It solves some other
<br>>>> problems. Right now voyage numbers increment from zero at the start of
<br>>>> each new year (which is what caused the problem) but there is no
<br>>>> reason why I can't have an extra field which has every voyage for that
<br>>>> vessel down through the years.
<br>>>
<br>>> Do you talk about CERATE SEQUENCE?
<br>>>
<br>>>
<br>>> For simple case, consider SERIAL32 or SERIAL64 pseudo-types,
<br>>> As even more simple things.
<br>>>
<br>>>
<br>>> --
<br>>> Best regards,
<br>>>
<br>>> Ruslan Zasukhin
<br>>> VP Engineering and New Technology
<br>>> Paradigma Software, Inc
<br>>>
<br>>> Valentina - Joining Worlds of Information
<br>>> http://www.paradigmasoft.com
<br>>>
<br>>> [I feel the need: the need for speed]
<br>>>
<br>>>
<br>>> _______________________________________________
<br>>> Valentina mailing list
<br>>> Valentina@lists.macserve.net
<br>>> http://lists.macserve.net/mailman/listinfo/valentina
<br>>
<br>>
<br>>
<br>> --
<br>> http://www.bluewatermaritime.com
<br>> _______________________________________________
<br>> Valentina mailing list
<br>> Valentina@lists.macserve.net
<br>> http://lists.macserve.net/mailman/listinfo/valentina
<br>>
<br>>
<br>> _______________________________________________
<br>> Valentina mailing list
<br>> Valentina@lists.macserve.net
<br>> http://lists.macserve.net/mailman/listinfo/valentina
<br>>
<br>
<br>
<br>
<br>--
<br>http://www.bluewatermaritime.com
<br>_______________________________________________
<br>Valentina mailing list
<br>Valentina@lists.macserve.net
<br>http://lists.macserve.net/mailman/listinfo/valentina
<br></div></div></span></blockquote></body></html>