Re: [sqlite] SQL statement and C++

2017-09-01 Thread Simon Slavin


On 1 Sep 2017, at 9:50pm, Simon Slavin  wrote:

> you appear to be trying to execute a command with the database name in, 
> something like
> 
>> "F:\\Temp\\test_database.jdb "VACUUM"

I’ve just realised what’s going on.  OP has confused the sqlite3 shell tool 
with what it’s like to use the SQLite API.  The above extract looks like 
something you might issue to a shell to use the shell tool (which is designed 
as an interactive exploration aid) as a scripting tool.

Papa, please take a look at this page:



and use the example at the end of the page as a starting point.  Then you might 
move on to this page:



Simon.
___
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] SQL statement and C++

2017-09-01 Thread Jens Alfke


> On Sep 1, 2017, at 1:47 PM, Papa  wrote:
> 
> Yes, right after opening the database, I want o perform a vacuuming so that 
> the new tables can be created, writing and/or read.

I don't know how to put this politely, but you seem to be making things up out 
of thin air. There's nothing anywhere that says you need to run VACUUM to run 
any other command. And there are no SQL commands that take the path to the 
database.

Instead of making things up, try the `sqlite3` command-line tool. Run some SQL 
commands in that tool's interactive mode and get a feel for how SQL works. Then 
when you have working commands, you can bring them into your own program.

—Jens
___
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] SQL statement and C++

2017-09-01 Thread Keith Medcalf

And look at the oh so usefully provided return code from the prepare call ... 
there is NO POINT WHATSOEVER in looking at the statement pointer if the return 
code does not indicate that the prepare prepared anything.  So if the 
returncode is ANYTHING OTHER THAN SQLITE_OK then you should be expecting the 
statement pointer to be null.


---
The fact that there's a Highway to Hell but only a Stairway to Heaven says a 
lot about anticipated traffic volume.


>-Original Message-
>From: sqlite-users [mailto:sqlite-users-
>boun...@mailinglists.sqlite.org] On Behalf Of Jens Alfke
>Sent: Friday, 1 September, 2017 12:46
>To: SQLite mailing list
>Subject: Re: [sqlite] SQL statement and C++
>
>
>
>> On Sep 1, 2017, at 11:23 AM, Papa  wrote:
>>
>> I get an error indicating that binary_sql_statement evaluates to
>NULL.
>
>Most often that means there's a syntax error in the SQL statement.
>You should call sqlite3_errcode() to get the error code, and
>sqlite3_errmsg() to get an error message.
>
>—Jens
>___
>sqlite-users mailing list
>sqlite-users@mailinglists.sqlite.org
>http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users



___
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] SQL statement and C++

2017-09-01 Thread Simon Slavin


On 1 Sep 2017, at 9:47pm, Papa  wrote:

> Yes, right after opening the database, I want o perform a vacuuming so that 
> the new tables can be created, writing and/or read.

You do not need to execute VACUUM to use new tables.  In fact the command will 
cause a long delay for no useful result, since you are immediately fragmenting 
the database again by changing it.  Just proceed without the VACUUM.

Simon.
___
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] SQL statement and C++

2017-09-01 Thread Simon Slavin


On 1 Sep 2017, at 9:24pm, Papa  wrote:

>   database_name = "F:\\Temp\\test_database.jdb";

and later

>sql_statement_request = database_name + L" \"VACUUM; \" ";
>// Compiled the SQL statement into a byte-code
>rc = sqlite3_prepare_v2(db,
>sql_statement_request.data(),
>-1,
>&binary_sql_statement,
>NULL);


you appear to be trying to execute a command with the database name in, 
something like

> "F:\\Temp\\test_database.jdb "VACUUM"

Why are you trying to execute a command with the database name in ?  The 
command you want is just VACUUM.  You don’t need any quotes around it and you 
don’t need the database name as part of the command.

Simon.
___
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] SQL statement and C++

2017-09-01 Thread Papa
Yes, right after opening the database, I want o perform a vacuuming so 
that the new tables can be created, writing and/or read.



On 2017-09-01 4:31 PM, Igor Korot wrote:

Hi,
What are you trying to achieve?
Are you trying to perform a "VACUUM" command on the data base?

Thank you.


On Sep 1, 2017 2:23 PM, "Papa"  wrote:

In this snip, I'd like to show a brief description of what the class member
function should do, in order to ask you if the SQL statement has been
properly prepared.
 sqlite3* db; //!< Data Base
 std::string database_name; //!< The name of the database
 std::string sql_statement_request; //!< Formated SQL request
 sqlite3_stmt* binary_sql_statement; //!< SQL binary statement

 ..
 assign values to the above strings
 ..
 open the database
 .

 sql_statement_request = database_name + L" \"VACUUM; \" ";
 // Compiled the SQL statement into a byte-code
 rc = sqlite3_prepare_v2(db,
 sql_statement_request.data(),
 -1,
 &binary_sql_statement,
 NULL);

I get an error indicating that binary_sql_statement evaluates to NULL.
I being a SQL with C++ newbie, I'd like to ask much patience from you.
Thanks



--
ArbolOne.ca
Using Fire Fox and Thunderbird.
ArbolOne is composed of students and volunteers dedicated to providing free 
services to charitable organizations.
ArbolOne on Java Development in progress [ í ]

___
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] SQL statement and C++

2017-09-01 Thread Igor Korot
Hi,
What are you trying to achieve?
Are you trying to perform a "VACUUM" command on the data base?

Thank you.


On Sep 1, 2017 2:23 PM, "Papa"  wrote:

In this snip, I'd like to show a brief description of what the class member
function should do, in order to ask you if the SQL statement has been
properly prepared.
sqlite3* db; //!< Data Base
std::string database_name; //!< The name of the database
std::string sql_statement_request; //!< Formated SQL request
sqlite3_stmt* binary_sql_statement; //!< SQL binary statement

..
assign values to the above strings
..
open the database
.

sql_statement_request = database_name + L" \"VACUUM; \" ";
// Compiled the SQL statement into a byte-code
rc = sqlite3_prepare_v2(db,
sql_statement_request.data(),
-1,
&binary_sql_statement,
NULL);

I get an error indicating that binary_sql_statement evaluates to NULL.
I being a SQL with C++ newbie, I'd like to ask much patience from you.
Thanks

-- 
ArbolOne.ca
Using Fire Fox and Thunderbird.
ArbolOne is composed of students and volunteers dedicated to providing free
services to charitable organizations.
ArbolOne on Java Development in progress [ í ]

___
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
___
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] SQL statement and C++

2017-09-01 Thread Papa

Thanks for your suggestion Jens, I tried it and this is what they report.
---
DEBUGING
---
sqlite3_extended_errcode == 1
 sqlite3_errcode ==  1
 sqlite3_errmsg == near "F": syntax error

---
OK
---

What puzzles me is the report from sqlite3_errmsg, the only thing I can 
relate this value F is the directory where the database is being 
created, 'F:\Temp' i.e.

std::string database_name;
database_name = "F:\\Temp\\test_database.jdb";
rc = sqlite3_open_v2(
    database_name.c_str(), //Database name
    &db, //Database object
    SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE, //
    NULL
    );
On 2017-09-01 2:45 PM, Jens Alfke wrote:



On Sep 1, 2017, at 11:23 AM, Papa  wrote:

I get an error indicating that binary_sql_statement evaluates to NULL.

Most often that means there's a syntax error in the SQL statement.
You should call sqlite3_errcode() to get the error code, and sqlite3_errmsg() 
to get an error message.

—Jens
___
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users


--
ArbolOne.ca
Using Fire Fox and Thunderbird.
ArbolOne is composed of students and volunteers dedicated to providing free 
services to charitable organizations.
ArbolOne on Java Development in progress [ í ]

___
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] SQL statement and C++

2017-09-01 Thread Jens Alfke


> On Sep 1, 2017, at 11:23 AM, Papa  wrote:
> 
> I get an error indicating that binary_sql_statement evaluates to NULL.

Most often that means there's a syntax error in the SQL statement.
You should call sqlite3_errcode() to get the error code, and sqlite3_errmsg() 
to get an error message.

—Jens
___
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users


[sqlite] SQL statement and C++

2017-09-01 Thread Papa
In this snip, I'd like to show a brief description of what the class 
member function should do, in order to ask you if the SQL statement has 
been properly prepared.

    sqlite3* db; //!< Data Base
    std::string database_name; //!< The name of the database
    std::string sql_statement_request; //!< Formated SQL request
    sqlite3_stmt* binary_sql_statement; //!< SQL binary statement

    ..
    assign values to the above strings
    ..
    open the database
    .

    sql_statement_request = database_name + L" \"VACUUM; \" ";
    // Compiled the SQL statement into a byte-code
    rc = sqlite3_prepare_v2(db,
    sql_statement_request.data(),
    -1,
    &binary_sql_statement,
    NULL);

I get an error indicating that binary_sql_statement evaluates to NULL.
I being a SQL with C++ newbie, I'd like to ask much patience from you.
Thanks

--
ArbolOne.ca
Using Fire Fox and Thunderbird.
ArbolOne is composed of students and volunteers dedicated to providing free 
services to charitable organizations.
ArbolOne on Java Development in progress [ í ]

___
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users