[sqlite] sqlite.dll

2015-09-03 Thread Simon Slavin

On 3 Sep 2015, at 4:29pm, H?ctor Fiandor  wrote:

> I am using Lazarus and tables sqlite in an Application. It works fine.

You're talking about the free version of the Pascal programming language ?  I'm 
afraid that we don't know how it calls SQLite so we don't know what the problem 
is.  From the error message you quote, the problem is not inside SQLite, it in 
the program which is trying to use it.

Could you contact someone who knows about Lazarus ?  Perhaps the person who 
installed it on that computer, or the person who is tell you to use it.

Simon.


[sqlite] Variables in statements

2015-09-03 Thread Peter Haworth
I use a high level language to write my db applications (Livecode).  It
permits the use of replacement opertaors in sql statements, e.g. "SELECT *
FROM myTable WHERE myKey=:1".  I guess that's a standard way of doing
things in SQLite.

I'm having some issues with this and not sure whether it's a SQLite or
Livecode problem.

The statement I'm using is:

SELECT * FROM myTable WHERE myKey IN (:1)

If the value I supply to be used as :1 is a single integer, the SELECT
finds the correct rows.  If the value is a comma separated list of
integers, e.g 1,2 the SELECT statement does not return any rows and no
error is returned.  If I recode the SELECT to specify 1,2 instead of :1,
the correct rows are returned.

Should the :1 form work when a list is supplied as its value?

Similarly with a statement like this.

SELECT * FROM myTable WHERE myText LIKE :1

I've tried various ways of implementing that with the following LIKE clause
and :1 values:

LIKE :1 - '%abc%'
LIKE :1 - %abc%
LIKE ':1' - %abc%
LIKE '%:1%' - abc

None of the above return any rows, but if I issue:

SELECT * FROM myTable WHERE myText LIKE '%abc%'

... the correct rows are returned.

I suspect this is a Livecode problem but wanted to check if what I am
trying to do is syntactically correct before reporting it as a bug.

Thanks


[sqlite] Query

2015-09-03 Thread Kees Nuyt
On Thu, 3 Sep 2015 15:03:27 +0530, manash b
 wrote:

>Hello,
>
>
>I am using SQLite version 3.8.11.1 and PHP for my web application.
>
>Table *employee* has 4 columns. Last two columns have default NULL values.
>
>Insert query -
>
>
>
>*INSERT INTO employee SELECT 3 AS 'eid','manash' AS 'name'
>   UNION SELECT 2,'ram'UNION** SELECT 1,'rahim'*
>
>
>Getting error -
>
>["SQLSTATE[HY000]: General error: 1 table employee has 4 columns but 2
>values were supplied
>
>
>How can i handle this? Please let me know.

I think you are looking for:

INSERT INTO employee (eid,name) 
VALUES (3,'manash'),(2.'ram'),(1,'rahim');

http://www.sqlite.org/lang_insert.html

-- 
Regards,

Kees Nuyt



[sqlite] Query

2015-09-03 Thread manash b
Hello,


I am using SQLite version 3.8.11.1 and PHP for my web application.

Table *employee* has 4 columns. Last two columns have default NULL values.

Insert query -



*INSERT INTO employee SELECT 3 AS 'eid','manash' AS 'name'
   UNION SELECT 2,'ram'UNION** SELECT 1,'rahim'*


Getting error -

["SQLSTATE[HY000]: General error: 1 table employee has 4 columns but 2
values were supplied


How can i handle this? Please let me know.



Thanks,


[sqlite] Using |DataDirectory| in connection string (.NET with System.Data.SQLite)

2015-09-03 Thread Lee Gray
Hello, I'm just starting to experiment with sqlite and System.Data.SQLite. How 
do they make use of the connection string |DataDirectory| macro? I've found 
lots of references online showing that it is indeed used, but I haven't found 
how to extract the file path from it at runtime.

Given a connection string such as "Data 
Source=|DataDirectory|TestDatabase.sqlite;", I want to be able to create the 
database file if it does not exist, and I want to extract that path from the 
connection string.

In SQL CE, I could do this:

public string GetSqlCeDataSource()
{
var connectionString = 
ConfigurationManager.ConnectionStrings[ConnectionStringName];
var factory = DbProviderFactories.GetFactory(connectionString.ProviderName);

using (var connection = factory.CreateConnection())
{
if (connection == null)
{
throw new InvalidOperationException(String.Format(
"Failed to create connection for {0}", 
connectionString.ProviderName));
}

connection.ConnectionString = connectionString.ConnectionString;
return connection.Database;
}
}

But sqlite returns "main" as the database instead of the file name.

So I worked around it by using a ConnectionStringBuilder and parsing the macro 
myself, but is there a better way to do this?

Here's the workaround (null checks removed for simplicity):

public void EnsureDatabase()
{
var connectionStringSettings = 
ConfigurationManager.ConnectionStrings[ConnectionStringName];
var factory = 
DbProviderFactories.GetFactory(connectionStringSettings.ProviderName);
var builder = factory.CreateConnectionStringBuilder();
builder.ConnectionString = connectionStringSettings.ConnectionString;
var dataDirectory = 
AppDomain.CurrentDomain.GetData("DataDirectory").ToString();

string databaseFilePath = builder["Data 
Source"].ToString().Replace("|DataDirectory|", null);
databaseFilePath = Path.Combine(dataDirectory, databaseFilePath);

if (!Directory.Exists(dataDirectory))
{
Directory.CreateDirectory(dataDirectory);
}

if (!File.Exists(databaseFilePath))
{
   SQLiteConnection.CreateFile(databaseFilePath);
}
}

Thanks,
Lee


[sqlite] sqlite.dll

2015-09-03 Thread Héctor Fiandor
Dear members:

Thanks very much. I have decided to start again other application from cero,
and it is working well up to now.

I expect to finish the copy of the app and hope it will work fine.

Thanks again.


Ing. H?ctor Fiandor
hfiandor at ceniai.inf.cu



[sqlite] Variables in statements

2015-09-03 Thread Richard Hipp
On 9/3/15, Peter Haworth  wrote:
>
> SELECT * FROM myTable WHERE myKey IN (:1)
>
> If the value I supply to be used as :1 is a single integer, the SELECT
> finds the correct rows.  If the value is a comma separated list of
> integers, e.g 1,2 the SELECT statement does not return any rows and no
> error is returned.  If I recode the SELECT to specify 1,2 instead of :1,
> the correct rows are returned.
>
> Should the :1 form work when a list is supplied as its value?

No.  Variables only work for single values, not lists.


>
> Similarly with a statement like this.
>
> SELECT * FROM myTable WHERE myText LIKE :1
>
> I've tried various ways of implementing that with the following LIKE clause
> and :1 values:
>
> LIKE :1 - '%abc%'
> LIKE :1 - %abc%
> LIKE ':1' - %abc%
> LIKE '%:1%' - abc
>
> None of the above return any rows, but if I issue:
>
> SELECT * FROM myTable WHERE myText LIKE '%abc%'
>
> ... the correct rows are returned.
>
> I suspect this is a Livecode problem but wanted to check if what I am
> trying to do is syntactically correct before reporting it as a bug.
>

I concur.  This latter seems like a livecode problem.  Similar things
work in SQLite.  See
https://www.sqlite.org/src/artifact/0f0ee61?ln=295 for example.  The
example uses $like instead of :1, but they both work the same.

-- 
D. Richard Hipp
drh at sqlite.org


[sqlite] Magic number in sqlite source code

2015-09-03 Thread Domingo Alvarez Duarte
Hello !  

I was looking at this particular commit
https://www.sqlite.org/src/info/0ea6e5c9fc6b1dd1 then I realize the usage of
magic number through sqlite3 source code like the one bellow, it's not good
practice to avoid then ?  

Cheers !  

=  case PragTyp_STATS: {   static const char *azCol[] = { "table",
"index", "width", "height" };  Index *pIdx;  HashElem *i;  v =
sqlite3GetVdbe(pParse);pParse->nMem = 4; ///first appearance of
the a magic number (sizeof(azCol)/sizeof(char*)) 
sqlite3CodeVerifySchema(pParse, iDb); setAllColumnNames(v, 4, azCol);
 second appearance of a magic number described above 
for(i=sqliteHashFirst(>pSchema->tblHash); i; i=sqliteHashNext(i)){  
 Table *pTab = sqliteHashData(i);sqlite3VdbeAddOp4(v, OP_String8, 0,
1, 0, pTab->zName, 0);sqlite3VdbeAddOp2(v, OP_Null, 0, 2);   
sqlite3VdbeAddOp2(v, OP_Integer,
(int)sqlite3LogEstToInt(pTab->szTabRow), 3);sqlite3VdbeAddOp2(v,
OP_Integer,  

=


[sqlite] sqlite.dll

2015-09-03 Thread Héctor Fiandor
This is my first request to the list.



I am using Lazarus and tables sqlite in an Application. It works fine.



I don?t know what happens (sure I have clicked something) and now, when I
clicked over the .lpi file, don?t charge Lazarus and a message appears
asking for a file sqlite.dll. I don?t remember used this file in any
Application before.



I will appreciate any coments.



yours



Ing. H?ctor Fiandor

hfiandor at ceniai.inf.cu





[sqlite] Query

2015-09-03 Thread Igor Korot
Hi,

On Thu, Sep 3, 2015 at 5:33 AM, manash b  wrote:
> Hello,
>
>
> I am using SQLite version 3.8.11.1 and PHP for my web application.
>
> Table *employee* has 4 columns. Last two columns have default NULL values.
>
> Insert query -
>
>
>
> *INSERT INTO employee SELECT 3 AS 'eid','manash' AS 'name'
>UNION SELECT 2,'ram'UNION** SELECT 1,'rahim'*
>
>
> Getting error -
>
> ["SQLSTATE[HY000]: General error: 1 table employee has 4 columns but 2
> values were supplied
>
>
> How can i handle this? Please let me know.

Could you please post "CREATE TABLE employee" statement?

Thank you.

>
>
>
> Thanks,
> ___
> sqlite-users mailing list
> sqlite-users at mailinglists.sqlite.org
> http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users


[sqlite] Magic number in sqlite source code

2015-09-03 Thread Scott Robison
On Sep 3, 2015 4:17 AM, "Domingo Alvarez Duarte" 
wrote:
>
> Hello !
>
> I was looking at this particular commit
> https://www.sqlite.org/src/info/0ea6e5c9fc6b1dd1 then I realize the usage
of
> magic number through sqlite3 source code like the one bellow, it's not
good
> practice to avoid then ?

Generally yes, but like most decisions made in programming, there are
exceptions. Much like goto: avoid it when nothing better is available, but
use it when it is the right tool.

Besides, I have seen code that is harder to read when certain magic numbers
are replaced by named constants. It isn't common, but it happens.

>
> Cheers !
>
> =  case PragTyp_STATS: {   static const char *azCol[] = { "table",
> "index", "width", "height" };  Index *pIdx;  HashElem *i;  v =
> sqlite3GetVdbe(pParse);pParse->nMem = 4; ///first appearance
of
> the a magic number (sizeof(azCol)/sizeof(char*))
> sqlite3CodeVerifySchema(pParse, iDb); setAllColumnNames(v, 4, azCol);
>  second appearance of a magic number described above
> for(i=sqliteHashFirst(>pSchema->tblHash); i; i=sqliteHashNext(i)){
>  Table *pTab = sqliteHashData(i);sqlite3VdbeAddOp4(v, OP_String8,
0,
> 1, 0, pTab->zName, 0);sqlite3VdbeAddOp2(v, OP_Null, 0, 2);
> sqlite3VdbeAddOp2(v, OP_Integer,
> (int)sqlite3LogEstToInt(pTab->szTabRow), 3);sqlite3VdbeAddOp2(v,
> OP_Integer,
>
> =
> ___
> sqlite-users mailing list
> sqlite-users at mailinglists.sqlite.org
> http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users