Re: [sqlite] INSERT INTO and Hexadecimal Literals
Igor Tandetnik wrote: > No, there's no syntax for integral hexadecimal literals. There is a blob > literal x'B4', but it doesn't behave like a number (e.g. you can't > do arithmetic on blobs). Bottom line, the only option is to use plain > vanilla decimal numbers. > Thanks for the response, Igor. That tells me what I need. Regards, Ben > Ben Atkinson wrote: > > Sorry for the newbie SQL question. I'm trying to use the INSERT INTO > > statement with a hexadecimal literal. I want to accomplish something > > like this: > > > > INSERT INTO TruckDefaultsTable VALUES ( 'AirPressureTime', 0, > > 0xB4); > > > > Does SQL have a hex literal sequence that serves the same role as > > "0x" in C? > > No, there's no syntax for integral hexadecimal literals. There is a blob > literal x'B4', but it doesn't behave like a number (e.g. you can't > do arithmetic on blobs). Bottom line, the only option is to use plain > vanilla decimal numbers. > > > I could express the value in decimal as 11796480, but that's pretty > > awkward since the actual value I'm putting into the table is a Linux > > timeval structure. It just makes more sense as hex. > > How come you need to type these timestamps in by hand? When you work > with SQLite programmatically, you just use int variables and such - > there's almost never a need to represent the number as string, whether > decimal or hex. > > Igor Tandetnik > ___ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
Re: [sqlite] INSERT INTO and Hexadecimal Literals
Ben Atkinsonwrote: > Sorry for the newbie SQL question. I'm trying to use the INSERT INTO > statement with a hexadecimal literal. I want to accomplish something > like this: > > INSERT INTO TruckDefaultsTable VALUES ( 'AirPressureTime', 0, > 0xB4); > > Does SQL have a hex literal sequence that serves the same role as > "0x" in C? No, there's no syntax for integral hexadecimal literals. There is a blob literal x'B4', but it doesn't behave like a number (e.g. you can't do arithmetic on blobs). Bottom line, the only option is to use plain vanilla decimal numbers. > I could express the value in decimal as 11796480, but that's pretty > awkward since the actual value I'm putting into the table is a Linux > timeval structure. It just makes more sense as hex. How come you need to type these timestamps in by hand? When you work with SQLite programmatically, you just use int variables and such - there's almost never a need to represent the number as string, whether decimal or hex. Igor Tandetnik ___ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
Re: [sqlite] INSERT INTO and Hexadecimal Literals
Erg, I can almost count. Sorry, the correct way to specify a hex literal is in that thread too. If you use x'' you can enter the bits. Thank you, Clay On Wed, 1 Jul 2009, Clay Baenziger wrote: > Hi Ben, > I hit this a few months ago. Hex literals have to contain an even > number of hex digits. For that discussion, see: > http://www.nabble.com/Hexadecimal-Inequalities-Failing--td20216982.html > > Thank you, > Clay > > On Wed, 1 Jul 2009, Ben Atkinson wrote: > >> >> Sorry for the newbie SQL question. I'm trying to use the INSERT INTO >> statement with a hexadecimal literal. I want to accomplish something >> like this: >> >> INSERT INTO TruckDefaultsTable VALUES ( 'AirPressureTime', 0, 0xB4); >> >> sqlite chokes on the 0xB4 expression with: >> unrecognized token: "0xB4" >> >> I could express the value in decimal as 11796480, but that's pretty awkward >> since the actual value I'm putting into the table is a Linux timeval >> structure. >> It just makes more sense as hex. >> >> Does SQL have a hex literal sequence that serves the same role as "0x" in C? >> >> Thanks for any help. >> >> Ben >> >> >> >> ___ >> sqlite-users mailing list >> sqlite-users@sqlite.org >> http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users >> > ___ > sqlite-users mailing list > sqlite-users@sqlite.org > http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users > ___ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
Re: [sqlite] INSERT INTO and Hexadecimal Literals
Hi Ben, I hit this a few months ago. Hex literals have to contain an even number of hex digits. For that discussion, see: http://www.nabble.com/Hexadecimal-Inequalities-Failing--td20216982.html Thank you, Clay On Wed, 1 Jul 2009, Ben Atkinson wrote: > > Sorry for the newbie SQL question. I'm trying to use the INSERT INTO > statement with a hexadecimal literal. I want to accomplish something > like this: > > INSERT INTO TruckDefaultsTable VALUES ( 'AirPressureTime', 0, 0xB4); > > sqlite chokes on the 0xB4 expression with: > unrecognized token: "0xB4" > > I could express the value in decimal as 11796480, but that's pretty awkward > since the actual value I'm putting into the table is a Linux timeval > structure. > It just makes more sense as hex. > > Does SQL have a hex literal sequence that serves the same role as "0x" in C? > > Thanks for any help. > > Ben > > > > ___ > sqlite-users mailing list > sqlite-users@sqlite.org > http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users > ___ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
[sqlite] INSERT INTO and Hexadecimal Literals
Sorry for the newbie SQL question. I'm trying to use the INSERT INTO statement with a hexadecimal literal. I want to accomplish something like this: INSERT INTO TruckDefaultsTable VALUES ( 'AirPressureTime', 0, 0xB4); sqlite chokes on the 0xB4 expression with: unrecognized token: "0xB4" I could express the value in decimal as 11796480, but that's pretty awkward since the actual value I'm putting into the table is a Linux timeval structure. It just makes more sense as hex. Does SQL have a hex literal sequence that serves the same role as "0x" in C? Thanks for any help. Ben ___ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users