1. Scott Roberts
  2. Valentina Database ADK
  3. Montag, Juni 11 2018, 09:25 PM
  4.  Abonnieren via E-Mail
I am using Valentina ADK 8.3.2 with LiveCode.

I created a database using Valentina Studio. The database has one table. I created a snapshot of the database and have code in my program to create the database, if it is not found.

The SQL commands at the database level run fine when called with VDatabase_SqlExecute.

The command to create the table fails with Error 0x71000 - unexpected end of file. If I copy the SQL text for this command to the SQL Editor in Valentina Studio, the command executes without error.

I have attached a ZIP file containing the snapshot files along with the log file that was generated when I ran the LiveCode program.
Anhänge
Kommentar
There are no comments made yet.
Sergey Pashkov Akzeptierte Antwort
Hello Scott,

So when you execute VDatabase_SqlExecute with the CREATE TABLE statement it fails

-- CREATE TABLE "recently_opened_databases" --------------------
CREATE TABLE "recently_opened_databases"(
"name" VARCHAR ( 2044 ) DEFAULT '' NOT NULL,
"full_path" VARCHAR ( 2044 ) DEFAULT '' NOT NULL,
CONSTRAINT "unique_name" UNIQUE( "name" ),
CONSTRAINT "unique_full_path" UNIQUE( "full_path" ) );
-- -------------------------------------------------------------



We'll check it.
Kommentar
There are no comments made yet.
Ruslan Zasukhin Akzeptierte Antwort
Hi Scott,

Can you run our examples fine?
e.g. SQL / Records_AddDeleteUpdate

Also, please try to remove COMMENTS in the SQL query in LiveCode
Kommentar
There are no comments made yet.
Scott Roberts Akzeptierte Antwort
I was not able to run your examples. The call to VDatabase_Create failed. I have attached the log.

I removed the comments from the SQL query and received the same error.

Also, your example is not a true match to my code because your example calls VDatabase_CreateTable and VTable_Create... to create the table whereas my example is using VDatabase_SqlExecute to create the table (and its fields).
Anhänge
Kommentar
There are no comments made yet.
Scott Roberts Akzeptierte Antwort
I have determined the circumstances that cause the error but I am not sure what the solution is.

I ran the Field_CreateDrop example (in the SQL_Way folder) and it executed without error.

I found that, if I manually write the SQL statement to create the table (using string concatenation like the Field_CreateDrop example), then the table is created successfully.

However, if I read the SQL statement from the file that was generated by the Create Schema Snapshot tool, then I get the unexpected end of file error when the text from that file is passed to VDatabase_SqlExecute.

Is this a LiveCode issue rather than a Valentina issue?
Kommentar
There are no comments made yet.
Sergey Pashkov Akzeptierte Antwort
So you read both SQL files into strings, the first file executed, the second file failed.

Could you please show the snippet how you read data and pass to the SqlExecute function?

The file is UTF8 encoded, it could be some encoding issue, but the first file works.
Kommentar
There are no comments made yet.
Scott Roberts Akzeptierte Antwort
It seems that the statements executed by the first file are affecting the execution of the statement in the second file.

If I do not run the statements in the first file, then the CREATE TABLE statement executes without error. However, if I do run the statements in the first file, then the CREATE TABLE statement fails with unexpected end of file.

The first file was also created by the Create Schema Snapshot tool. Which of the commands in the first file do you think is causing the problem?
Kommentar
There are no comments made yet.
Scott Roberts Akzeptierte Antwort
FYI, the code that I use to execute the statement(s) in the file is:


open file tFullPath for read
read from file tFullPath until EOF
put it into tSql
close file tFullPath
get VDatabase_SqlExecute(tDB, tSql)
Kommentar
There are no comments made yet.
Scott Roberts Akzeptierte Antwort
I found that if I change the IOEncoding property of the database to UTF-8, then the CREATE TABLE statement runs without error. Is this something that I should do routinely, or is there another issue that needs to be addressed? For now, I can continue with this workaround.
Kommentar
There are no comments made yet.
Scott Roberts Akzeptierte Antwort
Sorry to keep posting replies, but my workaround is no longer working. I added another table to the database and now the unexpected end of file error occurs with every command after the first one that sets the properties of the database.

I had added a line of code to set the IOEncoding property to UTF-8 but now that command fails also when passed to VDatabase_SqlExecute.

I have attached a zip file containing the schema snapshot and the log.

Again, the code that I am using to execute these commands is:


open file tFullPath for read
read from file tFullPath until EOF
put it into tSql
close file tFullPath
get VDatabase_SqlExecute(sSystemDB, tSql)
Anhänge
Kommentar
There are no comments made yet.
Sergey Pashkov Akzeptierte Antwort
Hello Scott,

Did you try to create the dump instead of snapshot?

And there is VDatabase_LoadDump function for loading it back.
That’s the usual way.
Kommentar
There are no comments made yet.
Scott Roberts Akzeptierte Antwort
The dump method worked fine. I'll use that from now on.

Thanks.
Kommentar
There are no comments made yet.
Ivan Smahin Akzeptierte Antwort
My guess is - you do first:


SET PROPERTY "IOEncoding" OF DATABASE TO 'UTF-16';


After that vKernel expects every string passed to vKernel to be in UTF16 encoding.
Even SET PROPERTY "IOEncoding" OF DATABASE TO 'UTF8'; must be UTF16 encoded.
Kommentar
There are no comments made yet.
Ivan Smahin Akzeptierte Antwort
Please note that V4REV set UTF8 ioEncoding itslef in VDatabase_Constructor.
Kommentar
There are no comments made yet.
Ivan Smahin Akzeptierte Antwort
If you still want to play with IOEncoding - you should take a look at Examples/Common/IOEncoding
Kommentar
There are no comments made yet.
  • Seite :
  • 1


There are no replies made for this post yet.
However, you are not allowed to reply to this post.

Categories

Announcements & News
  1. 0 subcategories
Valentina Studio
  1. 2 subcategories
Valentina Server
  1. 4 subcategories
Valentina Database ADK
  1. 0 subcategories
Valentina Reports ADK
  1. 0 subcategories
Other Discussions
  1. 2 subcategories
BETA Testing
  1. 0 subcategories
Education & Research
  1. 0 subcategories