Highlighted

Dynamic table name for RDBMS?

travistravis

25-10-2017

This is in Campaign 6.1.

I'm having some trouble getting this to work. We're trying to set up a system to pull a specific set of customers each day from a PostreSQL database we have set up as RDBMS. This works fine for regular deliveries and campaigns, but this time we want to be able to dynamically generate the name of the table. (Basically they will be along the lines of 'call_back_2017_10_25' with the date changing each day.

I've managed to put javascript into the initialization that can get me the table name I want - but am at a loss for where to assign the database to actually use it. (I've tried a few things.)


When I assign the table name as normal in the GUI and pull the XML for each the failed and non-failing it seems that the bad one is not getting the connection.  The error I get is as follows (some stuff redacted)

25/10/2017 14:01:47 dbImport PostgreSQL error: ERROR:  syntax error at or near ")" LINE 1: COPY wkf295681483_55_1 () FROM STDIN                                 ^

25/10/2017 14:01:47 dbImport Starting 1 connection(s) on pool 'nms:extAccount:153296623 ****' (PostgreSQL, server='*******', login='******')

25/10/2017 14:01:47 dbImport Loading data from table 'happy_birthday_v2' (step 'Data loading (RDBMS)')

I know there's a lot we should fix (like using FDA and updating our server), but I'm willing to bet this is just down to me not understanding how all the bits connect, this is my first foray into attempting scripts in initialization (or at all.) Can anyone see anything obvious I would have missed?

Replies

Highlighted

travistravis

26-10-2017

As a followup:Screen Shot 2017-10-26 at 11.02.28.png

I deleted this activity and re-added it (since it was missing part of the activity, I thought maybe that would help). Upon creating as normal and setting things up for a normal data loading, I added an initialization script that dynamically pulled the name of another table. It did load this table correctly.

HOWEVER. On a second run of this workflow (since it will be ran repeatedly using a scheduler), it fails. It is fixed if I hit the above button "Update Schema Structure". But I can't tell what this button does, or how I can trigger this behaviour from inside a script. (I can do it after creating the table name - but don't know what it does.)

Highlighted

florentlb

06-11-2017

Hi Travis,

Can you share some more screenshots of your workflow so we can get a better overview of your process here? In which activity did you set the initialization script?

Florent