Questions tagged [user-variables]

SQL variables set by the user, without special significance to the RDBMS.

Often referring to SQL server variables, these are variables created by the user, as opposed to system variables presented by the underlying platform.

59 questions
0
votes
1 answer

How do I assign numeric value of an SQL query result to a package variable of data type Double?

I have what should be a simple task - Populate a user variable using the ResultSet from an Execute SQL task SELECT MainID FROM TableA WHERE TableA_ID = 1` (This will only return one Column and one Row). MainID is currently stored as a user-defined…
Rob
  • 3
  • 1
  • 1
  • 2
0
votes
0 answers

MySQL decrement user variable on value change?

I have a problem with MySQL user defined variables! My table looks like this .. plz | uid 4000 1 4000 2 9000 3 7000 4 Desired output .. rownum | plz | uid 1000 4000 1 1000 4000 …
Aldee
  • 61
  • 9
0
votes
1 answer

How to populate variable to all view logged user

I have code like bellow: return view('Dashboard.AccountSettingsView', [ 'PageTitle' => config('app.name', 'Laravel') . ' | ' . __('Profile'), 'PageHeader' => __('Profile'), 'user' => Auth::user() ]); How i can pass $user variable to all…
hrace009
  • 37
  • 9
0
votes
0 answers

SELECT max() inside trigger returns NULL, separately returns non-NULL value

Consider the following schema: Table 1: Schedule_items id | id_schedule | id_element | id_type | id_parent | creation_time Table 2: Schedule_items_tree id_rel | id_schedule | descendant | ancestor | depth | sequence A goal of the second table is…
Kuba
  • 161
  • 2
  • 7
0
votes
1 answer

MySQL: Update table with an IN (@variable) failed

I'm trying to update a table, with the IN function and a variable. The content of the variable is a sub-query that returns the expected values aka ID for each STRING. When I copy/paste the values in the update, everything is fine. USE `DB1`; SET…
Nico
  • 85
  • 1
  • 9
0
votes
1 answer

What boolean value return assign integer or string to a variable

Im using user variables to emulate ROW_NUMBER() OVER (PARTITION BY `wsf_ref`, `type` ORDER BY `wsf_value` DESC) Pay attention to the @type variable. I set it to a to make the issue clear but at first was an empty string. CROSS JOIN ( SELECT @rn :=…
Juan Carlos Oropeza
  • 47,252
  • 12
  • 78
  • 118
0
votes
1 answer

mysql select query not working with limit and offset set via user variables

I'll be brief: WORKING SELECT p.id, p.name, cat.name `category`, prod.name `producer`, p.images, p.price, p.flag_avaliable, p.amount, p.description, p.options FROM product p INNER JOIN product_category cat ON…
Victor Gorban
  • 1,159
  • 16
  • 30
0
votes
1 answer

Unable to run prepared statement because user variable is too long?

The issue I have a working stored procedure (SP) that accepts 3 parameters (an id, a from date and a to date). This SP works fine in my test system where all of the values returned from t1.name in the GROUP_CONACT are rather short and there aren't…
Petay87
  • 1,700
  • 5
  • 24
  • 39
0
votes
1 answer

Sending variable from $_SESSION, through AJAX to PHP for password change, how to do it?

I am making an option in my web application for users which are already logged in to change their password (so this is not a Forgot password option). I have an HTML form, then external JS file for form validation, which, if entered data pass…
0
votes
1 answer

PHP PDO / MySQLi doesn't return rows while query has mysql user-variables

I want to execute and get the results of the following query: $query = <<
Kangur
  • 7,823
  • 3
  • 30
  • 32
0
votes
2 answers

Insert into table concatenation of variables and constant tokens

I have a table with the following schema CREATE TABLE `foo` ( `myfield` text NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8; I've defined a couple of variables as follows SET @NAME := 'Somename'; SET @AGE := '31'; I need to insert into the table…
Giorgio
  • 1,940
  • 5
  • 39
  • 64
0
votes
0 answers

MySQL user defined variables in WHERE clause

In the regular EMP,DEPT table configuration (stock data provided by Oracle), I have the following query to solve: List the empno,ename,sal,job,deptno & experience of all the emps belongs to dept 10 or 20 with an exp 36 to 40 years working under the…
devak23
  • 419
  • 1
  • 4
  • 6
0
votes
1 answer

user variables in a calculation

I am producing a league table for speedway teams, I have got a query to calculate the required data based on teams results. The part I am struggling with is the points difference (difference between points scored and scored against. SELECT…
Mark Bagnall
  • 1
  • 1
  • 2
0
votes
2 answers

SSIS user variable not updating in execute SQL task

I know this should be really simple, but I cannot get it to work. I am using an execute SQL Task in Control flow with the intention of setting 2 user_variables, vRunID and vRelease. I have a very simple select statement where I am getting a single…
CJS
  • 1
  • 2
0
votes
0 answers

MYSQL - select clause with user-defined variable not returning same result when used in a subquery

I'm having some troubles under MYSQL and hope find some answer here. I have some score table, and want to query the users whose rank is nearby the current user. For instance, if the current user is ranked #85, I want to get the users whose rank is…