dynamic-sql Questions

9

Solved

I just asked an SQL related question, and the first answer was: "This is a situation where dynamic SQL is the way to go." As I had never heard of dynamic SQL before, I immediately searched this s...
Fic asked 12/11, 2010 at 13:21

1

Solved

I use PostgreSQL 10 and I run CREATE EXTENSION unaccent; succesfully. I have a plgsql function that contains the following whereText := 'lower(unaccent(place.name)) LIKE lower(unaccent($1))'; late...
Phonation asked 15/4, 2018 at 17:54

2

Solved

I'm using Oracle 11.2.0.1.0 and am trying to get the dbms_sql package to work. However, I keep getting the ORA-29471 error, as shown below: DECLARE c INTEGER; BEGIN c := dbms_sql.open_cursor(); ...
Griggs asked 19/12, 2013 at 19:41

2

Solved

Imagine I have table1 which has a column named 'table_name'. I use table1.table_name to store the name of another table in the database. The referenceable tables would all have a field 'target_id. ...
Antilebanon asked 12/11, 2010 at 12:53

2

I am using PostigreSQL10. I have an all-in-one query where a user can pick a non-standard combination of category style, event, area to search for a constructions. Keep in mind that category style,...
Sprayberry asked 11/1, 2018 at 22:38

4

Solved

I was wondering if there was a way to do this in MS SQL Server 2005: DECLARE @theDate varchar(60) SET @theDate = '''2010-01-01'' AND ''2010-08-31 23:59:59''' SELECT AdministratorCode, SUM(To...
Ecclesiology asked 30/9, 2010 at 17:50

8

Solved

We have a ton of SQL Server stored procedures which rely on dynamic SQL. The parameters to the stored procedure are used in a dynamic SQL statement. We need a standard validation function inside ...

1

Solved

I have a bunch of table that have a "stat" column (stat for status ;-) I would like the count of each stats, and see it! My tables look like this create table a ( a_id UUID PRIMARY KEY DEFAULT ...
Ajax asked 18/9, 2017 at 15:18

2

Solved

How can I write a dynamic SELECT INTO query inside a PL/pgSQL function in Postgres? Say I have a variable called tb_name which is filled in a FOR loop from information_schema.tables. Now I have a...

4

Solved

How to do dynamic SQL in myBatis 3.1.1 based on an enum constant parameter?
Conventioneer asked 17/10, 2012 at 11:58

3

Solved

I need to retrieve data from a linked server using a parameter, @PickedDate for example. The query works fine if I skip @A and @B, but it always returns an error due to a missing single quote. Plea...
Esparto asked 8/5, 2015 at 17:49

6

Solved

Executing dynamic SQL as follows in Stored Procedure: DECLARE @sqlCommand nvarchar(1000) DECLARE @city varchar(75) SET @city = 'London' SET @sqlCommand = 'SELECT COUNT(*) FROM customers WHERE City...
Espalier asked 1/10, 2010 at 15:39

5

Solved

I want to create backup SQL tables using variable names. something along the lines of DECLARE @SQLTable Varchar(20) SET @SQLTable = 'SomeTableName' + ' ' + '20100526' SELECT * INTO quotename(@...
Sakti asked 25/5, 2010 at 15:3

7

Solved

Ι have some tables ( eg. [Table1], [Table2], [Table3] and so on ) with a [ID] as primary key and a RecTime as DATETIME on each. Αlso Ι have a table [Files] that hold files in a varbinary(max) colu...
Warsle asked 8/2, 2017 at 9:37

2

Solved

I have a postgres database that has several tables (a few hundreds). A subset Foo of the tables in the database have the same schema. Ideally, I would like to create a stored procedure which can r...
Grapeshot asked 5/1, 2017 at 9:17

3

Solved

I would like to delete all tables sharing the same prefix ('supenh_agk') from the same database, using one sql command/query.
Become asked 22/12, 2014 at 21:44

3

What I am trying to do here is create a dynamic query where DBAs only have to change the column name at the variable level, the reason of this is because we have multiple DBs that were horrendously...
Hals asked 5/10, 2016 at 3:58

2

Solved

Sample code trimmed down the the bare essentials to demonstrate question: CREATE OR REPLACE FUNCTION mytest4() RETURNS TEXT AS $$ DECLARE wc_row wc_files%ROWTYPE; fieldName TEXT; BEGIN SELECT *...
Putscher asked 1/10, 2016 at 15:6

1

I have seen that there are quit a few similar questions like this one, but I havent understood how to code it myself. Please have in mind that I am just a beginner in this field. Basically I want ...
Postrider asked 29/9, 2016 at 20:47

2

Solved

I've put together a simple stored procedure in which two parameters are passed through to make it more dynamic. I've done this with a prepared statement in the "First Two Digits and Count of Record...
Broome asked 27/7, 2012 at 16:33

10

I'm trying to switch the current database with a SQL statement. I have tried the following, but all attempts failed: -- 1 USE @DatabaseName -- 2 EXEC sp_sqlexec @Sql -- where @Sql = 'USE [' + @Dat...
Kinakinabalu asked 24/6, 2009 at 8:52

3

Solved

I have a problem on creating PostgreSQL (9.3) trigger on update table. I want set new values in the loop as EXECUTE 'NEW.'|| fieldName || ':=''some prepend data'' || NEW.' || fieldName || ';'; w...

3

Solved

Given the following table: USE tempdb; CREATE TABLE #T(Val INT); INSERT INTO #T VALUES (1), (2), (3), (4), (5); I wanted to execute a dynamic sql query using EXEC given a Val value: DECLARE @s...
Photosensitive asked 16/6, 2016 at 7:29

4

Solved

In PL/SQL, you can specify the values for the IN operator using concatenation: v_sql := 'select field1 from table1 where field2 in (' || v_list || ')'; Is it possible to do the same using a vari...
Cavitation asked 23/1, 2012 at 5:45

3

Solved

I have a database named test which contains 2 views and 2 tables under the schema dbo: I want to create a table named report which lists the number of rows for each view and each table. The concep...
Undeniable asked 2/6, 2016 at 2:38

© 2022 - 2024 — McMap. All rights reserved.