Forum Discussion
Hi @Siva_Venna,
I think that would work. It seems like there’s a bug in the SQL snap’s expression evaluation where it’s choking on Date.now(), but if you already have the $year field I would think you can use ‘abc_’ + $year to get the tablename. Give it a try!
- Judy
I gave a try it did not work. Hope the fix will resolve the issue.
- alchemiz6 years agoContributor III
instead of using the getFullYear which by the way the output in an integer type which I think causing the sql select snap to haywire 🙂 you can use concat
e.g.
‘abc_’.concat(Date.now().toLocaleDateString({‘format’:‘yyyy’}))or if you want to stick with the getFullYear() try to cast it as string
‘abc_’ + Date.now().getFullYear().toString()
- Siva_Venna6 years agoContributor
@alchemiz It didn’t work
- alchemiz6 years agoContributor III
I saw this write up from a Postgesql update snap, I wonder if this applies to all database type snaps ?
Do you mind putting a pipeline parameter and test it? If this can be allowed from the pipeline parameter then you can use an expression library and put the function there
sample of expression file content
{
‘getDynamicTableName’ : (table_prefix = “abc_”) => table_prefix.concat(Date.now().getFullYear().toString())
}then set the expression file in the pipeline and invoke the method in the SQL select snap under table name
e.g lib.extender.getDynamicTableName()
The values can be passed using the pipeline parameters but not the upstream parameter