[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

A better Emacs sql mode?



Hi,

Anyone here code sql seriously using Emacs and need strict Sql Coding 
Style [1]? 

I found that the default Emacs' sql mode is geared more towards 
interactive debugging, instead of sql coding. E.g., I simply wasn't able 
to indent my sql code the same way as any other programming language. 

UTSL reveals that AbbrevMode is also not used, let alone using abbrevs in 
code only so as NOT show capitalization you do NOT expect to use FOR [2].

So, what's your solution?

Thanks

[1] E.g., 

http://c2.com/cgi/wiki?SqlCodingStyle

 1. Capitalize SQL keywords.
 2. Put separate constraints and column names on separate lines.
 3. Indent equally detailed expressions equally.
 4. Use a monospace font.
 5. Right align equally important SQL keywords equally.

 SELECT	Person.name AS firstName,	
	Family.name AS lastName,
        Person.age
  FROM 	Person, Family
  WHERE Person.familyID = Family.ID
    AND Person.gender   = 'M'
  ORDER BY lastName ASC, familyID ASC, firstName ASC, age DESC;

http://www.remote-dba.net/t_plsql_coding_standards.htm

Incorrect:

  DaysBetween (dStartDate => dEnrolledDate,
               dEndDate => dGraduationDate,
               nGPA => nFinalGPA,
               nDaysBetween => nDuration);

Correct:

  DaysBetween (dStartDate   => dEnrolledDate,
               dEndDate     => dGraduationDate,
               nGPA         => nFinalGPA,
               nDaysBetween => nDuration);

[2] http://www.emacswiki.org/emacs/AbbrevMode

-- 
Tong (remove underscore(s) to reply)
  http://xpt.sourceforge.net/techdocs/
  http://xpt.sourceforge.net/tools/


Reply to: