7 Replies - 762 Views - Last Post: 14 February 2011 - 12:38 PM Rate Topic: -----

#1 Guest_Brad*


Reputation:

SQLite Help Required

Posted 14 February 2011 - 11:53 AM

I have a database with a fair number of words in a table.

I basically need a SQL statement which will replace each vowel (a,e,i,o,u) with the next vowel along alphabetically)

e.g.

Hello --> Hillu

Morning --> Murnong

Stubborn --> Stabburn


I looked up REPLACE and TRANSLATE however they do not seem to be available in SQLite. Any help guys, even if its just the actual function call I need. I could probably work the rest myself, but cannot find anything via google.

Is This A Good Question/Topic? 0

Replies To: SQLite Help Required

#2 JackOfAllTrades  Icon User is offline

  • Saucy!
  • member icon

Reputation: 6035
  • View blog
  • Posts: 23,418
  • Joined: 23-August 08

Re: SQLite Help Required

Posted 14 February 2011 - 12:16 PM

SQLite is not MS SQL, so I'll move this to the general DB forum.

Look under here.
Was This Post Helpful? 0
  • +
  • -

#3 Guest_Brad*


Reputation:

Re: SQLite Help Required

Posted 14 February 2011 - 12:25 PM

View PostJackOfAllTrades, on 14 February 2011 - 12:16 PM, said:

SQLite is not MS SQL, so I'll move this to the general DB forum.

Look under here.


Apologies.

I noticed there is a documented REPLACE function in there, however whenever I try using it, be it in SQLite DB Browser or my application as a commandText, it returns an error saying REPLACE is not a function. Any further help?
Was This Post Helpful? 0

#4 JackOfAllTrades  Icon User is offline

  • Saucy!
  • member icon

Reputation: 6035
  • View blog
  • Posts: 23,418
  • Joined: 23-August 08

Re: SQLite Help Required

Posted 14 February 2011 - 12:28 PM

What version of SQLite?
Was This Post Helpful? 0
  • +
  • -

#5 Guest_Guest*


Reputation:

Re: SQLite Help Required

Posted 14 February 2011 - 12:30 PM

View PostJackOfAllTrades, on 14 February 2011 - 12:28 PM, said:

What version of SQLite?


version 3.3.5 I believe.
Was This Post Helpful? 0

#6 JackOfAllTrades  Icon User is offline

  • Saucy!
  • member icon

Reputation: 6035
  • View blog
  • Posts: 23,418
  • Joined: 23-August 08

Re: SQLite Help Required

Posted 14 February 2011 - 12:35 PM

sqlite3
SQLite version 3.7.3
Enter ".help" for instructions
Enter SQL statements terminated with a ";"
sqlite> select replace('hello', 'e', 'i');
hillo
sqlite> 


Was This Post Helpful? 0
  • +
  • -

#7 baavgai  Icon User is offline

  • Dreaming Coder
  • member icon

Reputation: 5775
  • View blog
  • Posts: 12,587
  • Joined: 16-October 07

Re: SQLite Help Required

Posted 14 February 2011 - 12:37 PM

Well, databases aren't real into string manipulation. Particularly sqlite, where it's assumed you'll be calling from a middle tier that would be far more suited.

Still, in the interests of silliness, and proof of concept, this worked:
baavgai@DIC:~$ sqlite3 foo.db
SQLite version 3.6.22
Enter ".help" for instructions
Enter SQL statements terminated with a ";"
sqlite> create table foo(s text);
sqlite> 
sqlite> insert into foo values('Hello');
sqlite> insert into foo values('Morning');
sqlite> select * from foo;
Hello
Morning
sqlite> select s,
   ...> replace(replace(replace(replace(s,'o','u'),'i','o'),'e','i'),'a','e')
   ...> from foo;
Hello|Hillu
Morning|Murnong
sqlite>


Was This Post Helpful? 0
  • +
  • -

#8 Guest_Guest*


Reputation:

Re: SQLite Help Required

Posted 14 February 2011 - 12:38 PM

View PostJackOfAllTrades, on 14 February 2011 - 12:35 PM, said:

sqlite3
SQLite version 3.7.3
Enter ".help" for instructions
Enter SQL statements terminated with a ";"
sqlite> select replace('hello', 'e', 'i');
hillo
sqlite> 



Running the latest SQLite engine I can get that to work fine, however using the admin's current database does not seem to recognize REPLACE.

Oh well, i guess a bit of a more long winded method is in order then, thanks anyway dude!
Was This Post Helpful? 0

Page 1 of 1