[SOLVED] (Feature already exists): user-defined variables in comment directive CSV/Excel

zitot

Member²
EDIT: SOLVED, see 2nd and 3rd posts.
Hello,

I tried putting this line and hitting the Export to CSV button above the result set but the resulting filename just had &var in the name without substituting

-- CSV=C:\excel\Person &var Aggregated Data from v1.4.0-alpha.1-20250812.csv
-> Person &var Aggregated Data from v1.4.0-alpha.1-20250812.csv
As for bind variable, that one just failed to input into the filename when it saw the colon
-- CSV=C:\excel\Person :var Aggregated Data from v1.4.0-alpha.1-20250812.csv
-> Person

Using %var% did not work either
Person Aggregated Data from v1.4.0-alpha.1-20250812.csv

It would be nice to allow custom variable. Or maybe I did something wrong?

P.S. I know there is some package or procedure i can call to output with PL/SQL (utl_file.put_line?), just happened to try this today.
 
Last edited:
Environment variables should work. For example:

Code:
-- csv=%USERPROFILE%\Documents\dept.csv
SELECT * FROM dept;

After executing and selecting Export Results > CSV File, the dept.csv file is automatically saved to your Documents directory.
 
Oh, I went and reread that page and saw %&var% in the manual to expand user variables.

For regular environment variables, following %var%, I also have that working now, not sure why it wasn't before.

Though I can't get it working with user level env var I don't really need that since those two are enough

Thanks Marco,
Thomas
 
Last edited:
Back
Top