Question

I am not sure if this is possible or not, but here is my problem with select expression in a sql loader file.

I have two tables.

TABLE 1

IDENTITYNUMBER

ID NUMBER
100 8
200 9

TABLE 2

TESTTABLE

NAME ID
John 100  

data file for the loader sql

Jim,8
Carol,9

Now, I want to load this data in test table by replacing the second number with the id from the first table.

So this is how my test.ctl file looks like

load data
append
into table testtable
fields terminated by ',' optionally enclosed by '"'
(
NAME,
ID EXPRESSION "(select i.id from identitynumber i where i.number = :ID)"
)

But I keep getting this error: SQL*Loader-291: Invalid bind variable ID in SQL string for column ID

I expect the table 2 to look like this after a successful execution of the loader script.

TESTTABLE

    NAME  ID
    John  100 
    Jim   100
    Carol 200

Any pointers will be greatly appreciated.

Was it helpful?

Solution 2

I don't think select's are allowed in sqlldr EXPRESSION Functions are:

create function idtestfun(p_num in number) return number
is
  l_num number;
begin
  select id into l_num from identitynumber where "number"= p_num;
  return l_num;
end;

and use it sqlldr config:

ID "idtestfun(:ID)"

OTHER TIPS

Do without "expression"

ID "(select i.id from identitynumber i where i.number = :ID)"

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top