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.6K Connect
- 1.2K Connectors
- 300 Workbench
- 6 Cloud Amplifier
- 9 Federated
- 2.9K Transform
- 102 SQL DataFlows
- 626 Datasets
- 2.2K Magic ETL
- 3.9K Visualize
- 2.5K Charting
- 753 Beast Mode
- 61 App Studio
- 41 Variables
- 692 Automate
- 177 Apps
- 456 APIs & Domo Developer
- 49 Workflows
- 10 DomoAI
- 38 Predict
- 16 Jupyter Workspaces
- 22 R & Python Tiles
- 398 Distribute
- 115 Domo Everywhere
- 276 Scheduled Reports
- 7 Software Integrations
- 130 Manage
- 127 Governance & Security
- 8 Domo Community Gallery
- 38 Product Releases
- 11 Domo University
- 5.4K Community Forums
- 40 Getting Started
- 30 Community Member Introductions
- 110 Community Announcements
- 4.8K Archive