That's why the good Lord saw fit to create PL/SQL Developer and it beautification tool. That way everyone can write it their way.
True enough.Personally, I like typing it all out myself. I don't use intellisense at all. I believe it helps me remember things better, typing them out that is.It's sort of like the cellphone and speed dial. I used to know everyone's phone number, now I hardly know my own. I don't want the same thing to happen to my tables... ;)chet
I need to vote "depends / both depending on statement"...I type everything out as well. I justify it on the basis that it adds another sanity check.Never trust a tab. I've never met a formatter that did things exactly as I like.
I always put my commas after the line, because that's what I'd do in English - I wouldn't do:Hello there ,how are you?It just looks wrong!As wiser heads than mine have said, code gets written once or twice, but read many more times. So, you write your code to be read.(I methodically go through and move every comma to after the line in code that I'm changing... which is a bit sad, really!)
@boneistI do that too!I agree, it "reads" better at the end of the line. Maybe that's why I have such a, umm...dislike for it?chet
@domRumor has it that the new SQL Developer formatter is very flexible...you can set it up however you want.I've not tried it yet though. I'm still going to type it out.chet
Chet,I do commas after the line in SQL and before the line in PL/SQL. How's that for strange ;)SQL developer 1.5 made a great leap with its formatter, but it's still lacking. I'm really looking forward to this working well so that the code can be standardized. Regards,Dan
That is strange...perhaps all your sense escaped through your hairless head? :)Oh wait...what does that say about me?chet
After the line... Gonna have to fix that :-D John T
Before the line is better in my opinion because commenting out columns doesn't leave you fiddling with commas.Like so:SELECT val1 ,val2 ,val3 ,val4FROM TABLEI can comment out the last two columns (val3 and val4) quickly without giving a thought to making sure I put a comma at the end. See:SELECT val1 ,val2-- ,val3-- ,val4FROM TABLEYay! Valid SQL.(Yes, if you comment out the first column you do have to fiddle with commas. However, I find that if I comment out columns it is almost never the first column)However, if I wroteSELECT val1, val2, val3, val4FROM TABLECommenting out val3 and val4 would leave the trailing comma after val2, which is a pain:SELECT val1, val2, -- BAD COLUMN HERE-- val3,-- val4FROM TABLEIt gets even more annoying when I'm commenting out val4 and val2, for example. I have to do some searching and re-parsing to figure out just where all the columns go.SELECT val1,-- val2, val3, -- ARGH!!!-- val4FROM TABLEWhat's worse with comma after the line, once you are done troubleshooting (maybe bringing back some joins that you temporarily removed to see why you have too many rows) you have to go back and fiddle with your commas again to get it back to valid SQL.Yes, comma-before may look alien at first (it did to me). However, the productivity gained by switching to it really is nice. I now tweak queries without giving much thought to where my commas are.
@c0achI hear ya. That is the one-and-only reason to ever put a comma at the front of the line.For me, it just comes down to the way I read, from left to right. As someone else said, "it looks alien" to me. ;)
I put the comma before, for the reason cOach pointed out plus the fact that cut and pasting from one query to another easier.This not only applies to the select list but also to the list of tables, for example:select acc.account_number , p.party_name , p.category_code , p.country , col.name collector , (select sum(amount_due_remaining) from ar_payment_schedules_all ps where ps.customer_id = acc.cust_account_id and ps.status = 'OP') total_balancefrom hz_parties p , hz_cust_accounts acc , hz_customer_profiles cp , ar_collectors colwhere p.party_id = acc.party_idand acc.cust_account_id = cp.cust_account_idand cp.site_use_id is nulland cp.collector_id = col.collector_id
Post a Comment