1

Really appreciate if I can get any help on this

I have one sql query i.e query1 which displays the list of users who are not logged in to our application and another query "query2" that uses the ouput of query 1 and disables those user. Until now I had to manually run the two query individually, but now I have to automate the process.

My question is how can I pass the output of query1 as input to query2 without any manually work. I did some research and found out that this can be done using procedures and I need to create cursors as well. If this is true please let me know the steps on how to proceed further

I have Oracle database on the backend for our application. and we use SQL to retrieve the data

Thanks victor

5
  • How exactly do you "disable" the user? An update statement maybe? Please post both queries Commented May 12, 2012 at 9:19
  • You can do that using stored procedure but it might not be necessary for you. This problem could be solved by using sub-queries, just try it... Commented May 12, 2012 at 9:29
  • In your post, you say you have Oracle database - yet the tag reads sql-server (that is: Microsoft SQL Server) - so which is it now?? Commented May 12, 2012 at 9:33
  • we have oracle DB and we use sql to retrieve the data. Commented May 12, 2012 at 9:41
  • yes query2 is an update query but im unable to post it.since im new to this site please let me knw how do i post both my queries as they are quite huge about 700 lines Commented May 12, 2012 at 9:49

1 Answer 1

4

I'm not an Oracle guy, but this should work:

update tbl1
set IsEnabled = 1
where UserId in (select UserId from tbl2 where IsLoggedIn = 0)
Sign up to request clarification or add additional context in comments.

2 Comments

Works also on MS SQL Server. Validated both on 2014 and 2016. Thanks!
@bizna - I said "I'm not an Oracle guy", but I most definitely am a SQL Server guy. :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.