-1

Help guys i need to make a dynamic infile. so the common infile is

INFILE 'yourcsvfile.csv'

LOAD DATA
INFILE 'yourcsvfile.csv'
append
INTO TABLE table_name
TRUNCATE
FIELDS TERMINATED BY ','

is it possible to make it like this?

INFILE (sysdate , 'YYYYMMDD') || (_STRING.csv)

so meaning im searching for 20160816_STRING.csv

Ken White
  • 123,280
  • 14
  • 225
  • 444
ve_1992
  • 19
  • 6
  • 3
    Please clarify what your actual problem is. – Tim Biegeleisen Aug 16 '16 at 01:07
  • im asking if i can actually make an infile depending on the current date added to a string? (sysdate , 'YYYYMMDD') || (_STRING.csv) – ve_1992 Aug 16 '16 at 01:08
  • You certainly can do this but it may have nothing to do with SQL. SQL is only consuming the file in this case. – Tim Biegeleisen Aug 16 '16 at 01:10
  • can u please check my question again sir. – ve_1992 Aug 16 '16 at 01:16
  • I don't think you can do this from within the `LOAD DATA` command, but it should be possible to create a script or batch file which can do this. What OS are you using? – Tim Biegeleisen Aug 16 '16 at 01:19
  • win 7. Yes im using it to upload an excel file to oracle – ve_1992 Aug 16 '16 at 01:22
  • 1
    If you're using Oracle, why do you have this tagged `mysql`? – Barmar Aug 16 '16 at 01:23
  • the post's tagged is oracle and sql loader lol – ve_1992 Aug 16 '16 at 01:27
  • You should check your keyboard. The CAPS LOCK key seems to have gotten stuck when you typed your question. It's important to keep your keyboard working, because on the internet posting in ALL CAPS is considered SHOUTING, and people think it's pretty rude when you shout at them for no reason, especially when you're asking them for free help. – Ken White Aug 16 '16 at 02:22

1 Answers1

2

You can create a Windows batch script which gets the current date in the format you want and then calls the Oracle loader:

set "part1=!date:~10,4!!date:~6,2!/!date:~4,2!"
set "part2=_STRING.csv"
set "yourfile=%part1%%part2%"

@echo LOAD DATA INFILE %yourfile% APPEND INTO TABLE table_name TRUNCATE FIELDS TERMINATED BY ','; | sqlplus username/password@database
Tim Biegeleisen
  • 502,043
  • 27
  • 286
  • 360