473,385 Members | 1,372 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Second call: third edition of SQL FOR SMARTIES

I am working on the third edition of SQL FOR SMARTIES. If anyone has
an SQL programming technique, trick or tip that they think should be in
the book, drop me an email.

You get a virtual beer and your name in the book. Even better, if you
have an improvement on something in the second edition, you get two
virtual beers and a chance to humilate me in my own book!

Code should Standard SQL-92 or SQL-99, but if you do not know Standard
SQL, then use vendor code that maps into Standard SQL (the most common
example would be temporal functions) or it should be portable (i.e. The
MOD() function is not part of SQL-92, but every SQL product has some
version of it).

Nov 12 '05 #1
1 2169

--CELKO-- wrote:
I am working on the third edition of SQL FOR SMARTIES. If anyone has
an SQL programming technique, trick or tip that they think should be in the book, drop me an email.

You get a virtual beer and your name in the book. Even better, if you have an improvement on something in the second edition, you get two
virtual beers and a chance to humilate me in my own book!

Code should Standard SQL-92 or SQL-99, but if you do not know Standard SQL, then use vendor code that maps into Standard SQL (the most common example would be temporal functions) or it should be portable (i.e. The MOD() function is not part of SQL-92, but every SQL product has some
version of it).


I'm curious to know how positioning and scrolling in a set can be done
in SQL (and in commercial products) in particular when 1 table is
involved with logical keys composed of multiple columns.

I see 2 components for it and a hole in the SQL standard.

The first component: select ... from y,z, t

can have where, order by, group, ...

The second component: the cursor: declare cursor for <component 1>

Finally: open cursor.

One of the basic, often occuring subset is

select ... from X where ... order by ...

So with 1 table involved, a where clause, an order.

SQL-92 has a row-value constructor clause that allows to write:

select ... from X where (c1,c2,c3, ...) <operator>
("C1","C2","...", ...)

which allows to define a where clause on composite logical keys
(multiple columns). Add an index on the logical keys and the row-value
constructor matches nicely the index when 1 table is involved. But
row-value constructors apply to a more elaborate set also (select on
multiple tables).

On the cursor side the SQL standard was not consistent in its
evolution..

In the SQL-.. standard (<SQL-92) cursors at open are always at the
beginning of the set. It makes sense as only fetch forward was
possible.

In SQL-92 scrolling cursors were introduced but the standard commitee
did not change the initial cursor positioning: as a cursor can go up
and down, there is no reason the cursor should be at the beginning of
the set at open. Cursor positioning at open should be totally
independent of set composition and the "first" row in the set.

So the syntax could be: open cursor position cursor where ... and to
use row value constructors again: open cursor position cursor where
(c1, c2,...) <operator> ....

So my question is: how to solve this problem in SQL and SQL
dialects/extensions?

Bernard Dhooghe

PS: DB2 has generated columns which allows to make one physical column
of several columns. Drives me ...SQL-92 is the (partial) solution.

Nov 12 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Alex Martelli | last post by:
Greetings, fellow Pythonistas! We (Alex Martelli, David Ascher and Anna Martelli Ravenscroft) are in the process of selecting recipes for the Second Edition of the Python Cookbook. Please...
0
by: Ben Yates | last post by:
Book is entitled The XML Handbook Third Edition by Charles F. Goldfarb and Paul Prescod. 2001 Prentice-Hall. 969 pages. Original price $49.99. Comes with two CDs that appear to be unopened, with...
0
by: --CELKO-- | last post by:
I am working on the third edition of SQL FOR SMARTIES. If anyone has an SQL programming technique, trick or tip that they think should be in the book, drop me an email. You get a virtual beer...
0
by: Frederick Noronha \(FN\) | last post by:
---------- Forwarded message ---------- Solutions to Everyday User Interface and Programming Problems O'Reilly Releases "Access Cookbook, Second Edition" Sebastopol, CA--Neither reference book...
0
by: Torsten Grust | last post by:
Second Call for Papers X I M E - P 2 0 0 6 3rd International Workshop on XQuery Implementation, Experience and Perspectives June 30, 2006 Collocated with ACM SIGMOD/PODS 2006, Chicago, USA...
3
by: Grizlyk | last post by:
Hello. I am thinking: why if i will comment lines marked with '#' in the following example, all will be compiled, else will not: // *********************** typedef unsigned uint; ...
17
by: CoreyWhite | last post by:
I bought this book years ago, when I was just learning C++. Since then I've gone through every math course offered at my college, taken courses on coding C & thinking in terms how how to make the...
7
by: Arindam | last post by:
#include <cstdio> struct Test { void bar() { foo(); } private: virtual void foo() { printf("Test\n"); }
5
by: Bob Nelson | last post by:
Right next to K&R2 on my bookshelf is _C Programming: A Modern Approach_ by Professor K.N. King. The second edition of this book is now available. See this URL for details: ...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.