Home » RDBMS Server » Server Utilities » unix variables in control file
unix variables in control file [message #73971] Thu, 12 August 2004 11:17 Go to next message
Santosh George
Messages: 27
Registered: June 2002
Junior Member
I am using sqlldr from a unix. I want to pass in the data file name,
table name and table partition name as unix variables that are exported
from the shell script. However, while the data file is recognized by
the control file, the table and partiton names are not - SQL Loader
complains of expecting double quotes for ${TMP_TABLE} and ${PARTITION_NAME}

OPTIONS
(
 ERRORS=100,
 DIRECT=FALSE,
 SILENT=(HEADER,FEEDBACK)
)
LOAD DATA 
INFILE '${CIR_DATA}/summary/${DAT_FILE}'  "fix 326"
APPEND
PRESERVE BLANKS
INTO TABLE ${TMP_TABLE} PARTITION ${PARTITION_NAME}

I also tried the following lines with no luck
INTO TABLE '${TMP_TABLE}' PARTITION '${PARTITION_NAME}'
INTO TABLE "${TMP_TABLE}" PARTITION "${PARTITION_NAME}"

All the unix variables are being exported from the calling shell script.
What is the correct syntax please?

 
Re: unix variables in control file [message #73979 is a reply to message #73971] Fri, 13 August 2004 05:42 Go to previous messageGo to next message
Mahesh Rajendran
Messages: 10708
Registered: March 2002
Location: oracleDocoVille
Senior Member
Account Moderator
-- lets check the table

bash-2.03$ sqlplus -s mag/mag << EOF
> select * from member;
> exit;
> EOF

no rows selected

-- lets run the shell script

bash-2.03$ sample

invoking the sql*loader
using table member

SQL*Loader: Release 9.2.0.4.0 - Production on Fri Aug 13 09:42:22 2004

Copyright (c) 1982, 2002, Oracle Corporation.  All rights reserved.

Commit point reached - logical record count 4

-- lets check whether records are loaded

bash-2.03$ sqlplus -s mag/mag << EOF
> select * from member;
> exit;
> EOF

NAME       ADDRESS
---------- --------------------
Charlie    250yonge
Ben        123King
Ben        123king
Peter      5Brook

--
-- this is the script.
-- 

bash-2.03$ cat sample
#!/usr/bin/bash
intable=member
echo load data                                    > temp1.ctl
echo infile 'member.dat'                         >> temp1.ctl
echo replace into table $intable                 >> temp1.ctl
echo fields terminated by ',' trailing nullcols  >> temp1.ctl
echo (name,                                     >> temp1.ctl
echo address)                                    >> temp1.ctl
echo
echo invoking the sql*loader
echo using table $intable
sqlldr userid=mag/mag control=temp1.ctl

Re: unix variables in control file [message #73982 is a reply to message #73979] Sat, 14 August 2004 12:36 Go to previous message
Santosh George
Messages: 27
Registered: June 2002
Junior Member
Thanks for the suggestion. I also came across another method which involves parsing the control file using unix's SED command and replacing the variables like table name or partition name with the values I want. This search and replace will be done from the calling script.
Previous Topic: imp ignore=y gives erorr ora-0001
Next Topic: Sql loader insert into multiple table failing
Goto Forum:
  


Current Time: Wed Dec 25 07:38:49 CST 2024