Question

I'm really frustrated with JavaDB and Netbeans! ANY help would now be appreciated. I use Netbeans 7.2.1 with the latest Java SDK.

OBJECTIVE:
Import data in CSV format from file located in C:\ into a JavaDB table named APP.USERS.

WHAT I'VE DONE:
I've used the following codes to try and import the data into the table, using the SQL Query utility in Netbeans:

  1. CALL function:

CALL SYSCS_UTIL.SYSCS_IMPORT_TABLE (null, 'USERS', 'FIRSTNAME,LASTNAME,USERNAME,PASSWORD,UNIQUENR,MEMBERSINCE,DOB,EMAIL,AWARDPOINTS,USERTYPE', 'c:\SQL_APP_USERS', '\n',',','UTF-8', 0); ` SELECT * FROM APP.USERS;`

  1. The "other" function:

INSERT INTO APP.USERS(FIRSTNAME,LASTNAME,USERNAME,PASSWORD,UNIQUENR,MEMBERSINCE,DOB,EMAIL,AWARDPOINTS,USERTYPE) VALUES (FROM 'c:\SQL_APP_USERS.txt' WITH ( FIELDTERMINATOR = ',', ROWTERMINATOR = '\n' )); --Check the content of the table. SELECT * FROM APP.USERS;

ISSUES:

  • Reading the Oracle KB docs doesn't help me at all!!! (http://docs.oracle.com/javadb/10.4.1.3/tools/ctoolsimport16245.html)
  • Executing first mentioned function shows result: Error code -1, SQL state 42Y03: 'SYSCS_UTIL.SYSCS_IMPORT_DATA' is not recognized as a function or procedure.
  • Executing second mentioned function shows results: Error code -1, SQL state 42X01: Syntax error: Encountered "FROM" at line 2, column 9

PLEASE - HELP.

Was it helpful?

Solution

1.) The specified function you give us

CALL SYSCS_UTIL.SYSCS_IMPORT_TABLE (...

does not match the error message

SYSCS_UTIL.SYSCS_IMPORT_DATA is not recognized as a function or procedure.

2.) The number of values ​​passed does not meet the required.
There is no overloaded function with 8 parameters.

CALL SYSCS_UTIL.SYSCS_IMPORT_TABLE 
   (null,'STAFF','c:\output\myfile.del',';','%',null,0);
     1      2             3              4   5   6   7

CALL SYSCS_UTIL.SYSCS_IMPORT_TABLE 
   (null, 'USERS','FIRSTNAME,...,', 'c:\SQL_APP_USERS', '\n',',','UTF-8', 0);
     1      2             3                  4            5   6     7     8

Also the sequence is wrong .
That would mean that each column is a separate line.

'\n',','

should be

',','\n'

3.) It would be nice if it were that easy.

INSERT INTO ... VALUES (FROM 'c:\SQL_APP_USERS.txt'

So here’s a simple Java Utility class that can be used to load CSV file into Database.

Import CSV into Database example

Tested:

  • create a empty file c:\myfile.del

CALL SYSCS_UTIL.SYSCS_IMPORT_TABLE 
     (null,'CUSTOMER','c:\myfile.del',';','%',null,0);

enter image description here

Here, with table FRIENDS created for test.

enter image description here

Since file 'c:\myfile.del' is empty, so nothing to do .
NO error : is not recognized as a function or procedure

enter image description here

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