functions and sequences

Tech-Archive recommends: Fix windows errors by optimizing your registry



Hi.

I realize that ms sql doesn't really have sequences like Oracle and some other
db's.

I was wondering, given sql server 2000, and the restrictions placed upon
writing user defined functions, is it possible even to do this:

I'd like to write a function that I can call from the db layer to return a
sequence.
It would be defined by a table and column name, and in Oracle it would do a
nextval sort of call on a sequence defined for that table and column.

In ms sql it would increment a column I'm using for sequences and return the
value.

The usage would be in sql statements to supply the a value for an id column.
sort of:

insert into table(col1,col2) values ('x',myFunc.nextseq('table','col2'))


Basically, is there any way to get around the restrictions on writing UDF's in
MS Sql 2000 to do that? I'm trying to keep a certain level of sql generic.

Thanks for your patience

.



Relevant Pages

  • Re: To LinQ or not LinQ
    ... The assertion that SQL is _strictly_ set-based doesn't make sense to me either, since when you query the database, records always have to be returned in _some_ order. ... Likewise, while it's true that the LINQ syntax is very much centered around the IEnumerableinterface, there's nothing about the interface that requires the sequences to be well-defined. ... It's only practicality that causes that not to happen in practice. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: OOP/OOD Philosophy
    ... >>Sure by avoiding dates, sequences ... > I don't avoid dates, ... Oracle has INTERVAL and TO_DATEbut SQL*Server, ... which cannot be resolved by relying on the standardness of SQL. ...
    (comp.object)
  • Re: PHP/Oracle SQL statements, OciParse
    ... just my sql syntax is ... If you're going to use Oracle and don't have access to a DBA, ... Read up about sequences ... (and probably about triggers - a combination of a sequence and a before- ...
    (comp.lang.php)
  • Re: How to use sequences in DBI/DBD::Oracle with bind
    ... > SQL ... > Does anybody have a clue on how to bind oracle sequences. ... > You might think I should have user bind variables from the start, ...
    (perl.dbi.users)
  • Re: Limit of 1050 columns for ANSI joins
    ... comprehensive than Oracle SQL. ... I'm trying not to have any auto-generated SQL on my system, ... Index your schema properly and think about the proper design. ...
    (comp.databases.oracle.server)