• Welcome, Guest. Please login.
 
May 07, 2021, 11:51:22 PM

News:

Welcome to the SQLitening support forums!


6 database tabel is locked error

Started by bobl, May 14, 2011, 07:49:36 AM

Previous topic - Next topic

bobl

May 14, 2011, 07:49:36 AM Last Edit: May 14, 2011, 08:10:00 AM by bobl
The middle block of code UNCONDITIONALLY inserts a column in a table and it used to work fine.
Since I've added the test code blocks above and below it...
to make the column addition CONDITIONAL on the value of a fleld in the table...
the line..."slExe "Drop table if exists tmp_tbl""...now results in an error 6
i.e....database table is locked!
I don't understand why getting a row should cause this and wonder how I can get around it.
Thx in anticipation.

'=====================================================================
'test
slSel( "Select * from " & tFocus.y_cat_tbl & " where sort_order=" & STR$(tFocus.y_row) )
IF slGetRow THEN
    IF slF(tFocus.y_col)<>"" THEN
'=====================================================================           

'=====================================================================           
            'this block of code worked fine before the outer blocks were added
            group_col_no+=1
            auto_col_nm = "g" & TRIM$( STR$(group_col_no) )
            ARRAY INSERT col_nms(), auto_col_nm
            csv=JOIN$(col_nms(),",")
            csv=LEFT$(csv,-1)
            slExe "ALTER TABLE " & tFocus.y_cat_tbl & " RENAME TO tmp_tbl"
            New_table(BYCOPY tFocus.y_cat_tbl,csv)
            slExe "INSERT INTO " & tFocus.y_cat_tbl & " SELECT id,sort_order,null,itm FROM tmp_tbl"
            '***ERROR 6 happens when executing next line!!!***
            slExe "Drop table if exists tmp_tbl"
'=====================================================================           

'=====================================================================
'test
    END IF
END IF
'=====================================================================

bobl

All sorted!...either by using "Do while slGetRow... or "slCloseSet".

Fred Meier

Another way is to add the "C" ModChar to slGetRow.
QuoteC  = Close the set even if there is another row.  This is useful
           when all you want to do is test if a set has any rows.

bobl

...making it a one-liner.
Thanks very much Fred!

Fred Meier

Yet another way to test if a set has any rows.
   if len(slSelStr("Select 1 from T1 where C1='Value' limit 1") then
      ' Set has rows
   end if