ph_importdata PowerHome formula function
Description
Imports data into a Data
Retrieval area
Syntax
ph_importdata ( i_dsvar, as_data, ai_datatype, ai_importtype )
Argument | Description |
i_dsvar | Integer. The Data Retrieval area number. Valid
values are 1 thru 20 |
as_data | String. The raw data to be imported or a full
path and filename of a file to be imported |
ai_datatype | Integer. The type of data to import. 0 is for
tab separated text. 1 is for CSV (comma separated values). 2 is for XML
formatted data. Any other value will return an error |
ai_importtype | Integer. The type of data in the as_data
parameter. A value of 0 indicates raw data. Any other value indicates a filename |
Return value
Long. Returns the number of rows imported if
the function is successful.
Returns one of the negative numbers below if
an error occurs:
-1 No rows to import
-2 Empty file
-3 Invalid argument
-4 Invalid input. This is the most common error and can result from the import data not matching the columns or the import data exceeds the internal column length
-5 Could not open file
-6 Could not close file
-7 Error reading file text
-8 Unsupported file name suffix (must be *.txt, *.csv, *.dbf or *.xml)
-11 XML parsing error
-12 XML template does not exist or does not match
-13 Unsupported style for import
-14 Error resolving nesting
-15 File size exceeds limit
-100 The i_dsvar parameter is out of range
-101 The Data Retrieval area is undefined
-102 An invalid ai_datatype value was specified
Usage
Use this function to import formatted data
into a Data Retrieval area for further processing
Examples
The following examples demonstrate typical syntax/usage for this function.
• ph_importdata(1,"Test
Data 1~tSecond column~t14~r~nTest Data 2~tSecond column 2~t15~r~n",0,0) - Returns 2 for
the two rows of three columns of tab separated data in the as_data
parameter. The example assumes that Data Retrieval area 1 has already been defined
with a ph_sqlselect( ) function such as: ph_sqlselect(1,"select space(255),space(255),0 from dummy
where 1 =
0")