Sunday 16 May 2010

SQL POETRY : to @exist or not @exist - that is the query

start:
BEGIN TRAN
DECLARE @var INT, @exist VARCHAR
SET @var = 0

INSERT
    INTO Who
SELECT [to], [thine], [own], [self], [be], [true]
  FROM Life
      JOIN Earth
        ON [lifetime] BETWEEN [birth] AND [death]
 WHERE [time] = 'Now'
     AND [name] = 'You'

/* then */
IF (SELECT COUNT(*) FROM Who) > @var
BEGIN
     SET @exist = dbo.YourOwnFunction(@@IDENTITY)
END
ELSE
BEGIN
    SET @exist = null
    ROLLBACK TRANSACTION
    GOTO start
END

COMMIT

5 comments:

  1. I love this. I think I will print it out and hang it by my desk at work :)

    ReplyDelete
  2. Hi dixy, and thanks so much for your appreciation. I am very glad that you like it.

    ReplyDelete
  3. If I='geek' then that='fine';
    If self<>true then that='crime';
    Select best from self where all=the_time;

    Select wipe from face where eyes='teary';
    Select new from focus where energy='dreary';
    Update right_now set mood='cheery';
    commit;

    http://rvrb.fm/21bCkL7
    #SuperDBA

    ReplyDelete
    Replies
    1. Hi Will, thanks for your post. Glad to connect with fellow sql poets!

      Delete
  4. Wanted to share:

    Tables, the SQL

    select car.stickshift, u.hips,
    my.mouth, u.driving, mm.bad, my.breathing, mm.after,
    car.parked, u.smiling,

    from you u
    inner join memories mm ON mm.driving = u.driving
    left join my ON my.hips = u.hips
    left join car ON car.night = my.night

    where my.lips = tighteningaroundyou
    AND u.breathing LIKE poetry

    order by mm.night

    ReplyDelete