Passing data
from file as arguments to Stored procedures:
Using host Variables.
|
|||
Arguments to the stored procedure can come from a Data file.
USING clause of SQL provides a mechanism for
importing data from a file in to variables to used called HOST VARIABLES.
HOST
variables are recognized by the colon (:) ahead of their names.
Assume
we have a following procedure:
Here
we provide the name and salary in the procedure and we get a random value
output which is the multiplication of the salary and a random value.
Say
we have a file as below with name and salary details for each person and we
want to run the procedure for each record in the file.
more
inputfile1
sukul 100.11
rajan 1200.11
Following
is how we code in bteq to get this:
Note
the colons used to represent the host variables.
REPEAT
* indicates that the CALL should be repeated for every record in the file.
Note:
As are reading all data as characters we need to use .IMPORT REPORT
FILE
(Other option is .IMPORT DATA FILE=)
|
Pages
▼
No comments:
Post a Comment