how do i execute nohup and background job inside the korn script for db2

load_cursor_stmt()
{
ls /db/admin/ddl/rmn01000/load_cursor*.sql|while read file
 do
 echo "${file}"
   `nohup  db2  -tvf "$file"  \&`
done
}

Error:
-------

/admin/ddl/rmn01000/load_cursor5.sql /db/admin/ddl/rmn01000/load_cursor6.sql
+ read file
+ echo /db/admin/ddl/rmn01000/load_cursor1.sql
++ nohup db2 -tvf /db/admin/ddl/rmn01000/load_cursor1.sql '&'
+ DB21004E You cannot specify both an input file and a command when invoking the Command Line Processor.

Usually nohup is around the outer script, and then all the children are nohup. Some db2 tools talk to background processes, so it helps to start the session in the nohup script. Then you are just generating input. You can mix files and script decisions by just letting the script generate all the input to the db2 client.

Is this a product called "Korn script for DB2" or just a ksh script talking through a db2 command line client?

If it gets too painful, you can use xigole jisql and the free jdbc jars to get a nice friendly and simple db2 client.

First impressions, too much punctuation. Assuming that this is meant to be a Korn Shell Function called with load_cursor_stmt later in the full script:

Corrected code:

load_cursor_stmt()
{
ls /db/admin/ddl/rmn01000/load_cursor*.sql|while read file
 do
 echo "${file}"
   nohup db2 -tvf "$file" &
done
}

The backticks are pointless and not required or desirable. The escape of the background command "&" as "\&" is not required or desirable and caused the parameter "&" to be presented to the "db2" command and not executed by the Shell.

It is not working ,Pls see the error

DB21018E A system error occurred. The command line processor could not
continue processing.
DB21018E A system error occurred. The command line processor could not
continue processing.
DB21018E A system error occurred. The command line processor could not
continue processing.
DB21018E A system error occurred. The command line processor could not
continue processing.
DB21018E A system error occurred. The command line processor could not
continue processing.
DB21018E A system error occurred. The command line processor could not
continue processing.

load_cursor_stmt()
{
ls /db/admin/ddl/rmn01000/load_cursor*.sql|while read file
do
nohup db2 -tvf "$file" &
done

}