Forum Discussion

clarrivey's avatar
clarrivey
New Contributor
4 years ago

Using union in Execute SQL snap

I have an Execute SQL where I wan to add column names to my output file before adding the data. For example:
select ‘Last_Name’||chr(09)||‘First_Name’ from sys.dual
union
select rtrim(spriden_last_name) from spriden||chr(09)||select rtrim(spriden_first_name) from spriden
If I do this, I get an output of:
Alastname Afirstname
Blastname Bfirstname
.
.
.
Last_Name First_Name
.
.
.
Zlastname Zfirstname
when in fact, what I want is
Last_Name First_Name
Alastname Afirstname
Blastname Bfirstname
.
.
.
Zlastname Zfirstname

Anyone have a clue as to how to get this???

5 Replies

    • izzy_babcock's avatar
      izzy_babcock
      New Contributor II

      Thank you for your reply @Spiro_Taleski.
      I had read over the documentation, but I am not sure how to actually get it to list the file names into another file. Which snaps should I use in this case?

      • SpiroTaleski's avatar
        SpiroTaleski
        Valued Contributor

        @izzy.babcock

        Once you get all the files from the ftp location using the Directory Browser Snap, you can use a Mapper Snap in order to map necessary fields produced by the Directory Browser Snap.

        My question is: Do you want only to print/store the file names from ftp in one file in SnapLogic? Or do you want for each file on ftp to create separate file in SnapLogic project folder?

        Based on the type of the file(csv, json, xml, excel), that you want to store the details, there are designated Snaps for each like: JSON Formatter, CSV Formatter etc.

        Regards,
        Spiro Taleski

    • izzy_babcock's avatar
      izzy_babcock
      New Contributor II

      Hi @Spiro_Taleski,

      Thank you for sharing this sample pipeline with me.

      When I run it (after updating it so it reflects my files), the result is an .xlsx with binary content, but I thought that the file writer would read binary and write it as document to the endpoint. Am I missing something?

      Also, how do you know that $Name references the name of the file in a directory? How do I know what can be referenced as a variable/field for a specific snap?

      Thanks in advance.

      Best,
      Izzy Babcock

      • SpiroTaleski's avatar
        SpiroTaleski
        Valued Contributor

        @izzy.babcock

        Once you run the pipeline, the file is stored in the same project space where the pipeline is located. You can download the file, and the data will be in human-readable format.

        The Directory Browser Snap on the output in the $Name it references the Name of the file on that location.

        Regards,
        ST