Click here to Skip to main content
15,906,558 members
Home / Discussions / Database
   

Database

 
QuestionSQL Query Pin
theCPkid6-Jul-09 15:41
theCPkid6-Jul-09 15:41 
AnswerRe: SQL Query Pin
Niladri_Biswas6-Jul-09 16:05
Niladri_Biswas6-Jul-09 16:05 
AnswerRe: SQL Query Pin
Niladri_Biswas6-Jul-09 17:00
Niladri_Biswas6-Jul-09 17:00 
GeneralRe: SQL Query Pin
theCPkid6-Jul-09 22:52
theCPkid6-Jul-09 22:52 
AnswerRe: SQL Query Pin
Mycroft Holmes6-Jul-09 20:06
professionalMycroft Holmes6-Jul-09 20:06 
GeneralRe: SQL Query Pin
Paul Unsworth6-Jul-09 22:19
Paul Unsworth6-Jul-09 22:19 
GeneralRe: SQL Query Pin
Mycroft Holmes6-Jul-09 23:07
professionalMycroft Holmes6-Jul-09 23:07 
GeneralRe: SQL Query Pin
theCPkid6-Jul-09 22:48
theCPkid6-Jul-09 22:48 
Brilliant, _insert_synonyms_of_brilliant_here_ man!
My knowledge of SQL is only around 1 hour old out of which 50 minutes was around 2 years back.

I tried ltrim(X,Y) of SQLite but it returned the error that ltrim is not defined although this function is there in docs on SQLite website.. may be some version problems.
Then, I wrote my own function (based on functions in func.c) extractFileName(..) and tried to use "load_extension" to load the c file but could not make it work too.
Finally, I opened SQLite source file "func.c" and added the following two functions and an entry "{ "extractFileName", 1, 0, SQLITE_UTF8, 0, extractFileNameFunc },"
in "sqlite3RegisterBuiltinFunctions"

and in my SQL query, changed " ORDER BY filePath" to " ORDER BY extractFileName(filePath) "

and all worked well!!

Thank you. CP Rocks otherwise where in world one can find ppl like you.

/*
Extracts the file name from the file path. If file path is D:\myFolder\new1.txt, then it returns
new1.txt. not in original SQLite.
*/
const char* extractFileName(const char* s){
  while( *s != '\0' ) ++s;
  while( *s != '\\') --s;
  ++s;
  return s;
}

/*
Extracts the file name from the file path. If file path is D:\myFolder\new1.txt, then it returns
new1.txt. not in original SQLite.
*/
static void extractFileNameFunc(sqlite3_context *context, int argc, sqlite3_value **argv){
  const char *z;

  assert( argc==1);

  if( SQLITE_NULL==sqlite3_value_type(argv[0]) ){
    sqlite3_result_null(context);
    return;
  }
  z = sqlite3_value_text(argv[0]);
  sqlite3_result_text(context, extractFileName(z), -1, SQLITE_TRANSIENT); 
}

QuestionT-SQL USE with a variable Pin
TheComputerMan6-Jul-09 4:55
TheComputerMan6-Jul-09 4:55 
AnswerRe: T-SQL USE with a variable Pin
Blue_Boy6-Jul-09 6:13
Blue_Boy6-Jul-09 6:13 
GeneralRe: T-SQL USE with a variable Pin
TheComputerMan6-Jul-09 6:42
TheComputerMan6-Jul-09 6:42 
GeneralRe: T-SQL USE with a variable Pin
Blue_Boy6-Jul-09 7:09
Blue_Boy6-Jul-09 7:09 
GeneralRe: T-SQL USE with a variable Pin
TheComputerMan6-Jul-09 21:51
TheComputerMan6-Jul-09 21:51 
GeneralRe: T-SQL USE with a variable Pin
DoctorMick7-Jul-09 2:04
DoctorMick7-Jul-09 2:04 
GeneralRe: T-SQL USE with a variable Pin
TheComputerMan7-Jul-09 3:25
TheComputerMan7-Jul-09 3:25 
QuestionBest Way to Sync SQL Srv Databases Pin
Pago0076-Jul-09 3:58
Pago0076-Jul-09 3:58 
AnswerRe: Best Way to Sync SQL Srv Databases Pin
DoctorMick6-Jul-09 6:23
DoctorMick6-Jul-09 6:23 
AnswerRe: Best Way to Sync SQL Srv Databases Pin
dingoishere23-Feb-11 22:30
dingoishere23-Feb-11 22:30 
QuestionSchema Question Pin
Paul Unsworth6-Jul-09 3:13
Paul Unsworth6-Jul-09 3:13 
AnswerRe: Schema Question Pin
DoctorMick6-Jul-09 6:24
DoctorMick6-Jul-09 6:24 
AnswerRe: Schema Question Pin
David Mujica6-Jul-09 10:23
David Mujica6-Jul-09 10:23 
GeneralRe: Schema Question Pin
Paul Unsworth6-Jul-09 21:42
Paul Unsworth6-Jul-09 21:42 
GeneralRe: Schema Question Pin
David Mujica7-Jul-09 2:57
David Mujica7-Jul-09 2:57 
GeneralRe: Schema Question Pin
Paul Unsworth7-Jul-09 3:14
Paul Unsworth7-Jul-09 3:14 
GeneralAlong with security, consider auditing Pin
David Mujica7-Jul-09 3:25
David Mujica7-Jul-09 3:25 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.