NO

Author Topic: Pelles C & SQLite  (Read 299 times)

Offline Jokaste

  • Member
  • *
  • Posts: 145
  • Never be pleased, always improve.
    • ImgTools
Pelles C & SQLite
« on: July 01, 2018, 03:25:09 pm »
I would like to create a variable like this :
Code: [Select]
char   szSqlCreateChloe[]   =
DROP TABLE IF EXISTS [Stars];
CREATE TABLE [Stars](
[RecNum] INTEGER,
[StarNum] INTEGER,
[full_name] CHAR(29),
[spkid] INTEGER,
[Category] INTEGER);
DELETE FROM [Stars];
INSERT INTO [Stars]([RecNum],[StarNum],[full_name],[spkid],[Category]) VALUES(1,388282,'`Akepa (2006 RC118)',2388282,0);
INSERT INTO [Stars]([RecNum],[StarNum],[full_name],[spkid],[Category]) VALUES(2,378002,'`Akialoa (2006 RK112)',2378002,0);
.
.
.
INSERT INTO [Stars]([RecNum],[StarNum],[full_name],[spkid],[Category]) VALUES(21346,4879,'Zykina (1974 VG)',2004879,0);
INSERT INTO [Stars]([RecNum],[StarNum],[full_name],[spkid],[Category]) VALUES(21347,2098,'Zyskin (1972 QE)',2002098,0);
INSERT INTO [Stars]([RecNum],[StarNum],[full_name],[spkid],[Category]) VALUES(21348,22521,'ZZ Top (1998 ER2)',2022521,0);

But the compiler tells me the string is too long, just 2.61 Mb!

If I can't do it in C, I think that in asm I would not have any problem but that's not what I want.
« Last Edit: July 01, 2018, 03:26:42 pm by Jokaste »
Kenavo

Offline TimoVJL

  • Global Moderator
  • Member
  • *****
  • Posts: 1742
Re: Pelles C & SQLite
« Reply #1 on: July 01, 2018, 06:42:30 pm »
Is it just more efficient way to use array of values and use loop?
Code: [Select]
char szBuf[260];
strcpy(szBuf, "INSERT INTO [Stars]([RecNum],[StarNum],[full_name],[spkid],[Category]) VALUES(");
for (int i=1; i<=21348; i++) {
int len=sprintf(szBuf+78, "%u,%u,'%s',%u,0);",Rec[i].nRec,Rec[i].nStar,Rec[i].szName,Rec[i].nSkpId);
...
}

EDIT:
Code: [Select]
Characters in a string literal (after concatenation) [65 536].
ISO/IEC 9899:201x Committee Draft — April 12, 2011 N1570:
Quote
4095 characters in a logical source line
4095 characters in a string literal (after concatenation)
65535 bytes in an object (in a hosted environment only)
WG14/N1124 Committee Draft — May 6, 2005 ISO/IEC 9899:TC2:
Quote
4095 characters in a character string literal or wide string literal (after concatenation)
« Last Edit: July 02, 2018, 11:49:37 am by TimoVJL »
May the source be with you