Results 1 to 6 of 6
i currently have a shell script in which i am trying to pass a txt
file, by lines into a sql script. the txt file looks like this:
filename.ext : ...
- 08-14-2007 #1Just Joined!
- Join Date
- Jul 2007
- Posts
- 14
bash to sql
i currently have a shell script in which i am trying to pass a txt
file, by lines into a sql script. the txt file looks like this:
filename.ext : category PossiblyAnotherCategory
filename2.ext : category PossiblyAnotherCategory
...
For each line, set each word as a variable and pass it to the sql
script..is this possible?
- 08-14-2007 #2
Best way to do this would be through awk. something like this:
Would set the variable "variable1" to the first word on the line eg. filename.ext filename2.ext. Put this in a loop along with the creation of the SQL statement, and this should give you a good starting ground.Code:variable1=`echo $line | awk '{print $1'}`"I am not an alcoholic, alcoholics go to meetings"
Registered Linux user = #372327
- 08-14-2007 #3Just Joined!
- Join Date
- Jul 2007
- Posts
- 14
thank you much
- 08-14-2007 #4Just Joined!
- Join Date
- Jul 2007
- Posts
- 14
okay I am using an API called set_attribute which uses the parameters
ID and CATEGORYID... and I am taking what I have in this file, using
the file name to find the ID number, then I am going to look up the
categories number by the name of the category. It basically is
programatically applying categories to those files
- 08-15-2007 #5
In that case, might i suggest a slightly different method. If you had a lookup table for the "categories" and then a linking table that sits between the categories and files table, you could lay the text file out like:
I suggest this since it seems that you dont know for certain how many categories a file may be attributed to, therefore the linking table means you dont need to create a new field on the files table to add an extra category, since with this, a lot of the fields will be blank.Code:filename.ext category filename.ext another_category filename2.ext yet_another_category filename2.ext another_category
"I am not an alcoholic, alcoholics go to meetings"
Registered Linux user = #372327
- 08-21-2007 #6Just Joined!
- Join Date
- Jul 2007
- Posts
- 14
now I am going to be attempting to use sql*loader


Reply With Quote
