Click here to Skip to main content
15,909,656 members

Welcome to the Lounge

   

For discussing anything related to a software developer's life but is not for programming questions. Got a programming question?

The Lounge is rated Safe For Work. If you're about to post something inappropriate for a shared office environment, then don't post it. No ads, no abuse, and no programming questions. Trolling, (political, climate, religious or whatever) will result in your account being removed.

 
GeneralRe: SQL != SQL... Pin
William Clardy9-Oct-15 1:48
William Clardy9-Oct-15 1:48 
GeneralRe: SQL != SQL... PinPopular
Marc Clifton8-Oct-15 2:37
mvaMarc Clifton8-Oct-15 2:37 
GeneralRe: SQL != SQL... Pin
Jörgen Andersson8-Oct-15 3:16
professionalJörgen Andersson8-Oct-15 3:16 
GeneralRe: SQL != SQL... Pin
Sander Rossel8-Oct-15 5:33
professionalSander Rossel8-Oct-15 5:33 
GeneralRe: SQL != SQL... Pin
Eddy Vluggen8-Oct-15 2:58
professionalEddy Vluggen8-Oct-15 2:58 
GeneralRe: SQL != SQL... Pin
kmoorevs8-Oct-15 3:02
kmoorevs8-Oct-15 3:02 
GeneralRe: SQL != SQL... Pin
PIEBALDconsult8-Oct-15 4:50
mvePIEBALDconsult8-Oct-15 4:50 
GeneralRe: SQL != SQL... Pin
PIEBALDconsult8-Oct-15 4:49
mvePIEBALDconsult8-Oct-15 4:49 
Sander Rossel wrote:
When does the hurting stop?


Generally, the hurt lessens with each paycheck. Wink | ;)


I use many different database systems. I also have to deal with the various ways of wrapping table and column names in the various databases: [], "", ``, etc. And parameter prefices: @, : .
But it's Caché with is lack of operator precedence that wins the prize as worst (yes, worse than Access and Excel). Mad | :mad:


Anyway... now and again I work on a technique to deal with these issues. My current technique looks a bit like this:

C#
internal enum SQL
{
  [System.ComponentModel.DescriptionAttribute("Get a User record by Name")]
  [PIEBALD.Attribute.SqlServerStatementAttribute
  (
    @"
    SELECT [blah] , [blah] , [blah] FROM [UserTable] WHERE [Name]=@Param0
    "
  ,
    1 // (The number of parameters)
  )]
  [PIEBALD.Attribute.OracleStatementAttribute
  (
    @"
    SELECT ""blah"" , ""blah"" , ""blah"" FROM ""UserTable"" WHERE ""Name""=:Param0
    "
  ,
    1
  )]
  [PIEBALD.Attribute.MySqlStatementAttribute
  (
    @"
    SELECT `blah` , `blah` , `blah` FROM `UserTable` WHERE `Name`=@Param0
    "
  ,
    1
  )]
  GetUserByName

// Other members as required
}


This has the added benefit that it keeps all the various versions of the SQL together rather than having separate files or classes for each type of database and never knowing whether or not you are keeping them maintained properly.

Then in the application, I need refer only to the enumeration members, and my framework will select the correct version of the SQL for the particular ADO.net provider in use at the moment. (Yes, I might write yet another Data Access article.)

Very few applications actually need this, but it's good exercise.
GeneralRe: SQL != SQL... Pin
Sander Rossel8-Oct-15 5:32
professionalSander Rossel8-Oct-15 5:32 
GeneralRe: SQL != SQL... Pin
Jörgen Andersson8-Oct-15 6:22
professionalJörgen Andersson8-Oct-15 6:22 
GeneralRe: SQL != SQL... Pin
kmoorevs8-Oct-15 7:12
kmoorevs8-Oct-15 7:12 
GeneralRe: SQL != SQL... Pin
PIEBALDconsult8-Oct-15 13:00
mvePIEBALDconsult8-Oct-15 13:00 
GeneralRe: SQL != SQL... Pin
Roger Wright8-Oct-15 12:43
professionalRoger Wright8-Oct-15 12:43 
GeneralRe: SQL != SQL... Pin
Brittle16188-Oct-15 18:49
Brittle16188-Oct-15 18:49 
GeneralRe: SQL != SQL... Pin
Eric Whitmore9-Oct-15 1:58
Eric Whitmore9-Oct-15 1:58 
GeneralRe: SQL != SQL... Pin
Gary Huck9-Oct-15 3:13
Gary Huck9-Oct-15 3:13 
GeneralRe: SQL != SQL... Pin
Sander Rossel9-Oct-15 10:44
professionalSander Rossel9-Oct-15 10:44 
GeneralRe: SQL != SQL... Pin
agolddog9-Oct-15 4:01
agolddog9-Oct-15 4:01 
GeneralRe: SQL != SQL... Pin
Sander Rossel9-Oct-15 10:43
professionalSander Rossel9-Oct-15 10:43 
GeneralMQOTD Pin
V.7-Oct-15 21:59
professionalV.7-Oct-15 21:59 
GeneralRe: MQOTD Pin
OriginalGriff7-Oct-15 22:12
mveOriginalGriff7-Oct-15 22:12 
GeneralRe: MQOTD Pin
RUs1237-Oct-15 22:18
RUs1237-Oct-15 22:18 
GeneralRe: MQOTD Pin
den2k887-Oct-15 22:24
professionalden2k887-Oct-15 22:24 
GeneralRe: MQOTD Pin
Brittle16187-Oct-15 23:53
Brittle16187-Oct-15 23:53 
GeneralRe: MQOTD Pin
HobbyProggy8-Oct-15 0:00
professionalHobbyProggy8-Oct-15 0:00 

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.