Table Variables in Workbench
I have the following snippet of SQL code that I'm testing in Domo Workbench, basically just populating a table variable with one row for each of the previous 18 months. Domo Workbench (3.1.5714.35059) will validate the code, but I can't get it to preview. When I click the Preview button, I see messages that the query executed, etc, but the preview is never shown. No error messages, no nothing.
declare @pds table (
EvtMo smallint
,EvtYr int
)
declare @tmpDate date = getdate()
while datediff(month,@tmpDate,getdate()) < 18
begin
insert into @pds select datepart(month,@tmpdate), datepart(year,@tmpDate)
set @tmpDate = dateadd(month,-1,@tmpDate)
end
select * from @pds
Best Answers
-
Hey Chris -
Maybe I'm missing exactly what you're trying to do but can you create the final table outside of Domo and then import? You could use MySQL or PostreSQL interface to run the join of the datasets.
Or, you could import both datasets and join them using a MySQL dataflow in Domo.
- Aaron
0 -
Hi Adam--
Thanks for your message. I finally managed to figure this out... I had a stored proc (my back-end is SQL Server) that gave me exactly the dataset I needed, using a table variable for the table of months... I've since created a physical table of months that I'm now using instead, and Domo Workbench is handling that just fine.
It sounds weird, but for some reason, I only realized that option while reading your last message, so thanks for that. =^)
==
Chris
1
Answers
-
0
-
Or even if I could find out what the "dos and don'ts" are, for the SQL code being run by the Domo Workbench... It looks like table variables and temp tables aren't acceptable... can someone confirm this? Are there any more of these types of "gotchas"?
0 -
Hey @northshorehiker -
I don't think that you can pass a table variable as in input, it doesn't work like a create table function.
Have you tried using the transforms available in workbench to get the dates you're looking for? Or, have you tried importing the table and creating a MySQL dataflow within Domo?
The workbench documentation is pretty good, take a look here.
Hope this helps!
0 -
Thank you for your response.
My apologies, I probably should've included this in my initial message.,,, Ultimately, what I need to do is upload a dataset that contains one row for each of the past 18 months, along with some figures for each month. For some months, there will be no data, so it would just display zeroes in those rows. So, I thought that starting with a table of the past 18 months and left joining it to a table of the data figures summarized by month would do the trick, (and does, in a stored procedure) but I can't figure out how to get it to Domo workbench in a method that's acceptable. Thank you for the Workbench documentation link; I'll take a look at that.
==
Chris0 -
Hey Chris -
Maybe I'm missing exactly what you're trying to do but can you create the final table outside of Domo and then import? You could use MySQL or PostreSQL interface to run the join of the datasets.
Or, you could import both datasets and join them using a MySQL dataflow in Domo.
- Aaron
0 -
Hi Adam--
Thanks for your message. I finally managed to figure this out... I had a stored proc (my back-end is SQL Server) that gave me exactly the dataset I needed, using a table variable for the table of months... I've since created a physical table of months that I'm now using instead, and Domo Workbench is handling that just fine.
It sounds weird, but for some reason, I only realized that option while reading your last message, so thanks for that. =^)
==
Chris
1 -
Sweet, glad you got this squared away!
0 -
Hi,
I'm working exactly on the same business requirement. The data sits in Salesforce, and I'm using a connector to pull it into Domo and then manipulate it. But, the problem is , I'm trying to create a dataflow to run stored procedure. However, Domo wouldn't execute the code and keeps throwing an error at variable declaration in the procedure.
Following is the code, I've used: Could you help me figure out what I'm missing here, or something that has worked for you :
drop procedure if exists load_foo_test_data;
delimiter $$
create procedure load_foo_test_data()
BEGINSet @v_max = 13;
Set @v_counter =1;start transaction;
while `v_counter` < `v_max` do
insert into cb_sf_masterdata (FinalRevenue) value(adjustedrevenue/13) ;
set `v_counter`= `v_counter`+1;
end while;
commit;
end; $$delimiter ;
Thank you
0
Categories
- All Categories
- 1.8K Product Ideas
- 1.8K Ideas Exchange
- 1.5K Connect
- 1.2K Connectors
- 296 Workbench
- 6 Cloud Amplifier
- 8 Federated
- 2.9K Transform
- 100 SQL DataFlows
- 614 Datasets
- 2.2K Magic ETL
- 3.8K Visualize
- 2.5K Charting
- 729 Beast Mode
- 53 App Studio
- 40 Variables
- 677 Automate
- 173 Apps
- 451 APIs & Domo Developer
- 45 Workflows
- 8 DomoAI
- 34 Predict
- 14 Jupyter Workspaces
- 20 R & Python Tiles
- 394 Distribute
- 113 Domo Everywhere
- 275 Scheduled Reports
- 6 Software Integrations
- 121 Manage
- 118 Governance & Security
- Domo Community Gallery
- 32 Product Releases
- 10 Domo University
- 5.4K Community Forums
- 40 Getting Started
- 30 Community Member Introductions
- 108 Community Announcements
- 4.8K Archive