Questions tagged [dynamic-sql]

Dynamic SQL is a technique using SQL (Structured Query Language) whose main difference from traditional SQL is that Dynamic SQL allows to build SQL statements dynamically at runtime, which eases the automatic generation and execution of program statements.

2681 questions
0
votes
1 answer

How to create table with its columns based from the parameter passed from function in PostgreSQL?

I want to create a function or stored procedure that will create the table in PostgreSQL with its columns based from the parameter passed through the function. The example of the parameter will be in jsonb type, like this: { "columns": [ …
Sivvie Lim
  • 784
  • 2
  • 14
  • 43
0
votes
1 answer

PL/SQL Dynamic case when statement for parameters to pass into Java

I am fairly new to PL/SQL so I haven't been able to piece out some of the logic (specifically execute immediate) In my PL/SQL statement, I am essentially trying to create a trigger for a prompt where the user could either have D1.SESSION or D1.A. I…
editi
  • 41
  • 4
0
votes
1 answer

How to Dynamically Retrieve JDBC ResultSet Data

The requirement is :- The application will run dynamic SQLs and show the results in table format in JSP. The SQL passed to the application will change, which means the number, name, datatype of selected columns will change and so the result set will…
0
votes
1 answer

PL SQL Procedure using dynamic sql to take backup of a random table in a schema supplied during execution of the procedure

I would like to create a procedure that: Creates a backup of a table when supplied the table name and the owner when the procedure is executed. Does a count of the records of the backup table Insert a row (owner, table_name and sysdate) into a…
laureen85
  • 5
  • 1
  • 4
0
votes
0 answers

How to write EXECUTE INTO statement in PostgreSQL

I have write like this code in PostgreSQL. But value is not inserting into BENMASTHIST table. please help to solve this error. EXECUTE 'INSERT INTO BENMASTHIST SELECT BENMAST_ENTITY_CODE, BENMAST_CUSTOMER_CODE, BENMAST_BEN_CODE, …
sp k
  • 25
  • 4
0
votes
2 answers

How to create a database, table and Insert data into it and use it as a source in another data flow in SSIS?

I have a need to create a SQL database and a table and Insert data into the table from another SQL database . And also to use this newly created database as a oledb source in another dataflow in the same SSIS package. The table and database name are…
0
votes
1 answer

How to know if a procedure has successfully executed using dynamic sql in PL/SQL?

I am trying to get an OUT parameter calling a procedure dynamically using bind parameters. The procedure has some IN parameters and an OUT parameter. The IN parameters are fetched from a single column containing all the parameters separated with…
Doodledim
  • 1
  • 1
0
votes
2 answers

How to execute Dynamic sql with insert statement in Oracle

Below sql command is not working in procedure PROCEDURE P_EMPDETAIL AS V_WHERE := 'E.EMP_ID = 123'B BEGIN EXECUTE IMMEDIATE 'INSERT INTO EMPLOYEE E ' || V_WHERE || ; END;
0
votes
0 answers

MySQL - Use UNION to create a dynamic query that would integrate records from 30 different tables every month

I have datewise data in 30 different tables. The names of the tables are as follows - wh_available_items.01/06/2022, wh_available_items.02/06/2022, and so on for the rest of the dates of the month of June. I want to combine all these records in a…
Zaid Azim
  • 31
  • 1
  • 6
0
votes
1 answer

Pass ANY string as a in parameter to a stored procedure in mysql (dynamic)

I am experiencing some trouble when I pass date-like strings to a input parameter of a stored procedure. The table I try to modify has following columns: create table localdevid.product_a( INDX int PRIMARY KEY NOT NULL AUTO_INCREMENT, ProdID int…
Bodo
  • 15
  • 5
0
votes
2 answers

Oracle: Dynamic SQL query error for subquery right parenthesis(ORA-00907: missing right parenthesis)

I have executed below block and I am getting the error message as ORA-00907: missing right parenthesis. I have closed right parenthesis but still it is giving error. I am not understating what is wrong in my query. Can anyone please suggest the…
Devendra S
  • 45
  • 4
0
votes
0 answers

Using variable to create temporary table as another table

I'm building a procedure into SQL Server, and for that I need to receive a table name as a variable, create a temporary table based on the table requested, search some substrings on each column of the given table, remove then, and return the result…
0
votes
2 answers

Oracle View or Table Function that returns union of queries stored as text in another table

Let's say that I have a "Rules" table that has a column that contains oracle queries in a varchar2 column: Row Query 1 select 'Hardcoded_Tablename_1' tablename, request_id from table_1 where status >= 4 and resolve_date < *some date math…
P.B.
  • 15
  • 1
  • 7
0
votes
1 answer

How to SELECT a value into a variable using a dynamic SQL statement to do the assignment in MariaDB?

I'm trying to use a dynamic SQL statement to retrieve a value and assign it to a variable, in a stored procedure. The problem is, when executing the dynamic statement, it can't access the variable declared in the procedure scope. Here is a fragment…
0
votes
0 answers

Create a temp table at run time without knowing the list of columns before hand

How can I create a temp table if I don't know the name of columns? Names of columns I get at run time with some dynamic pivot so for example my DECLARE @cols AS NVARCHAR(MAX) now has a comma separated list of columns like '[First_Name],[Last_Name],…
UnskilledCoder
  • 192
  • 1
  • 11