I am trying to replace the following sql query in sqlite but seems like I don't have much options available to write this query completely in sqlite. I am aware of using the where not exists of sqlite but not sure how to use the same when there are nested if conditions after if not exists condition like below. I can take care of this issue in code behind but wanted to know if this can be taken care off completely in a sqlite query.
IF NOT EXISTS (SELECT col1 from tb1 where tbl.id= @someId)
BEGIN
SET NOCOUNT ON;
IF @someparam=@otherparam
SELECT col1,col2 from tb1
where tb1.somecolumn='xyz' or tb1.someothercolumn='pqr'
order by col1
IF @someparam=@otherparam2 OR @someparam = 'xyz'
SELECT col1,col2 from tb1
where tb1.somecolumn='xyz' or tb1.someothercolumn='pqr'
order by col1
END
ELSE
BEGIN
SET NOCOUNT ON;
IF @someparam2=@otherparam3
SELECT col1,col2 from tb1
where tb1.somecolumn='xyz' or tb1.someothercolumn='pqr'
order by col1
IF @someparam2=@otherparam4 OR @someparam = 'xyz'
SELECT col1,col2 from tb1
where tb1.somecolumn='xyz' or tb1.someothercolumn='pqr'
order by col1
END
END
Aucun commentaire:
Enregistrer un commentaire