Please Help Me.

Posts   
 
    
cmartinbot
User
Posts: 147
Joined: 08-Jan-2004
# Posted on: 11-Jul-2007 19:40:25   

Unfortunately, I've let my l33t LLBLGen skills wane wink and I can't quite figure out how to translate this into LLBLGen-eese. Can anyone help me out?

Thanks, Chris


INSERT INTO [NotificationQueue] ( [NotificationId], [ArticleId], [Created] ) SELECT ArticleNotification.NotificationId, ArticlePendingNotificationProcess.ArticleId, GETDATE() FROM ArticlePendingNotificationProcess

INNER JOIN
    ArticleNotification ON ArticlePendingNotificationProcess.ArticleId = ArticleNotification.ArticleId 
INNER JOIN
    Notification ON ArticleNotification.NotificationId = Notification.NotificationId 
INNER JOIN
    NotificationCredit ON Notification.UserId = NotificationCredit.UserId 
LEFT OUTER JOIN
    NotificationUsage ON Notification.NotificationId = NotificationUsage.NotificationId 
    AND 
    NotificationCredit.NotificationCreditId = NotificationUsage.NotificationCreditId

WHERE (NotificationCredit.CreditCount > 0)

GROUP BY ArticleNotification.NotificationId, ArticlePendingNotificationProcess.ArticleId, Notification.UserId, NotificationCredit.CreditCount HAVING (SUM(ISNULL(NotificationUsage.CreditsUsed, 0)) < NotificationCredit.CreditCount)

cmartinbot
User
Posts: 147
Joined: 08-Jan-2004
# Posted on: 11-Jul-2007 20:08:25   

My first impulse is to run the SELECT first and create a new NotificationQueueEntity for each row. But, my problem with that is that there could literally be 1 million rows returned (in some apps). That obviously poses a problem for me.

So my goal is to construct a query where everything takes place on the DB server without resorting to SPs.

Any other ideas?

Thanks, Chris

cmartinbot
User
Posts: 147
Joined: 08-Jan-2004
# Posted on: 11-Jul-2007 21:46:51   

According to http://llblgen.com/TinyForum/Messages.aspx?ThreadID=9914 this isn't possible.

If that's the case, I may just hit ADO directly too.

cmartinbot
User
Posts: 147
Joined: 08-Jan-2004
# Posted on: 11-Jul-2007 21:55:23   

I think I decided on a SPROC cry

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39910
Joined: 17-Aug-2003
# Posted on: 11-Jul-2007 22:26:49   

cmartinbot wrote:

I think I decided on a SPROC cry

Long time no see! simple_smile

I hate to bring this news, but indeed insert into .. select queries, so insert and select in 1 go aren't supported directly, so you have to create the query manually, e.g. via a proc or via inline sql.

Frans Bouma | Lead developer LLBLGen Pro