logo
down
shadow

How to execute expression stored in the table, after fetching into a variable


How to execute expression stored in the table, after fetching into a variable

By : Vitor Jorge
Date : November 17 2020, 04:28 AM
I wish this helpful for you I've got a table which stores date using getdate() function. For example , I found solution. Example of working code below:
code :
DECLARE
      @SQLString            NVARCHAR(200)
     ,@ParmDefinition       NVARCHAR(200)
     ,@f_name_date_to_out VARCHAR(30)
     ,@f_name_date_to VARCHAR (100) = 'convert(char(10),dateadd(day,-28,GETDATE()),120)' -- apostrophes are important here, because after fetching data from table they always appear in variable.
     ,@data_do VARCHAR (30)



SET @SQLString = N'SELECT @DataOUT ='+ @f_name_date_to
        SET @ParmDefinition = '@DataOUT varchar(100) OUTPUT'
        EXECUTE sp_executesql
                    @SQLString,
                    @ParmDefinition,
                    @DataOUT=@f_name_date_to_out OUTPUT
                    SET @data_do = @f_name_date_to_out;

SELECT @data_do


Share : facebook icon twitter icon
How to execute mathematical expression stored in a varchar variable

How to execute mathematical expression stored in a varchar variable


By : user3528160
Date : March 29 2020, 07:55 AM
it helps some times I have a variable in my database function: , You could use sp_executesql:
code :
declare @expression nvarchar(max)
set @expression = '2*3*100'

declare @sql nvarchar(max)
set @sql = 'select @result = ' + @expression

declare @result int
exec sp_executesql @sql, N'@result int output', @result = @result out

select @result
Fetching files stored in azure container using SSIS - Execute process task

Fetching files stored in azure container using SSIS - Execute process task


By : KvnLng
Date : March 29 2020, 07:55 AM
hop of those help? Based on this article, it seems that standard FTP is an option for you. To simplify your life, I'd create an ftp file that performs the download operations and then call that from your Execute Process Task via ftp.
Content of the batch would be approximately
code :
myusername
myPassword
bin
get myBlob.blob
Oracle : Execute Stored Procedure with table type input variable

Oracle : Execute Stored Procedure with table type input variable


By : Ry4N
Date : March 29 2020, 07:55 AM
hope this fix your issue Your type usage is possible within a package. Outside a package you have to create type.
For execution of procedures with such complex type parameters use a pl/sql anonymous block.
code :
declare
  X tableType;
begin
  X(1) := 1;
  P(X);
end;
How to execute an (expression involving columns of the same table) stored in another column of the table?

How to execute an (expression involving columns of the same table) stored in another column of the table?


By : user3513242
Date : March 29 2020, 07:55 AM
I think the issue was by ths following , My table will look like this- , You can use a function like this:
code :
create or replace function eval(p_row the_table) 
  returns integer
as
$body$
declare
  l_result integer;
  l_sql text;
begin

  l_sql := format('select %s from (values ($1, $2) ) as t(unit_cost, demand)', 
                   p_row.expression);

  execute l_sql
    into l_result
    using p_row.unit_cost, p_row.demand;

  return l_result;
end;
$body$
language plpgsql;
select (unit_cost*4)*demand 
from ( values ($1, $2)) as t(unit_cost, demand);
select (unit_cost*4)*demand 
from ( values (5, 100)) as t(unit_cost, demand);
select t.id, t.unit_cost, t.demand, eval(t) as total_cost
from the_table t;
create or replace function eval(p_expression text, p_demand int, p_unit_cost int)
   returns integer
as
$body$
declare
  l_result integer;
  l_sql text;
begin

  l_sql := format('select %s from (values ($1, $2) ) as t(unit_cost, demand)',
                  p_expression);

  execute l_sql
    into l_result
    using p_unit_cost, p_demand;
  return l_result;
end;
$body$
language plpgsql;
select id, unit_cost, demand, eval(t.expression, t.demand, t.unit_cost) as total_cost
from the_table t;
How to execute LINQ query when I have the table`s name stored in a variable

How to execute LINQ query when I have the table`s name stored in a variable


By : kay
Date : March 29 2020, 07:55 AM
I hope this helps . Sorry if I didn't explained it right in the title, but here it goes: , Use Reflection on the DataContext to find a property named tableName
Related Posts Related Posts :
  • Filter repeated columns in Oracle
  • SQL Server join on whichever column has value populated
  • use sql stored procedure to insert data which is returned from a query stored in a table
  • Query not working1
  • SQL - using an alias in a where clause in a subquery
  • How to search for a whole word with special char using oracle contains?
  • Production Perfomance of using SELECT * statements?
  • String concatenation not working as expected in SELECT statement
  • How to detect which stored procedures UPDATE or INSERT into a certain TABLE?
  • Select statement inside CASE - SQL
  • .Net Float error 4 - float(4) = 4.44089209850063E-16
  • How to show as column to recursive rows in a table With SQL Server
  • SQL Server error: Column name or number of supplied values does not match table definition
  • How to find a table name which's column name consist cl_
  • Cannot access existing table from WCF Code
  • SQL CREATE VIEW Error
  • Many Statement in the same transaction PLSQL
  • Tables are not joining properly in sql server 2008
  • DB2 how to sum two column from two different table
  • SQL msAccess: list unfinished courses of a student
  • SQL Server delete multiple rows
  • Finding max(date) from the resultant query output
  • updating multiple columns using case statement in sql server
  • Nested SQL query having select subquery in update statement
  • "putting" a certain object to the screen from inside an array
  • Retrieve segment from value
  • Error while creating a table in oracle 11g
  • Transaction with Sequelize doesn't work
  • Search time complexity of this sql query
  • How to return unique records between two tables without using distinct and union?
  • Is it possible to maximum occurences of a value for each key in my table all in one query?
  • Divide table into groups of 5000 based on rank
  • rolling back exec and sp_OA methods
  • How to convert multiple rows to one row in SQL Server?
  • How to use substring and charindex in google query language
  • Find table information where part of column matches char variable
  • Need to retrieve rows from table where the following condition was not satisfied column A = column B and column B = colu
  • Assigning an index to a constraint
  • Retrieve records from multiple Records returned by Sub-Query
  • SQL DELETE group of records based on opposite group being empty
  • SQL GetDate() returns wrong time
  • Total sales amount for customers in cities
  • SQL Server -- updating the `sys.*` tables and not just reading them
  • SQL Order By using concat
  • SQL server 2008 - subquery returned more than one value
  • Group Data Hourly and Insert Into a Summary Table in Postgres
  • Execute SQL Server Pass-Through Query From Access VBA
  • MS Access SQL Transform Aggregate Manipluation of Values for Pivot
  • SQL "if exists..." dynamic query
  • HANA: Split string?
  • Create a list of dates and match records to the list
  • Why won't SQL round correctly from my batch script?
  • SQLServer - Multiple PIVOT on same columns
  • Update a table foreign keys by substituting by a lookup from the result of another table
  • Deleting rows in a single database table based on the values of other rows
  • Search and replace part of string in database - what are the pitfalls?
  • How could I generate auto insert function SEAT_NO like A1,A2.... B1,B2 in sql server
  • whats a good way to optimize a table? SQL server 2k8
  • Sql server dynamic sequences
  • JPQL Query - object that's in one list and isn't in another
  • shadow
    Privacy Policy - Terms - Contact Us © ourworld-yourmove.org