Sqlite does not have a built in procedural language like PL/SQL.  For 
certain applications we just added Javascript to cover that requirement. 
  It was straightforward using Spidermonkey and had the advantage of 
being the same language used by the AJAX applications backended by 
Sqlite so applications programmers had one less skill to master.

Jason Salas wrote:
> Hi Igor,
> 
> Thanks for the insight.  I'm used to doing stored procedures for web 
> apps, which conditionally execute statements based on state and/or the 
> presence of variables.  Consider this construct, which I built recently 
> to populate a table with URL for a web spider bot I built:
> 
> CREATE PROCEDURE AddLinkInfo
> (
>     @ProviderName VARCHAR(200),
>     @LinkPath VARCHAR(200),
>     @LinkText VARCHAR(200)
> )
> AS
>     DECLARE @ProviderID    INT
> 
>     -- only store a link if it isn't already listed in the database
>     IF NOT EXISTS(SELECT LinkPath FROM SpiderBot WHERE LinkPath = @LinkPath)
>         BEGIN
>             -- is this a known provider?  if not, add it into the DB and 
> then assign it's new ID
>             IF EXISTS(SELECT ContentProviderID FROM 
> SpiderBot_ContentProviders WHERE ProviderName = @ProviderName)
>                 BEGIN
>                     SET @ProviderID    = (SELECT ContentProviderID FROM 
> SpiderBot_ContentProviders WHERE ProviderName = @ProviderName)           
>                 END
>             ELSE
>                 BEGIN
>                     INSERT INTO SpiderBot_ContentProviders VALUES 
> (@ProviderName)
>                     SET @ProviderID = @@IDENTITY
>                 END
>        
>           -- do the main content insertion
>             INSERT INTO SpiderBot (ContentProviderID,LinkPath,LinkText) 
> VALUES (@ProviderID,@LinkPath,@LinkText)           
>         END
> GO
> 
> How would I got about re-writing something like this in SQLite?  Thanks 
> again for your help.
> 
> 
> Igor Tandetnik wrote:
>> "Jason Salas" <[EMAIL PROTECTED]> wrote in message
>> news:[EMAIL PROTECTED]
>>   
>>> I'm used to doing lengthy T-SQL programming in SQL Server, so this is
>>> kinda new to me.  How does one replicate doing IF...THEN conditional
>>> blocks in SQLite 3?
>>>     
>> One typically doesn't. Instead, one implements complex logic in one's 
>> application that hosts SQLite.
>>
>> Igor Tandetnik 
>>
>>
>>
>> _______________________________________________
>> sqlite-users mailing list
>> sqlite-users@sqlite.org
>> http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
>>
>>   
> 
> 
> _______________________________________________
> sqlite-users mailing list
> sqlite-users@sqlite.org
> http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to