Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
serda
Regular Visitor

Run a DDL statement before query getting data

Hi everybody!

 

I am trying to retrieve data directly against Teradata with the import mode and writing the SQL query in the optional textbox. Teradata raises an error because it can't run a DDL statement with a DML statement in the same transaction.

 

It could be nice to separate DDL and DML statements in different sessions/connections from Power BI to databases.

 

In my case, I need to run this DDL statement in order to have access to several tables:

 

SET ROLE sampleRole;

 

If in the query textbox I try the following:

 

SET ROLE sampleRole;

A query;

 

The below error is raised:

 

"Teradata: [Teradata Database] [3932] Only an ET or null statement is legal after a DDL Statement."

 

I have tried to embrace the DDL statement in a transaction but the same error is raised:

 

BT;

SET ROLE sampleRole;

ET;

A query;

 

Does anyone comes up with anything?

 

Thanks in advance!

1 ACCEPTED SOLUTION

Hi @serda,

 

As the error message stated, it's not supported to use DDL and DML at the same time when connecting to Teradata database in desktop. In my opinion, SELECT statement will return records based on the entered credential which used to connect to Taradata database. So we can just set permission for this account on Teradata database side, and write SELECT statement in the query box.

 

In your scenario, please set proper permission for the account used to access Teradata database. Only write "SELECT * FROM the Table" in desktop query box.

 

Best Regards,
Qiuyun Yu

Community Support Team _ Qiuyun Yu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

3 REPLIES 3
v-qiuyu-msft
Community Support
Community Support

Hi @serda,

 

As far as I know, DDL is used to alter/modify a database or table structure and schema. While DML affects row records in a table. In your scenario, I guess the issue is that it's not supported to use DDL statement when you connect to Teradata database. Please try to write the DML statement like SELECT instead of DDL.

 

Best Regards,
Qiuyun Yu

Community Support Team _ Qiuyun Yu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

I have to run a DDL statement in order to have permissions to SELECT a table, I try the following statements:

 

SET ROLE theRoleIneed;

SELECT * FROM theTable;

 

But, Teradata do not let you write a DDL statement with a DML statement in the same transaction, my question is if there is a way to avoid this, for example, Power BI could perform two different sessions/conections independently. Or maybe with BTEQ you can avoid this although I tried with this excerpt:

 

BT;

SET ROLE theRoleIneed;

ET;

BT;

SELECT * FROM theTable;

ET;

 

 

Thank you for your try, I did not explain it well.

Hi @serda,

 

As the error message stated, it's not supported to use DDL and DML at the same time when connecting to Teradata database in desktop. In my opinion, SELECT statement will return records based on the entered credential which used to connect to Taradata database. So we can just set permission for this account on Teradata database side, and write SELECT statement in the query box.

 

In your scenario, please set proper permission for the account used to access Teradata database. Only write "SELECT * FROM the Table" in desktop query box.

 

Best Regards,
Qiuyun Yu

Community Support Team _ Qiuyun Yu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.

Top Solution Authors
Top Kudoed Authors