I want to create a postgresql procedure which creates a query and run it. I tried and research on forums. But i can not solve my problem. Procedure should get user input as a parameter and use it in query. My code like that : And this is the error : edit: form_field is a table. create statement : Answer
Tag: sql
Why PLSQL optimize level is not providing expected result?
I am trying to understand complier optimizations in plsql in depth. Theoretically, default optimisation level PLSQL_OPTIMIZE_LEVEL is set to 2. To get better performance, we can set it to 3. To …
Flyway don’t clean database correctly, and execute migration files two times
I’m using flyway for migration database, as well I use FlywayTest for my integration tests, but When I create a test using : I get this error : If you not : This comes from FlywayTestExecutionListener.class but it migrate the database again. Why flyway do this, and how can stop this. More details The pr…
MySQL select all column names where condition is met for specific row
I have a table which links users to groups which is set up as below: I would like to know if there is a method to select all groupIDs (column names) where a certain condition is met. E.g. if I want to find all groups where user 2 has a level greater than 0 it would return (1,2,4) It is
How can I pass a list, array or string to be separated as a parameter to redshift
I’m trying to write a simple query with an in clause like so: I need to be able to pass the values in the in clause as a parameter, the number of values in the in clause are variable and could be one or thousands depending on the user input. In other sql databases I have solved this problem by
Replace and squeeze boolean feedback columns to single score column in BigQuery
I have data that looks like this (note one TRUE per row): I want to replace each TRUE with a number that depends on the column that it is in (5-1), so a score with very_good being 5 and very_poor being 1, and then squeeze it into one column. So it looks like this: So far I’ve tried this: But
How do I use a variable to create a randomized date for every row in a column?
I’m currently trying to randomize every date inside a column! Will this create a single random date for the variable and assign it to every row, or will this generate a unique randomized date for every row? (I’m using a variable here instead of just doing it right in the update statement because I…
SQL Server: Drop all Not Null constraints in all DB tables
How do I drop all Not Null Constraints in All Columns in every table using SQL Server ? Would like to loop run this query in all tables and columns, How to remove not null constraint in sql server using query Note: requirement is for all non-primary key columns. Similar Question: How to drop all Foreign Key c…
Replacing case with IIF in SQL Server
So for my above query, I want to use IIF instead of CASE, because I want to show only uninsured patients, would something be correct? Because if I only use one case in my case scenario, the null will should up in my insurancestatus column instead of uninsured. Basically I just want the result for null showing…
Split array(bigint) to multiple rows of bigint
I’m querying some data (SQL, presto), each item can be the parent or child of another. The parent IDs and the child IDs are stored in the row for that primary ID as an array(bigint). Each task could be the child of multiple parents. It looks something like: I want a list of all of the parent Ids and eac…