MacBook, defective by design banner

title:
Put the knife down and take a green herb, dude.


descrip:

One feller's views on the state of everyday computer science & its application (and now, OTHER STUFF) who isn't rich enough to shell out for www.myfreakinfirst-andlast-name.com

Using 89% of the same design the blog had in 2001.

FOR ENTERTAINMENT PURPOSES ONLY!!!
Back-up your data and, when you bike, always wear white.

As an Amazon Associate, I earn from qualifying purchases. Affiliate links in green.

x

MarkUpDown is the best Markdown editor for professionals on Windows 10.

It includes two-pane live preview, in-app uploads to imgur for image hosting, and MultiMarkdown table support.

Features you won't find anywhere else include...

You've wasted more than $15 of your time looking for a great Markdown editor.

Stop looking. MarkUpDown is the app you're looking for.

Learn more or head over to the 'Store now!

Monday, October 15, 2012

Ask Tom "Describe REF CURSOR columns":

Dear Tom,

how can I describe columns of a REF CURSOR? (analog of dbms_sql.DESCRIBE_COLUMNS).

Thanks

and we said...
you cannot, not until 11g Release 1 anyway, in plsql.

But then in 11g R1, magic happens.

SET SERVEROUTPUT ON; -- Tom forgets to remind us about this
declare
        l_rcursor sys_refcursor;
        l_colCnt number;
        l_descTbl dbms_sql.desc_tab;
begin
        open l_rcursor for select * from all_users;

        dbms_sql.describe_columns
        ( c       => dbms_sql.to_cursor_number(l_rcursor),
          col_cnt => l_colCnt,
          desc_t  => l_descTbl );

        for i in 1 .. l_colCnt
        loop
                dbms_output.put_line( l_descTbl(i).col_name );
        end loop;
end;
/

I'm trying to figure out what columns were returned by a stored procedure call, and it's been a bear so far trying to remember how to use sprocs in SQL Deveoloper and to change the default setup in the test harness to SYS_REFCURSOR -- and figure out how to play with each row in the cursor (that would be ROW_TEMP CUR_RESULT%ROWTYPE;) and...

Labels:


posted by ruffin at 10/15/2012 02:36:00 PM
Thursday, August 23, 2012

How do you do it? Here's the quick answer:

SELECT
CASE
WHEN TRIM(FIELD_MAYBE_NULL) is NULL THEN FIELD_NEVER_NULL
ELSE FIELD_NEVER_NULL || ', ' || FIELD_MAYBE_NULL
END AS CONCATTED_FIELD

FROM TABLE


Course it helps that NULL = '' in Oracle.

Labels: ,


posted by ruffin at 8/23/2012 04:29:00 PM
Tuesday, August 07, 2012

Had a process go on too long, and I couldn't tell which of the several I had going was the greedy one.
 
process - How do I show running processes in Oracle DB? - Stack Overflow:


SELECT sess.process, sess.status, sess.username, sess.schemaname, sql.sql_text
FROM v$session sess,
v$sql sql
WHERE sql.sql_id(+) = sess.sql_id
AND sess.type = 'USER'

Voila.

There are a few names on StackOverflow that I'm starting to recognize, and this Justin Cave is one of them.  I wonder how much of this is conscious branding and how much is [neurotic?] compulsion.  I can see how it'd be addictive, especially once you're an expert in something.  I'm no expert, but the git questions are just light enough on experts I could get sucked in.

Labels: , ,


posted by ruffin at 8/07/2012 12:49:00 PM

Materialized View Concepts and Architecture:

This chapter explains the concepts and architecture of Oracle materialized views.

Profit.

Labels: ,


posted by ruffin at 8/07/2012 10:01:00 AM

from here:

select lower(sys_context('USERENV','SESSION_USER'))||
'@'||
lower(sys_context('USERENV','DB_NAME'))||'>' prom
from dual;


... if only to check my sanity at one point.

Labels: ,


posted by ruffin at 8/07/2012 09:54:00 AM
Thursday, August 02, 2012

sql - why does my nested case statement return a character set mismatch? - Stack Overflow:

The type of a case statement is determined by the first clause in it. In this case, the first clause is a varchar string rather than an nvarchar.

Try this:
UPDATE TableA t
SET t.Last_Col = (CASE WHEN t.First_Col = N'ItemOne'
THEN N'anItemOne'
WHEN t.First_Col = N'ItemTwo'
THEN (CASE WHEN t.Second_Col = N'ItemTwo_A'
THEN N'aSecondItem_A'
ELSE N'aSecondItem'
END)
ELSE N'NoItem'
END );

Wow. Weird. String fields != strings if the field is an NVARCHAR. But slap an N in front of your quoted strings and you're golden.

Slick interface you got there, Oracle.

Labels: ,


posted by ruffin at 8/02/2012 03:14:00 PM
Monday, July 16, 2012

You know you're kludging when...

There are native SQL techniques to display multiple columns onto a single row

* Oracle 9i xmlagg

In Oracle 9i we can use the xmlagg function to aggregate multiple rows onto one column:

select
deptno,
rtrim (xmlagg (xmlelement (e, ename || ',')).extract ('//text()'), ',') enames
from
emp
group by
deptno
;

DEPTNO ENAMES
---------- ----------------------------------------
10 CLARK,MILLER,KING
20 SMITH,FORD,ADAMS,SCOTT,JONES
30 ALLEN,JAMES,TURNER,BLAKE,MARTIN,WARD

Labels: , ,


posted by ruffin at 7/16/2012 12:56:00 PM
Wednesday, June 20, 2012


Word to the wise: SQL*Loader doesn't like Mac file endings. Use TextWrangler's Save As to convert to Windows (or UNIX) file endings to make your csv sqlldr ready.

Labels: , , ,


posted by ruffin at 6/20/2012 09:01:00 AM
Thursday, May 24, 2012

c# - How to enable assembly bind failure logging (Fusion) in .NET - Stack Overflow:

If you have the Windows SDK installed on your machine, you'll find the "Fusion Log Viewer" under Microsoft SDK\Tools (just type "Fusion" in the start menu on Vista or Windows 7). Launch it, click the Settings button, and select "Log bind failure" or "Log all binds".

If these buttons are disabled, go back to the start menu, right-click the Log Viewer, and select "Run as Administrator".

Still can't say I'm getting Oracle.DataAccess to behave, however.  I hate 32/64 bit debugging.

Labels: ,


posted by ruffin at 5/24/2012 12:32:00 PM
Wednesday, April 04, 2012

A pretty good, step by step guide is here.

Keys:
1.) Get information from your tnsnames.ora file.
2.) oracle12.jar can be found here, though you might want ojdbc14.jar, also on that page.

Here, we can find some important things. Match your tnsnames.ora file and note the following details like me:
Database-name : XE
Server / Host = lordamit-laptop
Port: 1521

Remember, these are case sensitive. close the tnsnames.ora file. Now, once again. get back to squirrel. From the left menu, select Aliases. Click on the plus button to add a new alias.

now, make the following configurations [in SQuirreL]:

Name: myHR (change it if you want)
Driver: Oracle Thin driver
URL: jdbc:oracle:thin:@lordamit-laptop:1521:XE (replace it with the info you got from tnsnames.ora)
Username: HR
password: iit123
now, press ok. It will be saved. You can now press Connect to connect to your oracle

Labels:


posted by ruffin at 4/04/2012 09:28:00 AM
Wednesday, March 07, 2012

I shoulda linked this in a while back (Feb 17th, apparently), when I used it. The bottom line is that you find the package, right-click the appropriate shin-dig (see below), and then use a GUI. Because Oracle said so, that's why.

How can I use Oracle SQL developer to run stored procedures? - Stack Overflow:

I highlight it in the SQL*Developer Object Navigator, invoke the right-click menu and chose Run. (I could use ctrl+F11.) This spawns a pop-up window with a test harness. (Note: If the stored procedure lives in a package, you'll need to right-click the package, not the icon below the package containing the procedure's name; you will then select the sproc from the package's "Target" list when the test harness appears.)

Labels:


posted by ruffin at 3/07/2012 11:56:00 AM
Wednesday, February 22, 2012

select object_name
from dba_objects
where object_type = 'TRIGGER'
and status = 'INVALID';

Labels: ,


posted by ruffin at 2/22/2012 11:25:00 AM

Aka, "Where did all my changes go, and why does this trigger's creation only work in sqlplus?"

Roland Bouman's blog: Oracle SQL Developer 1.1 Supports MySQL:
Sorry, that was a PEBKAC (Problem Exists Between User And Chair)

All I needed to do was turn on "auto commit" in SQL Developer.
Tools -> Preferences
Click next to Database,
Select Worksheet Parameters
Click checkbox to mark "Autocommit in SQL Worksheet"
Close SQL Developer and re-launch.

Problem solved.


More on how autocommit works in Oracle from an Ask Tom segment here (from 2000! though last updated this month).

I've always used SQuirreL-SQL when using Oracle to this point, and this hasn't been an issue. Very non-SQL Query Analyzer. Old habits die hardest, I guess.

Labels: , ,


posted by ruffin at 2/22/2012 11:09:00 AM
Friday, February 17, 2012

How can I use Oracle SQL developer to run stored procedures? - Stack Overflow:

I highlight it in the SQL*Developer Object Navigator, invoke the right-click menu and chose Run. (I could use ctrl F11.) This spawns a pop-up window with a test harness. (Note: If the stored procedure lives in a package, you'll need to right-click the package, not the icon below the package containing the procedure's name; you will then select the sproc from the package's "Target" list when the test harness appears.)


Man, that's more difficult than T-SQL. I was supposed to be able to figure that out without help? Hello, non-intuitive. Why I can't just call or exec sprocName(param1, param2) and have it display results (even if via an outCursor) in the results window, I have no idea. Over 24k views for that thread, and it's only a year old.

Aside: Hard to believe Joel Spolsky is responsible for this thing, not because he doesn't often have good ideas, but because he seems to almost have too many. StackOverflow is awesomez. Why Fog Creek doesn't have some mainstream software everyone uses quickly becomes the more interesting question. Is Spolsky just a programmer who is good at managing programmers writing software for programmers, but that's it?

Labels:


posted by ruffin at 2/17/2012 12:07:00 PM

oracle - Problem with execute procedure in PL/SQL Developer - Stack Overflow:

Calling stored procedures using execute as above is specific to SQL*Plus. In fact, SQL*Plus converts execute some_proc() into BEGIN some_proc(); END;...

Labels:


posted by ruffin at 2/17/2012 11:34:00 AM

select * from ALL_CONSTRAINTS where constraint_name = 'YoConstraint'

Had one that wouldn't drop when the table was dropped (with CASCADE CONSTRAINTS;), and had to go search to see where the constraint with the same name as the one I was re-building lived. Voila.

(No, my constraint in production was not called 'YoConstrait'. That's yo' constraint name, not mine, okay?)

Labels: ,


posted by ruffin at 2/17/2012 08:57:00 AM
Thursday, February 09, 2012

SELECT * FROM all_tab_columns

Enjoy.

Labels: ,


posted by ruffin at 2/09/2012 10:31:00 AM

<< Older | Newer >>


Support freedom
All posts can be accessed here:


Just the last year o' posts:

URLs I want to remember:
* Atari 2600 programming on your Mac
* joel on software (tip pt)
* Professional links: resume, github, paltry StackOverflow * Regular Expression Introduction (copy)
* The hex editor whose name I forget
* JSONLint to pretty-ify JSON
* Using CommonDialog in VB 6 * Free zip utils
* git repo mapped drive setup * Regex Tester
* Read the bits about the zone * Find column in sql server db by name
* Giant ASCII Textifier in Stick Figures (in Ivrit) * Quick intro to Javascript
* Don't [over-]sweat "micro-optimization" * Parsing str's in VB6
* .ToString("yyyy-MM-dd HH:mm:ss.fff", CultureInfo.InvariantCulture); (src) * Break on a Lenovo T430: Fn+Alt+B
email if ya gotta, RSS if ya wanna RSS, (?_?), ยข, & ? if you're keypadless


Powered by Blogger etree.org Curmudgeon Gamer badge
The postings on this site are [usually] my own and do not necessarily reflect the views of any employer, past or present, or other entity.