I built in some general sql functions to [[TkSQLite]] ver0.4.~
Here is the list of the functions. You can blild in these functions to 
your database freely. NOTE: This is under developed, so these may be changed. 


*** How to build in the functions to your db [#eaf68944]
 package require sqlite3
 source sqlitefunc.tcl
 sqlite db :memory:
 Sqlite::func::install db

then

 % db eval {SELECT MD5('md5 test')}
 2E5F9458BCD27E3C2B5908AF0B91551A


*** Download [#n5ef0eb9]
http://reddog.s35.xrea.com/software/sqlitefunc0.4.zip
http://reddog.s35.xrea.com/software/sqlitefunc0.5.zip


***String Format Functions [#fa4b0f08]
|ascii(char)                 |return ascii code                                                  |
|char(code)                  |return char from ascii code                                        |
|concat(arg ?, arg ...?)     |join args                                                          |
|concat_ws(sep, arg ?, arg?) |join args with sep                                                 |
|convert(str, from, to)      |encoding converter. from and to must be tcl's encoding name.       |
|elt(n, arg ?, arg ...?)     |MySQL's elt.                                                       |
|hex(n)                      |return hex value.                                                  |
|initcap(str)                |Oracle's initcap.                                                  |
|insert(s, pos, len, ns)     |                                                                   |
|instr(str, sstr, ?st ?n??)  |search sstr in str.                                                |
|length(str)                 |SQLite Built-in                                                    |
|locate(sstr, str, pos)      |return first sstr position in str. start from pos.                 |
|lower(str)                  |SQLite Built-in                                                    |
|lpad(str, len ?, pad?)      |                                                                   |
|ltrim(str ?, chars?)        |trimleft chars(or space) from str.                                 |
|mid(str, pos, len)          |                                                                   |
|position(sstr, IN, str)     |return first sstr position in str.                                 |
|repeat(str, n)              |                                                                   |
|replace(str, from, to)      |replace from to to.                                                |
|reverse(str)                |reverse string.                                                    |
|rpad(str, n ?, pad?)        |                                                                   |
|rtrim(str ?, chars?)        |trimright chars(or space) from str.                                |
|space(n)                    |return space.                                                      |
|to_char(num, fmt)           |Support only B,FM,S,G,D,",",9,0. Only number format. If you want to format datetime, use some sqlite built-in functions like strftime or datetime. |
|translate(str, from, to)    |PostgreSQL's translate.                                            |
|trim(str ?, chars?)         |This is not SQL99 trim. trim chars(or space) from str.             |


*** Math Functions [#o12e785e]
 acos                    exp                 radians                    
 asin                    floor               rand                       
 atan                    greatest            random(SQLite Built-in)    
 atan2                   least               round(SQLite Built-in)     
 avg(SQLite Built-in)    log                 sign                       
 ceil                    log10               sin                        
 cos                     mod                 sqrt                       
 cot                     pi                  tan                        
 degrees                 pow                 trunc                      


*** Date Time [#fe31d122]
|now()      |return localtime. same as datetime('now', 'localtime') |
|julianday  |SQLite Built-in                                        |
|datetime   |SQLite Built-in                                        |
|date       |SQLite Built-in                                        |
|strftime   |SQLite Built-in                                        |


*** Other Functions [#y6a88a8e]
|min               |SQLite Built-in |
|max               |SQLite Built-in |
|coalesce          |SQLite Built-in |
|nullif            |SQLite Built-in |
|ifnull            |SQLite Built-in |
|last_insert_rowid |SQLite Built-in |
|quote             |SQLite Built-in |
|regexp            |                |
|regsub            |                |
|user              |return user name |


*** Crypt, Hash, etc [#ed5062cd]
NOTE: requires Tcllib and Trf
|md5(data ?, binary?)                   |MD5                         |
|md5_hmac(key, data ?, binary?)         |HMAC-MD5                    |
|md5_crypt(pass, salt ?, binary?)       |BSD compatible MD5 crypt    |
|apr_crypt(pass, salt ?, binary?)       |Apache compatible MD5 crypt |
|sha1(data ?, binary?)                  |SHA1                        |
|sha1_hmac(key, data ?, binary?)        |HMAC-SHA1                   |
|aes_encrypt(key, data ?, binary?)      |ASE encryption              |
|aes_decrypt(key, data ?, binary?)      |ASE decryption              |
|blowfish_encrypt(key, data ?, binary?) |Blowfish encryption         |
|blowfish_decrypt(key, data ?, binary?) |Blowfish decryption         |
|des_encrypt(key, data ?, binary?)      |DES encryption              |
|des_decrypt(key, data ?, binary?)      |DES decryption              |
|base64_encode(data ?, binary?)         |Base64 encode               |
|base64_decode(data ?, binary?)         |Base64 decode               |
|compress(data ?, binary?)              |compress data by zip        |
|decompress(data ?, binary?)            |decompress data by zip      |
|uuid()                                 |UUID                        |
|exec(string)                           |execute command and return result |
the ''binary'' option must set 1 for the BLOB data. default is 0.
if ''binary'' is omitted (binary = 0), data is handled as text.
''key'' is handled as text even if ''binary'' is 1.


*** File IO [#m7e679f6]
|write_file(path, data ?,binary?)      |Base64 decode               |
|read_file(path ?,binary?)             |Base64 encode               |
''path'' is file path.~
the ''binary'' option must set 1 for the BLOB data. default is 0.
if ''binary'' is omitted (binary = 0), data is handled as text.


*** One Line Comment [#h4c6dd90]
-select MD5('ala') --  2005-12-16 08:16:51
-broken link: http://reddog.s35.xrea.com/software/sqlitefunc.zip -- Giorgio 2006-03-16 22:29:29
-I fixed it. thanks. -- reddog 2006-03-17 01:23:19
- I'm on holiday http://graceibc.org/revatio-how-supplied/ generic revatio for ed  Campbell’s Soup Company is recalling 1,920 cans of SpaghettiOs with Meatballs because the product contains wheat, soy, and milk, which are three of the major food allergens, that are not declared on the label.  -- Salvatore &new{2015-05-09 (Sat) 22:28:06};
- Free medical insurance http://www.drijendesigns.co.uk/avanafil-scheda-tecnica/ estimation of avanafil by uv  BEIJING/HONG KONG - China reiterated its opposition on Thursday to a European Union plan to limit airline carbon dioxide emissions and called for talks to resolve the issue a day after its major airlines refused to pay any carbon costs under the new law.  -- Roger &new{2015-05-09 (Sat) 22:28:14};
- Sorry, I'm busy at the moment https://ummgc.org/vicerex-mercadolibre vicerex dove si compra  “The last thing that we want is him getting hurt, and we don’t need people coming here and trying to watch the bear – because he’s a big bear,” he said. “I bet he’s 400 pounds. I’m sure he could definitely hurt someone.”  -- Amber &new{2015-05-09 (Sat) 22:28:18};
- I'm training to be an engineer http://www.pizzaamorewoodfire.com/cheap-filagra-100-mg-pink.html filagra 100 dp  “To be absolutely clear, the Senate will reject both the one-year delay of the Affordable Care Act and the repeal of the medical device tax," Reid said. "After weeks of futile political games from Republicans, we are still at square one."  -- Richie &new{2015-05-09 (Sat) 22:28:20};
- I'm originally from Dublin but now live in Edinburgh http://anestasiavodka.com/blog/vegah-extra-cobra-cost/ vegah extra cobra 120 nedir  "We are far too soft, our bodies would not be able to cope with the cold winters, no central heating, the growing of food, health and the lack of hygiene, the feudal system - you and I would be near the bottom - wars, crime and on and on.  -- Brandon &new{2015-05-09 (Sat) 22:28:22};
- Your account's overdrawn http://www.sniderscyclery.com/?vitaros-phase-iv.pdf vitaros cream online  These sound like trumped up charges, and if the ship had medical supplies as one would think they would, one might find drugs. When one is injured that is what is given to get rid of pain. AND I do believe that Green peace was trying to get more press for their cause. This is one of the forms they raise funds, via controversy. If things where so bad that Green Peace had to run up there, why is the U.S. government so quite.  -- Danial &new{2015-05-09 (Sat) 22:28:25};
- I'm retired http://www.townofcaroline.org/tadalista-informacion/ cheapest tadalista  Davis hit .165 in the first half, a stretch that included a monthlong demotion to Triple-A Las Vegas. Since returning to the majors, he owns a .192 average (5 for 26). With Josh Satin producing and Lucas Duda eventually coming off the disabled list, Davis needs to start hitting.  -- Collin &new{2015-05-09 (Sat) 22:28:28};
- What sort of music do you like? http://graceibc.org/revatio-how-supplied/ revatio generic drug  The house at 807 Barrow Street was demolished Thursday as previously planned. It was owned by Covenant House Alaska and used by a contractor overseeing the construction of its new shelter nearby. Police say they signed off on the demolition. Covenant House plans to build a parking lot for staff on the lot.  -- Jacques &new{2015-05-09 (Sat) 22:28:30};
- I'm a member of a gym http://graceibc.org/revatio-how-supplied/ pvl revatio  According to Medicare.gov, the government's official website, Medicare Part A generally covers most of the bills associated with that type of a hospital stay, including a semi-private room and medical procedures. But it doesn't cover incidentals like hospital-room TV or phone service, which can run as high as $50 per day.  -- Geraldo &new{2015-05-09 (Sat) 22:28:33};
- I work for myself http://www.sniderscyclery.com/?vitaros-phase-iv.pdf vitaros directions  He added that improvements in more forward-looking data, such as new buyer inquiries in the Royal Institution of Chartered Surveyors housing market survey or the main measures of consumer confidence, suggest that further rises in approvals "probably lie ahead".  -- Shaun &new{2015-05-09 (Sat) 22:28:39};
- I'm at Liverpool University http://www.davehebb.com/vistagra-50.pdf vistagra 100 dosage  The latter was sung here with sweeping panache and intense musicality by the impressive French-Canadian soprano Alexandra Deshorties. Her steely soprano turns glassily strident when the pressure increases at the top of her range, but she nails every last note and keeps the line tautly expressive throughout: she calls to mind Renata Scotto (a great compliment in my book), and I can imagine her as a fine Norma.  -- Eric &new{2015-05-10 (Sun) 03:43:02};
- I've only just arrived http://www.davehebb.com/vistagra-50.pdf how to use vistagra  To get off the ground, Minerva raised $25 million from Benchmark, a top Silicon Valley venture-capital firm, last year. But eventually, Minerva hopes tuition plus fees for room and board will move the for-profit institution into the black.  -- Antonia &new{2015-05-10 (Sun) 03:43:10};
- Your cash is being counted http://www.uberdorkcafe.com/review-zenerx-male-enhancement.pdf opiniones de zenerx  China's Ministry of Public Security also declined tocomment. The State Council's Development Research Centre, one ofthe groups reportedly involved, told Reuters they were notcarrying out such an investigation.  -- Bradly &new{2015-05-10 (Sun) 03:43:13};
- A packet of envelopes http://mobilewebghana.org/malegra-100-sunrise.pdf achat malegra  Gilead has filed for U.S. approval of its own hepatitis Cregimen and the FDA is slated to decide on the application byDec. 8. Its experimental drug sofosbuvir will be discussed at anFDA advisory committee meeting on Oct. 25.  -- Willard &new{2015-05-10 (Sun) 03:43:15};
- I'm on holiday http://rentamom.com/how-to-use-zeagra-long-stay-gel/ buy zeagra  “Following JCP’s 3Q business update, our impression is that merchandising issues that have bedeviled JCP for the last 18 months continue to do so,” Credit Suisse said in a note. “This continues to be a very tough situation as it plays out, as sales trends remain challenging.” Credit Suisse noted that while sales trends have shown some improvement, gross margins are not showing a sign of improving or even stabilizing in the near term. “Margins appear to be under more pressure than we expected so far this quarter,” Credit Suisse said.  -- Robin &new{2015-05-10 (Sun) 03:43:18};
- The line's engaged http://www.samhardenburgh.com/fidena-mg.pdf order fidena  Basle in contrast were dangerous on the break but they will be forced to come out more after the break in search of an equaliser. This in turn will play into Mourinho’s hands, allowing his team to operate on the counter-attack.  -- Keven &new{2015-05-10 (Sun) 03:43:20};
- My battery's about to run out http://www.davehebb.com/vistagra-50.pdf vistagra review  “My view is in one quarter we will see some recovery. The speed of government spending will increase in the next six months time,” said Deepak Ladha, executive director at Ladderup Corporate Advisory.  -- Wesley &new{2015-05-10 (Sun) 03:43:24};
- What sort of music do you like? http://www.fabulousfordsforever.org/index.php/purchase-vriligy vriligy review  I'm a Fellow at the Adam Smith Institute in London, a writer here and there on this and that and strangely, one of the global experts on the metal scandium, one of the rare earths. An odd thing to be but someone does have to be such and in this flavour of our universe I am. I have written for The Times, Daily Telegraph, Express, Independent, City AM, Wall Street Journal, Philadelphia Inquirer and online for the ASI, IEA, Social Affairs Unit, Spectator, The Guardian, The Register and Techcentralstation. I've also ghosted pieces for several UK politicians in many of the UK papers, including the Daily Sport.  -- Bryant &new{2015-05-10 (Sun) 03:43:25};
- Is this a temporary or permanent position? http://www.davehebb.com/vistagra-50.pdf vistagra review  In a securities filing, OSX said Batista's father, EliezerBatista da Silva, as well as former Energy Minister RodolphoTourinho Neto, Luiz do Amaral de França Pereira and Samir Zraickresigned from the board. The company gave no reason for thedepartures.  -- Humberto &new{2015-05-10 (Sun) 03:43:28};
- Please call back later http://buffalovisiongames.com/blog/tadadel-cialis/ tadadel erfahrung  And while it was announced that Kevin Alejandro would come on board as Sebastian Blood, while Michael Jai White will portray Bronze Tiger, the real buzz surrounded a sizzle reel that treated attendees to actual footage from this fall's new episodes.  -- Floyd &new{2015-05-10 (Sun) 03:43:30};
- I'm unemployed http://www.fitxpress.com/abra-100-side-effects/ abra price  PYONGYANG, North Korea - Two decorated U.S. war veterans who survived one of the worst battles of the Korean War found themselves among former foes at a memorial ceremony as North Korean leader Kim Jong Un launched the country's commemoration of the war's end 60 years ago.  -- Austin &new{2015-05-10 (Sun) 08:55:15};
- We've got a joint account http://www.fitxpress.com/abra-100-side-effects/ abra cost  In coming negotiations with Republicans, who control the House of Representatives, Democratic President Barack Obama will focus on ways to create economic gains for the middle class over spending cuts, Lew said.  -- Titus &new{2015-05-10 (Sun) 08:55:22};

#commente

----
[[CategoryTclTk]] [[TkSQLite]]
[[CategoryEnglish]]

|New|Edit|Diff|History|Attach|Copy|Rename|
HTML convert time: 0.002 sec.