Search This Blog

Wednesday, November 30, 2016

Will code for food

As of yesterday (2016/11/29), I am unemployed. On the bright side, at least the monkey of having to justify my continued employment by taking those stupid MicroSoft certification tests every few years is off my back.

21 comments:

Drew said...

:-(

Nate Winchester said...

That sucks. What did you program in?

Ilíon said...

For the past six years I have been doing mostly SQL Server development, with a touch of BizTalk (BizTalk serves a real need ... but I despise it nonetheless).

Before that, I was a C# developer.

Before that, I was a contract "technical back-end support" for the help desk in a department of the Ohio state government (that is, to examine COBOL code to identify problems the front-end couldn't resolve).

Before that, I was a UNIX administrator (I hated that) for a major US telecomm company.

Before that, I was a COBOL and BAL (mainframe assembler) programmer, using IMS/DC and IMS/DB, for the mentioned telecomm company.

Before that, I was a BAL (mainframe assembler) and COBOL programmer, using IMS/DC and IMS/DB, for a city iin Indiana.

B. Prokop said...

I hate to hear this. I hope you get back on your feet quickly!

Ilíon said...

Thanks.

Ilíon said...

Yesterday, I finished unloading the truck (*) and then organized the pantry. Between what I had here at the house already and what I'd had at the apartment, I have enough food to last for months without another visit to the grocery store.




(*) I pretty much collapsed into bed when I got home on Wednesday, having made two trips over Tuesday night to vacate the apartment I kep over there.

Nate Winchester said...

Huh. I needed you earlier this year when I was teaching myself c#. Might have to hire you sometime for a SQL tutor (as I'm learning that now).

Ilíon said...

LOL

Ilíon said...

Tutoring via email would be a tad difficult, don't you think?

As for teaching yourself C#, did you manage to do so?

I taught myself C# ... but only because I had a job prospect lined up (*) that used that language. Years before that (and before C# was created), I was going to teach myself C++ -- I bought some books and both Visual Studio and Borland Turbo C++ ... and then I did nothing with it, since I had no use-right-then for it.

This will sound strange, considering that C# is based on C++ and looks like the same thing to most people, but to this day I think that C++ (and C) is an ugly language. Whereas I like C#.


(*) I don't mean to imply that *I* lined it up; God dropped it into my lap.

Nate Winchester said...

Tutoring via email would be a tad difficult, don't you think?

Only to the unimaginative. Sometimes just having a mentor who can point where to find the solution is a big help.

As for teaching yourself C#, did you manage to do so?

Eh, barely enough for the program to do what it needed to (and now). I'm certain if you saw it the code might cause you to have a heart attack and shuffle off the mortal coil but it at least got the job done.

C++ is what I was taught in college and is still kind of my "default" language I'll think in. I'll agree C# is much more elegant, but then C++ is much more elegant than assembly language. ;-D

Ilíon said...

"... but then C++ is much more elegant than assembly language. ;-D"

I expect that you have in mind PC assembly, which does look nasty to me. I also wanted to teach myself that (and bought some materials), but never did really try to learn it.

Mainframe assembly is another beast altogether. Sure, it's not elegant, either; but it is, as they say, powerful. In my first job, I sometimes had to insert "jump" commands into the executing code via toggle switches on the front of the machine so as to get around a data problem.

Ilíon said...

Nate,
Do you have a copy of SQL Server? Which version? Alternately, while I've never used them, I expect that for the purposes of learning the SQL language, something like MySQL is more than sufficient.

Ilíon said...

Drew: ":-("

The *real* :-( is that you stopped blogging. But I'm happy that you still visit mine now and again.

Nate Winchester said...

Yeah, Microsoft SQL came with our server. I've been learning SQL from w3 schools. It's trying to learn to think like SQL that I'm working on. Like, you can use alias in the program but can't wield them to check stuff without using a subquery. i.e.
(SELECT .... ) AS Example
FROM __
WHERE Example > 0

doesn't work but this does:

SELECT *
FROM ((SELECT ....) AS Example) AS subQuery
WHERE subQuery.Example > 0

Now when the bosses ask, "can you make a report for X?" I can see how to do it in C# or C++ in my head, but takes me awhile to see how to in SQL. Heck I just learned about CASE and what it can do. lol

Ilíon said...

I'm understanding the "(SELECT .... )" to stand for a complete query in both examples.

In this example --

(SELECT .... ) AS Example
FROM __
WHERE Example > 0

The parentheses are causing your FROM and WHERE to be "orphaned". Or, more precisely, the WHERE "belongs" to the FROM, but the FROM doesn't "belong" to any SELECT.

Then, the "AS Example" assigns 'Example' as the alias for the result-set returned by the query, not for the column(s). Thus, the WHERE can't work, because it tries to treat the entire result-set as though it were an individual element/column.

In this example --

SELECT *
FROM ((SELECT ....) AS Example) AS subQuery
WHERE subQuery.Example > 0

I'm thinking you've typed it from memory and lost something in translation. I really don't believe that it can work.

Once again, 'Example' is the alias for the result-set, not for the element(s) of it. And, once again, the WHERE can't be right because 'subQuery.Example' is a result-set, not a column.

This works --
SELECT *
FROM (SELECT 1 AS Example) AS subQuery
WHERE subQuery.Example > 0

because 'Example' is the alias for a column, and thus 'subQuery.Example' refers to a column of the result-set.


This does not work --
SELECT *
FROM ((SELECT 1) AS Example) AS subQuery
WHERE subQuery.Example > 0

because this -- (SELECT 1) AS Example -- is faulty syntax.

========
"Heck I just learned about CASE and what it can do."

Wait 'til you learn about COALESCE, and if you are using SQL Server 2012 or higher, IIF

Ilíon said...

DECLARE @tbl TABLE
( [key] INT
,[value] VARCHAR(32)
);
INSERT INTO @tbl
( [key]
,[value]
)
VALUES
(0,'This is 0')
,(1,'This is 1')
,(2,'This is 2')
;
SELECT * FROM @tbl;

/*
-- This does not work: "The multi-part identifier'subQuery.Example' could not be bound"
SELECT *
FROM ((SELECT [key],[value] FROM @tbl) AS Example) AS subQuery
WHERE subQuery.Example > 0;

-- This does not work: "Invalid Column name 'example'"
SELECT *
FROM (SELECT [key],[value] FROM @tbl AS Example) AS subQuery
WHERE subQuery.Example > 0;

-- This does not work: "Invalid Column name 'example'"
SELECT *
FROM (SELECT [key],[value] FROM @tbl AS Example) AS subQuery
WHERE subQuery.Example.[key] > 0;
*/

-- This works ... though, of course, in this example/context it's ridiculous to use a sub-query
SELECT *
FROM (SELECT [key] AS Example
,[value]
FROM @tbl) AS subQuery
WHERE subQuery.Example > 0;

Ilíon said...

DECLARE @tbl TABLE
( [key] INT
,[value] VARCHAR(32)
);
INSERT INTO @tbl
( [key]
,[value]
)
VALUES
(0,'This is 0')
,(1,'This is 1')
,(2,'This is 2')
;
SELECT * FROM @tbl;


-- Another way to use a sub-query is via a CTE (Commmon Table Expression)
-- Some benefits of a CTE:
-- . the code is generallt easier to read
-- . the result-set of the CTS may be referenced multiple time in the main query
-- . A CTE can be coded to be recursive
;With cteExample AS
( SELECT [key] AS [cte_key]
,[value]
FROM @tbl
)
SELECT *
FROM cteExample
WHERE cteExample.[cte_key] > 0;

Ilíon said...

Nate,
In case it's not clear, my intention with those last two posts is to give you two examples of executable code that do what I *think* was the intention of the example code snippets you posted. My hope is that by running these code examples in a query window and studying what the result you may better understand the concept behind what you were asking about.

Ilíon said...

By the way, I think it's a good idea to develop the habit of always typing a semi-colon [;] immediately before WITH clauses which start a query.

The rationale is this -- these sorts of WITH *must* be either part of the first statement of a function/procedure/view/query *or* the previous statement *must* be terminated with a semicolon. As you're probably aware, while it is "best practice" to terminate *all* statements with a semicolon, SQL Server does not enforce this. Thus, if you write, say, a procedure using a CTE and with the statement before it terminated, but someone later modifies the procedure by inserting an unterminated statement immediately prior to the statement using the CTE, the code will be broken until a semi-colon is added.

Ilíon said...

DECLARE @tbl TABLE
( [key] INT
,[value] VARCHAR(32)
);
INSERT INTO @tbl
( [key]
,[value]
)
VALUES
(0,'This is 0')
,(1,'This is 1')
,(2,'This is 2')
;
SELECT * FROM @tbl;


-- Another way to use a sub-query is via a CTE (Commmon Table Expression)
-- Some benefits of a CTE:
-- . the code is generally easier to read
-- . the result-set of the CTE may be referenced multiple times in the main query
-- . A CTE can be coded to be recursive
--
-- As in this example, you can supply aliases to the elements returned by the CTE.
-- If you do so, then *all* of the returned values must be referenced (whether directly or by alias)
;With cteExample ([cte_key], [value]) AS
( SELECT [key]
,[value]
FROM @tbl
)
SELECT *
FROM cteExample
WHERE cteExample.[cte_key] > 0;

Shackleman said...

Ilion,

Check your hotmail inbox.

-Shackleman