sql server – Is it possible to “bind” sp_executesql to the calling procedure, as recorded in the Query Store?

Statements executed with sp_executesql appear to be generally “unbound” from the procedure in which they appear. By “bind”, I simply mean “associated to the calling object”.

The goal is to make it simpler to associate statements in the Query Store:

select object_name(q.object_id) as (Statement Context)
from sys.query_store_query
where 1=1
    and object_name(q.object_id) like 'This will be the procedure name for ''normal'' statements'

While it’s possible to embed comments in the statements that will show up in the query_sql_text, this feels a bit extra-hackish.

Also, it seems that sp_executesql would need some form of context binding as the dynamic SQL can access non-global temp tables in the surrounding scope: without a binding, how can SQL Server ensure the validity & stability of the temp table schema in the created plans?

Calling MouseListener for two different things

public class Application extends JFrame {
public Rectangle.MyMouseHandler handler;

public class MyMouseHandler extends MouseAdapter{
    
    public void MouseClicked(MouseEvent e){
        if (e.getModifiers() == MouseEvent.BUTTON3_MASK && e.getClickCount() == 1) {
        initUI1();
    }
     if (e.getModifiers() == MouseEvent.BUTTON1_MASK && e.getClickCount() == 1){
         initUI2();
     }       
}
}
                 

private void initUI1() {

    add(new Rectangle());

    setSize(800, 800);

    setTitle("Application");
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    setLocationRelativeTo(null);
}    
private void initUI2() {

    add(new Circle());

    setSize(800, 800);

    setTitle("Application");
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    setLocationRelativeTo(null);
}
/**
 * @param args the command line arguments
 */
public static void main(String() args) {
     EventQueue.invokeLater(() -> {
        Application ex = new Application();
        ex.setVisible(true);
    });
}
}

I want to make a program in which I can draw a rectangle and a circle with my left click of the mouse and use right click to switch between the two. I have already made both the Circle and Rectangle classes.

java – Calling a post method with a single string parameter using @RequestParam() annotation in spring-web

I am calling this post method to sent a single parameter as a test. I call it from the URL as the following, but get an error why? please give an example of calling Post method using one sing parameter if possible. I don’t want to use @RequestBody and @PathVariable annotations.

@PostMapping(value = "/cmd")
public String command(@RequestParam() String command) {
    return command;
}

Call:

http://localhost:8080/api/cmd?command=on

Error:

Whitelabel Error Page
  This application has no explicit mapping for /error, so you are seeing this as a fallback.
  
  There was an unexpected error (type=Method Not Allowed, status=405).

magento2 – Redirecting from Observer after calling external API when executing payment method

I am developing a payment module.
I am trying to redirect to an external url after calling an API with curl.
The api returns a redirect url (https://…..com/…./..), which I would like to follow and continue with payment on the page it should open.

I am trying to do that from an Observer (before_save_order_payment)
I tried every possible way (resultRedirectFactory, _redirect(), header(“Location:”), etc)
but none of them redirects to that external url.

Sometimes it happens to redirect to the cart page… o_O

This is my first Magento 2 development, so I am not sure if doing that from the observer is the correct way.

asymptotics – Time Complexity of multiple functions calling each other

Thanks for contributing an answer to Computer Science Stack Exchange!

  • Please be sure to answer the question. Provide details and share your research!

But avoid

  • Asking for help, clarification, or responding to other answers.
  • Making statements based on opinion; back them up with references or personal experience.

Use MathJax to format equations. MathJax reference.

To learn more, see our tips on writing great answers.

Calling All Illustrators for Icon $30

I need an illustrator to create an icon.

The concept:
SEMrush

This icon illustration is a computer. It’s a female, dressed nice, wearing pearls around her “neck” and red pointed toe stiletto shoes–at least that’s how I imagine it. :] Her name is “Fresh and Clean Francine.” She is to remind people to update their computers.

The pay is $30 via Paypal.

 

javascript – Calling a paginated and rate limited REST API with a cursor value to get multiple pages of results using .fetch

I’m working with a paginated REST API that returns data from a GET request with the following structure:

{
  "data": (
           { "id": "26007494656", "user_id": "23161357"}, 
           { "id": "26007492556", "user_id": "23124357"}...
          ),
  "pagination": {
        "cursor": "eyJiIjpudWxsLCJhIjp7Ik9mZnNldCI6MjB9fQ=="
    }
}

The endpoints can return a maximum of 100 elements inside a data array per call, and are rate limited to 800 calls per minute. However, there can be at anytime 100,000 – 200,000 available data elements to retrieve. Furthermore, the pagination cursor value is needed for subsequent requests to mark the starting point for the next set of results, and this value is updated on every successive request.

While it won’t likely be possible to retrieve all the data available from this endpoint, I have approached this problem using recursion:

function getAllData (cursor, data = (), counter = 35) {
  while (counter !== 0) {
    const request = new Request(url + (cursor ? '&after=' + cursor : ''), { 
    method: 'GET' ,
    headers: {
      'Client-ID': clientId,
      'Authorization': `Bearer ${access_token}`,
      'Content-Type' : 'application/x-www-form-urlencoded; charset=UTF-8'
      }
    });
      return fetch(request).then((response) => response.json()).then((responseJson) => { 
        if (counter === 1) return data;
        data.push(...responseJson.data);
        return getAllData(responseJson.pagination.cursor, data, --counter);
    }).catch(showError);
  }
}

I’m wondering if there is a better way to approach working with this API with the goal of retrieving as much data as reasonably possible, or if this function can be optimized somehow. The counter argument specifies the number of times the recursive call should be made, and the catch block simply displays an error message to the user. I’m using the maximum return value of 100 objects per call so it currently returns an array of approximately 3500 data elements.

With the way this function is being utilized in my app, it could be called as many as 4-5 times in a minute, and it seems to take approximately 6-7 seconds for the function to finish its recursive calls and return data. Currently, I’m using this function in a client-side Javascript file, but I’m thinking about maybe moving some of this logic to an Express server.

Exception when calling Postgresql function returning a local numeric from C#

I wrote a Postgresql function to insert a row and return the value generated from the identity column. I receive the following exception when trying to call it from C#.

Npgsql.PostgresException: ‘42601: query has no destination for result data’

I have looked around for an answer, and it seems ExecuteScalar has worked for others, but in all the examples I’ve seen, it’s usually when using RETURN QUERY, not a local variable. What am I missing?

Here is the function:

CREATE OR REPLACE FUNCTION public.func_insert_item(_name character varying)
 RETURNS BIGINT
 LANGUAGE plpgsql
AS $function$
DECLARE
    _item_id BIGINT;
BEGIN

    INSERT INTO public.items
    (
        name
    )
    VALUES
    (
        _name
    )
    RETURNING _item_id;
    
    RETURN _item_id;
END;
$function$

Here is the C#:


        static NpgsqlParameter CreateParameter(string name, ParameterDirection direction, string value)
        {
            var parameter = new NpgsqlParameter(name, NpgsqlTypes.NpgsqlDbType.Varchar, value.Length);
            parameter.Direction = direction;
            parameter.Value = value;

            return parameter;
        }

        static void Main(string() args)
        {
            using var connection = new NpgsqlConnection(connectionString.ToString());
            connection.Open();
            
            using var command = new NpgsqlCommand("func_insert_item", connection);
            command.CommandType = CommandType.StoredProcedure;

            command.Parameters.Add(CreateParameter("_name", ParameterDirection.Input, name));

            object itemId = command.ExecuteScalar();
        }

unreal 4 – Calling a function from Super is getting an error

I am following GameDev.tv’s unreal C++ course, but I am getting an error that is causing my compiler to fail. I’m coding a player controller, and I think I followed all the steps right but when I call the GameHasEnded() function from Super in the playercontroller.cpp, It gets an error saying: anything followed by '::' must be followed by a class or namespace.

Here is my .h file which has no known compiler errors.

    #pragma once

#include "CoreMinimal.h"
#include "GameFramework/PlayerController.h"
#include "ShooterPlayerController.generated.h"

/**
 * 
 */
UCLASS()
class SIMPLESHOOTER_API AShooterPlayerController : public APlayerController
{
    GENERATED_BODY()
public:
    virtual void GameHasEnded(class AActor *EndGameFocus = nullptr, bool bIsWinner = false) override;
};

Here is my .cpp file with the problem.

// Fill out your copyright notice in the Description page of Project Settings.


#include "ShooterPlayerController.h"


void GameHasEnded(class AActor *EndGameFocus, bool bIsWinner)  
{
    //this is the problem super
    Super::GameHasEnded(EndGameFocus, bIsWinner);
}

I have a lot of other scripts, but I don’t think they’re related to the problem. I’m using Unreal 4.26, and Visual Studio 2019. I have no idea why this is getting an error, the code is exactly the same as the instructor’s code.