0 - 14 of 14 tags for dynamic sql

Dear Experts,
 I need to write a script to count the not null rows in each field in the each of data mart tables.
it should be possible to generate this script from the  Oracle dictionary I believe,
statement can be something like this :
 spool count_fields.sql

Hi All,
I want to execute the below call procedure statement using a dynamic sql within a For loop of stored procedure.
call dbc.sysexecsql ('CALL dbname.'||proc_name_variable||'('||v1||','||v2||','||v3||','||v4||','||''||timestamp_variable||''||');' ) ;
But When i try to compile the procedure i am getting the following error.

Hi All,

Please help me through this

sel

a.col1,

a.co2,

a.col3,.........b.col1,b.col2..,c.col1,c.col2

from table1 as a inner join table2 as b on a.col1 =b.col1

inner join table 3 as c on a.col1 = b.col1

where col1 = xxxxx;

Hi Experts,

I am new to teradata, I came to know that qualfying is used in teradata to group the rows.

for eg :

I am getting a output 

emp_no  dept   sal      date

1

1               20     2000

1                                  6/13

 

The desired output should be

Hi.

 

I have a problem.

I have a cursor with a select statement.

The select statement returns 5 rows.

Row 1-- Select col 1

Row 2 --,col2

Row3---,col3

Row4---,col4

Row5--- From table A;

 

Hi All,

Recently someone told me that using Dynamic SQL in TD procedure is not a good practice for performance reasons. Is that true? Does it mean that for every procedure call procedure needs to re-compile?

Is there any way to avoid dynamic sql completely? Parameterizing query is something which I can not avoid.

Thanks

Hi All,

I am writing SP to generate dynamic SQL query which creates insert statements.

I want for a particular column the data should be fetched from another table. I have tried sample and top but teradata doesnt allow sub queries with sample statements.

Here is the sample scenario which I am trying to achieve

I'm trying to use my SQL Server to extract and store the results of dynamic queries executed on our Teradata server, but ran into technical difficulties - namely an 8k character limit on queries using OpenRowset, about half our queries are bigger than that.

I'm attempting to develop a stored procedure that takes a table name as a parameter, and performs column-by-column updates to whatever table is passed in.

I have the dynamic SELECT query working correctly:

SET CURSOR_SQL = 'SELECT * FROM ' || P_TABLE_NAME || ' ORDER BY rsid;';
PREPARE CURSOR_STATEMENT FROM CURSOR_SQL;
OPEN CDC_CURSOR;
/* logic */
CLOSE CDC_CURSOR;

Now I'm at the point where I need to fetch the cursor data into local variables...but I can't create table-specific local variables because I don't know what tables will be passed into this procedure.

Hello,

I have a current situation with a stored procedure and could use some guidance / advice. Currently we have a stored procedure that generates dynamic SQL which is based on customer inputs. Specifically, I'm having problems with a column being referenced in the SP that is undergoing funky range scans. I will refer to this column as ABC. Here are the 3 rangescan scenarios for ABC:

1) User enters the following: ABC = 100-105

How can I generate all permutation from the variables selected from different tables using SQL

For Example

In Table1 with Var1 has values:
Var1
1
2
3

In Table2 with Var2 has values:
Var2
4
5

In Table3 with Var3 has values:
Var3
7
8
9

Hi All

I've got a problem to resolve. Table contains an ID and two columns(lo,hi) defining range of numbers. I need output(table) that will contain as many records as are defined in a range for each ID.

Example table has 3 records

ID LO HI
1 10 12
2 1 5
3 27 30

I need such output:

i have couple of questions:

how to pass queries in the procedure ( i would be passing different queries at different times)
execute them as cursors
how to find out the no of coulmns in the cursor and fetch them into strings or array( as no of columns in the queries would be changing each for each call)

Until you have Teradata V13 Statistics Wizard Easy Feature available for your Teradata installation, here is a set of stored procedures that will generate and/or run collect statistics statements based on a set of index, column and referential integrity rules.