[SQL] Running a file
I'm runnin postgres 7.?? (Last RPM package available from the site). I want to create a few DB creation scripts so I can "publish" that afterwards. On Oracle there's a such possibility but I haven't seen anything comaprable in the docs ... I however think I'm missing one of the very first possibility of "pgsql". Could someone point me were I could find some more infos on that matter ? Tx, Thomas, p.s. : Merry Xmas for some / Enjoy Ead / Merry Solstice for the others :-) -- Sun Dec 24 13:32:35 CET 2000 Thomas SMETSe-mail : [EMAIL PROTECTED] Av. de la Brabançonne 133 / 3 Tel. : +32 (0)2 742. 05. 94. 1030 Bruxelles === Quote of the Day = The FALAFEL SANDWICH lands on my HEAD and I become a VEGETARIAN ... = End of Quote ===
[ADMIN] Running a file
Hi Thomas, Is it possible you're looking for: psql -f script.sql ? Regards, -- Raju > "Thomas" == Thomas SMETS <[EMAIL PROTECTED]> writes: Thomas> I'm runnin postgres 7.?? (Last RPM package available from Thomas> the site). Thomas> I want to create a few DB creation scripts so I can Thomas> "publish" that afterwards. On Oracle there's a such Thomas> possibility but I haven't seen anything comaprable in the Thomas> docs ... I however think I'm missing one of the very Thomas> first possibility of "pgsql". Could someone point me were Thomas> I could find some more infos on that matter ? Thomas> Tx, Thomas> Thomas, Thomas> p.s. : Merry Xmas for some / Enjoy Ead / Merry Solstice Thomas> for the others :-) -- Raju Mathur [EMAIL PROTECTED] http://kandalaya.org/
Re: [SQL] Invoice number
Thus spake Oliver Elphick > >If so, why is no rollbackable an issue? All you should need is unique > >numbers. Not necessarily exactly sequential numbers. > > For invoice numbers, it matters. > > Numbers missing from such a sequence are likely to provoke questions from > auditors and taxmen; why borrow trouble? I solved this exact problem once before in another database (Progres) but it should work here too. What I did was select a maximum number of concurrent transactions (I picked 10) and created a table with two columns, a token and a number. For every sequence that I needed I seeded the table with 10 rows each with the name of the sequence so that my next routine could reference it and with the number column set from 1 to 10. When I need a new number I simply find the smallest number for that token, lock the row, use the number in my work and commit everything when I was done. In Postgres I was able to scan through each number in order stopping at the first unlocked one so the process didn't block. Not sure how to apply that here. Perhaps a third column that you plug in your process ID or something so that you do something like this. UPDATE numbers SET reserve = [my ID] WHERE seqname = [token] AND seqnum = (SELECT MIN(seqnum) FROM numbers WHERE seqname = [token] AND reserve IS NULL); You would have to have some way of cleaning these up pretty quickly if your app crashed or failed to set reserve back to NULL. The other issue here is that strictly speaking you may not get your numbers sequentially but you won't skip any. In my experience the accountants have been OK with that. Hmmm. Perhaps "SELECT ... FOR UPDATE" would work instead of that extra column. Still need a way of skipping locked records though. Perhaps in a future version of PostgreSQL we can have a first class serial type that handles all of this. -- D'Arcy J.M. Cain| Democracy is three wolves http://www.druid.net/darcy/| and a sheep voting on +1 416 425 1212 (DoD#0082)(eNTP) | what's for dinner.
Re: [SQL] Running a file
On Sun, 24 Dec 2000, Thomas SMETS wrote: > I'm runnin postgres 7.?? (Last RPM package available from the site). > > I want to create a few DB creation scripts so I can "publish" that > afterwards. > On Oracle there's a such possibility but I haven't seen anything > comaprable in the docs ... > I however think I'm missing one of the very first possibility of > "pgsql". > Could someone point me were I could find some more infos on that matter > ? Are you talking about writing external scripts and importing them into Postgres in a manner similar to the @ function in SQL*Plus? In psql, you can use \i to import scripts to do that. -- Brett http://www.chapelperilous.net/~bmccoy/ --- Reading is to the mind what exercise is to the body.