Posts

sql server - SQL Insert a record and use its Id to update another set of records foreign key -

i have 2 tables combinableorders , orders , tempory table of order ids orders contain nullable fk combinableorders i create record follows insert combinableorders ([rank]) values (0) i need associate new combinableorder set of orders derived temporary table of ids update orders set orders.combinableorder_id = @id_to_original_insert orders orders inner join @ids ids on orders.id = ids.id how id new created combinableorders? you want declare variable of right type declare @id int and set using scope_identity() after insert select @id = scope_identity() alternatively output in insert using output clause, that's may more complicated in case.

python - How to be memory-efficient with variables in classes? -

suppose, sake of example, have class this: def class foo(object): def __init__(self,x): self.x = x def lookup(self): return dict[x] the purpose of lookup function x in dict , return value. suppose dict large. wondering whether declare dict in class, or whether declare dict global variable. i worried memory-efficiency: dict going constant, , want not take more memory need. thus, asking how classes use memory. if declare e.g. 50,000 instances of foo , , declare dict within foo , mean spawning 50,000 copies of foo ? whereas if refer dict global variable, not spawn additional copies? how make few copies of dict possible? ideally, program have one. in case should have dict global variable. idea of inner variables can change , use them independently without clashes. that's why every instance of foo have it's own copy of dict. (actually named self.dict - should have self.x argument in lookup function uses object's inner variable.)...

sql server - Joining multiple tables to one table in sql -

i have rather complex (well me) sql query happening , having trouble concepts. i have following sql on webpage building select [dbo].[enrolment].[_identity], [dbo].[enrolment].commencementdate, [dbo].[enrolment].completiondate, [dbo].[enrolment].enrolmentdate, [dbo].[course].name coursename, [dbo].[course].identifier qualcode, [dbo].[person].givenname, [dbo].[person].surname,[dbo].[employer].name empname, [dbo].[employer].address1,[dbo].[employer].suburb,[dbo].[employer].phone, [dbo].[employer].postcode,[dbo].[enrolmentstatus].name enrolname, [dbo].[student].identifier,[dbo].[student].person,[dbo].[contact].person contactid (((([dbo].[enrolment] left join [dbo].[course] on [dbo].[enrolment].course = [dbo].[course].[_identity]) left join [dbo].[employer] on [dbo].[enrolment].employer = [dbo].[employer].[_identity]) left join [dbo].[enrolmentstatus] on [dbo].[enrolment].status = [dbo].[enrolmentstatus].[_identity]) left join...

html - Python 3.4 - reading data from a webpage -

i'm trying learn how read webpage, , have tried following: >>>import urllib.request >>>page = urllib.request.urlopen("http://docs.python-requests.org/en/latest/", data = none) >>>contents = page.read() >>>lines = contents.split('\n') this gives following error: traceback (most recent call last): file "<pyshell#4>", line 1, in <module> lines = contents.split('\n') typeerror: type str doesn't support buffer api now assumed reading url pretty similar reading text file, , contents of contents of type str . not case? when try >>> contents can see contents of contents html document, why doesn't `.split('\n') work? how can make work? please note i'm splitting @ newline characters can print webpage line line. following same train of thought, tried contents.readlines() gave error: traceback (most recent call last): file "<pyshell#8>...

ios - UINavigationBar on top of status bar after dismiss a modal view controller -

Image
i have modal view controller , embed in navigation controller a. presenting navigation controller b, after navigation controller b dismissed, navigation bar on top of status bar in navigation controller a. can see pic below. using ios 8.0 develop app way.

sql - Find missing sequences by category -

i have identify missing records example below. category batchno transactionno +++++++++++++++++++++++++++++++++ cat1 1 1 cat1 1 2 cat1 2 3 cat1 2 4 cat1 2 5 cat1 3 6 cat1 3 7 cat1 3 8 cat1 5 12 cat1 5 13 cat1 5 14 cat1 5 15 cat1 7 18 cat2 1 1 cat2 1 2 cat2 3 6 cat2 3 7 cat2 3 8 cat2 3 9 cat2 4 10 cat2 4 11 cat2 4 12 cat2 6 14 i need script identify missing records below category batchno +++++++++++++++++++ cat1 4 cat1 6 cat2 2 cat2 5 i not need know cat1 8 , cat2 7 not there potentially have not been inserted yet. you can create temporary result set possible batch no max batch number each category select batch no not available. cr...

javascript - Test if a promise is resolved or rejected with Jasmine in Nodejs -

i know how in mocha want know how jasmine. tried describe('test promise jasmine', function() { it('expects rejected promise', function() { var promise = getrejectedpromise(); // return expect(promise).tobe('rejected'); return expect(promise.inspect().state).tobe('rejected'); }); }); however, state pending and, of course, test fails. couldn't find example online make work. can please me this? thanks. to test asynchronous code jasmine should use its async syntax , e.g.: describe('test promise jasmine', function(done) { var promise = getrejectedpromise(); promise.then(function() { // promise resolved done(new error('promise should not resolved')); }, function(reason) { // promise rejected // check rejection reason if want done(); // success }); });