dynamic-sql Questions

2

Solved

Is it possible to execute an update conditionally if a column exists? For instance, I may have a column in a table and if that column exists I want that update executed, otherwise, just skip it (or...
Fixing asked 8/5, 2015 at 19:8

3

Solved

I am generating some Dynamic SQL and would like to ensure that my code is safe from SQL injection. For sake of argument here is a minimal example of how it is generated: var sql = string.Format("...
Hydrograph asked 11/3, 2012 at 1:9

2

Solved

In PostgreSQL, I would like to create a safe-wrapping mechanism which returns empty result if an exception occurs. Consider the following: SELECT * FROM myschema.mytable; I could do the safe-wra...
Alkaline asked 10/2, 2015 at 16:37

2

I am showing data in CGridView from a dynamic SQL Query using CSqlDataProvider. There are some static and some dynamic column. Now I want to do some special formatting like currency in the dynamic ...
Ordinate asked 17/7, 2014 at 7:26

3

Solved

My Scenario I'm working on a database which will contain many details from various Stored Procedures in different databases across the entire server. The information I'm attempting to gather now i...
Dudek asked 19/10, 2011 at 18:54

2

Solved

I am trying to truncate all the tables in a schema using PostgreSQL. It is showing this error: ERROR: relation "Building" does not exist CONTEXT: SQL statement "TRUNCATE TABLE "Building" CAS...
Gannet asked 6/1, 2015 at 7:5

1

Solved

I am trying to implement a function that returns a table with the same structure as an input table in the parameter, using PL/pgSQL (PostgreSQL 9.3). Basically, I want to update a table, and return...
Plane asked 25/12, 2014 at 18:59

1

Solved

Let's say I have a column called partner in multiple tables within one schema: select table_name from information_schema.columns where column_name = 'partner'; How would I update all columns whe...
Resentment asked 17/12, 2014 at 13:58

3

Solved

I am trying to write a trigger function that will input values into separate child tables, however I am getting an error I have not seen before. Here is an example set up: -- create initial table...
Adamina asked 5/12, 2014 at 17:5

1

Solved

I want to update a column in table stats with the specific column being a parameter, then return the updated value of that column [only has 1 row]: CREATE FUNCTION grow(col varchar) RETURNS integ...
Lyublin asked 4/12, 2014 at 3:48

3

Solved

I am fully aware that the correct practice for sanitising SQL queries is to parameterise them. I work on a lot of pre-existing code where the sanitisation measure was to replace all instaces of ' ...
Kronos asked 2/12, 2014 at 8:57

7

I have two tables: A [ID, column1, column2, column3] B [ID, column1, column2, column3, column4] A will always be subset of B (meaning all columns of A are also in B). I want to update a record ...
Serle asked 4/5, 2010 at 8:27

1

I am new to PostgreSQL and found a trigger which serves my purpose completely except for one little thing. The trigger is quite generic and runs across different tables and logs different field cha...
Kiernan asked 14/10, 2014 at 7:3

2

Solved

In postgresql-9.2 database there are 125 views stored.Among them 75 views owner is sa. So,is there any method can I apply to alter the view's having owner sa to postgres.?
Philipp asked 15/9, 2014 at 5:18

2

Solved

I want to loop through a query, but also retain the actual record for the next loop, so I can compare two adjacent rows. CREATE OR REPLACE FUNCTION public.test () RETURNS void AS $body$ DECLARE...
Linderman asked 10/9, 2014 at 23:18

1

Solved

I am trying to execute an SQL command within dynamic SQL with bind variables: -- this procedure is a part of PL/SQL package Test_Pkg PROCEDURE Set_Nls_Calendar(calendar_ IN VARCHAR2) IS BEGIN EXE...
Fye asked 25/8, 2014 at 15:10

3

Solved

Example I have table named from A - Z , but only table "A" and table "J" have a column clm varchar(10). But then I realized that I needed clm to be of size 50 (given that I do not know th...
Intercostal asked 13/8, 2014 at 8:47

1

Solved

I have to resort to raw SQL where the ORM is falling short (using Django 1.7). The problem is that most of the queries end up being 80-90% similar. I cannot figure out a robust & secure way to ...
Marianomaribel asked 7/8, 2014 at 15:25

1

Solved

I am new in PostgreSQL and I wonder if it's possible to use number from table tbc as part of the table name in left join 'pa' || number. So for example if number is 456887 I want left join with tab...
Dewees asked 16/7, 2014 at 8:18

1

Solved

I'm new to Postgres and have a database with multiple tables of the same structure. I need to select data from each table that matches certain criteria. I could do this with a bunch of UNION queri...

1

Solved

I need to create a function that checks on a given table if the infowindow field exists. If it exists the function must return select * from table but if it does not, it must return an additional i...
Unorthodox asked 29/5, 2014 at 9:11

4

Solved

I have a stored procedure that accepts multiple parameters (i.e. pName, pHeight, pTeam) I have the query built up like this: SQLQuery VARCHAR2(6000); TestCursor T_CURSOR; SQLQuery := 'SELECT ID,...
Candlewood asked 12/6, 2012 at 19:45

3

Solved

I need to do the same deletion or purge operation (based on several conditions) on a set of tables. For that I am trying to pass the table names in an array to a function. I am not sure if I am doi...
Reparable asked 18/5, 2014 at 15:51

3

Solved

I have a table similar to the following: CREATE TABLE stats ( name character varying(15), q001001 numeric(9,0), q001002 numeric(9,0), q001003 numeric(9,0), q001004 numeric(9,0), q001005 nume...
Accost asked 17/5, 2014 at 23:22

4

Solved

All, I want to start the numbering of an IDENTITY field based on the current maximum obtained from another table. So I have tried something like the following DECLARE @CurrentES INT; SET @CurrentE...
Lemures asked 24/7, 2012 at 11:31

© 2022 - 2024 — McMap. All rights reserved.