Sybase stored procedure - how do I create an index on a #table?

I have a stored procedure which creates and works with a temporary #table Some of the queries would be tremendously optimized if that temporary #table would have an index created on it. However,...

Postgres window function and group by exception

I'm trying to put together a query that will retrieve the statistics of a user (profit/loss) as a cumulative result, over a period of time. Here's the query I have so far: SELECT p.name, e.date,...

Why do we need the "finally" clause in Python?

I am not sure why we need finally in try...except...finally statements. In my opinion, this code block try: run_code1() except TypeError: run_code2() other_code() is the same with this...

Django: Calling .update() on a single model instance retrieved by .get()?

I have a function which currently calls Models.object.get(), which returns either 0 or 1 model objects. If it returns 0, I create a new model instance in the except DoesNotExist clause of the...

Unique constraint with soft deleted rows excluded

We have a table with a unique constraint on it, for feedback left from one user, for another, in relation to a sale. ALTER TABLE feedback ADD CONSTRAINT unique_user_subject_and_sale UNIQUE...

PostgreSQL MAX and GROUP BY

I have a table with id, year and count. I want to get the MAX(count) for each id and keep the year when it happens, so I make this query: SELECT id, year, MAX(count) FROM table GROUP BY...

Dynamic LINQ DateTime Comparison String Building - Linq To Entities

I'm using the dynamic LINQ library by Scott Guthrie together with Entity Framework and C#. I have to build my where string into a variable based on several factors and then pass the string...

MySQL update value from the same table with count

What I want to do is to set every patient its unique patient code which starts with 1 and it's not based on row id. Id only specifies order. Something like...

NameError: global name 'HTTPError' is not defined

I have a command in a try clause which I know throws an exception. I'm trying to catch it in an "except" clause, but the except clause seems to not recognize the existence of the exception. The...

Can't connect to local MySQL server through socket '/tmp/mysql.sock

When I attempted to connect to a local MySQL server during my test suite, it fails with the error: OperationalError: (2002, "Can't connect to local MySQL server through socket '/tmp/mysql.sock'...

MYSQL: Can I use outer query table alias inside subquery

Here is my query: select uact.onAssetID as AssetID, a1.value as AssetValue, uact.CommentID, a2.value from useractivity uact inner join asset a1 on uact.onAssetID=a1.ID inner join (select * from...

Is comparing strings in MySQL vulnerable to timing attacks?

I'm deploying a classic hashing protection for user passwords. The submitted password on login is salted, hashed, and then compared to the already stored hash in the database. But instead of using...

Order of execution Oracle Select clause

Consider a query with this structure: select ..., ROWNUM from t where <where clause> group by <columns> having <having clause> order by <columns>; As per my understanding, the order of...

Get multiple rows using FOR JSON clause

Using PostgreSQL I can have multiple rows of json objects. select (select ROW_TO_JSON(_) from (select c.name, c.age) as _) as jsonresult from employee as c This gives me this...

EF6 IN clause on specific properties

Good morning, I'm having trouble with a EF query. This is what i am trying to do. First i am pulling a list of ID's like so (List of IDs are found in the included x.MappingAccts...

How can I have is null condition in typeorm find options?

In my queries I'm using typeorm find option, How can I have IS NULL condition in the where clause?

Rails Not query on entire Where clause

Is there a straight-forward way to negate an entire where expression using ActiveRecord/ARel? It seems that where.not(), when given a hash of arguments, negates each expression individually, as...

Is this Prolog terminology correct? (fact, rule, procedure, predicate, ...)

Getting the terminology correct is part of the success to communicating a concept and when the wrong terminology is used here at SO with the Prolog tag the respondents nicely point out the...

Firestore query with multiple where clauses based on parameters

I want to query a Firestore database with multiple where clauses based on the parameters that are passed in. The following block of code works: getProducts2(accountId: string, manufacturer?:...

Mapping hierarchical data in Hibernate

In a Hibernate application I'm working on a table with hierarchical data (Oracle Database). For the sake of simplicity I'll put an example of a person with a father (assume the hierarchy is not...

Why does a = a['k'] = {} create an infinitely nested dictionary?

Here is my Python code that creates an infinitely nested dictionary: a = a['k'] = {} print(a) print(a['k']) print(a['k']['k']) print(a is a['k']) Here is the output: {'k': {...}} {'k':...

Partitions for vpc flow logs

This query works as expected. CREATE EXTERNAL TABLE IF NOT EXISTS vpc_flow_logs3 ( version int, account string, interfaceid string, sourceaddress string, destinationaddress string, ...

OTA on GlobalPlatform sim-card. Issues with Load command via sms

I have a testing sim card (sysmoUSIM-SJS1) with a keyset for OTA (Kic,Kid). It's support JavaCard 2.2.1 GlobalPlatform 2.1.1. And I have a helloworld applet for this card. I can install this...

How to model if-expressions with actor systems?

I'm trying to emulate a simple functional language using an actor based execution model where issues arose modelling if-expression. Actor systems nowadays are used basically for speeding up all...

JPA Specification and null parameter in .where clause

I wrote two Specifications which return null if their parameter is null. public static Specification<Prodotto> getProdottoByLineaSpec (String linea) { if (linea != null) { return...

SQL date_sub vs datediff performance in looking over a date window

I'm trying to look at the number of active users of a product (toy example) over the last 30 days. I'm considering two approaches. One, date_sub is used to find the date 29 days before (the...

requires clause for a non-template member function in a template class

I have a simple template class A, I want to enable a function if some requirements are satisfied. Solution 1 - requires clause The first solution I tried is the following: template <class T> class...

How to generate and add privacy policy on Google Play?

I have to create and add a privacy policy to my Android app. My app accesses background geolocation data, so whatever policy I add has to include info about how location data is used. Two...

How to handle errors inside getServerSideProps in Next.js using next-connect

I'm using Next.js and next-connect to handle middlewares. But I'm having problems trying to handle errors when I use several middlewares inside getServerSideProps. This is the code I have inside...

Lifetime of async closure return type

Consider the following code: async fn f(x: &i32) -> i32 { todo!() } fn g<F, Fut>(f: F) where F: Send + Sync + 'static, for<'a> F: Fn(&'a i32) -> Fut, Fut: Future<Output = i32> +...