Monday, August 8, 2011

Windows service config commands

Had to do some changes to windows services recently to ensure that specific services would be started before others. The command I used was:


sc config "servce-name" depend= "other service name"

results: [SC] ChangeServiceConfig SUCCESS

This updated the registry settings for these two services.

Thursday, June 30, 2011

SQL To Find Records That Do Not Have Association

SQL Server Query to determine specific records that do not have a specific association to them:

select distinct documentid, ownername from contenttextpub where documentid in (select distinct documentid from contenttext where contentid in (Select contentid from contentsecuritytag where tagid=(select recordid from tag where referencekey='NULLTAG')))

Feels like recursion, but its more tied to the SQL Query grammer and how the SQL Server interpreter parses the query to get the final query results.

Tuesday, June 28, 2011

Mathematical Proofs and Business Requirements for Product Design

In College I took advanced math classes that taught us about Symmetric, Transitive, and Reflexive Relations. I thought these relations in proofs was not required, but then as we went through different equations I then started to understand the importance of these concepts.

With product development, I think a lot of these concepts should be thought about when designing a product. Because users will always attempt to use your product in ways that you had never imagined. And to attempt to foresee these usages of the product can become cost prohibitive.

Thursday, June 9, 2011

URL link creation

// Create URL link that social media sites can use
String linkUrl = java.net.URLEncoder.encode(request.getScheme() + "://" + request.getServerName()
+ ":" + request.getServerPort() + request.getContextPath() + "/index?"
+ request.getQueryString());

Monday, April 4, 2011

Oracle Trigger

Interesting trigger I worked on that uses exception handling to not insert records until all the required tables have populated data.

CREATE OR REPLACE TRIGGER CONTENTTEXTTOKEN_TRIGGER_1
AFTER INSERT OR UPDATE ON CONTENTTEXT
FOR EACH ROW
DECLARE
content_contentid VARCHAR2(64);
token_from_xml VARCHAR2(100);
token_recordid VARCHAR2(64);
xml_counter NUMBER := 1;
xml_clob CLOB;
BEGIN
/* Check if there is a clob in CONTENTDATA that corresponds with this update */
GET_XML_CLOB_PROCEDURE(:NEW.RECORDID, xml_clob);
IF DBMS_LOB.GETLENGTH( xml_clob ) > 0 THEN
/* Check for first token in clob */
xml_counter := REGEXP_INSTR(xml_clob, '\{(\s*?.*?)*?\}', xml_counter+1);
WHILE xml_counter <> 0 LOOP
/* Found a token, now get the token from the clob */
token_from_xml := SUBSTR(xml_clob, xml_counter+1, INSTR(SUBSTR(xml_clob, xml_counter+1), '}', 1, 1)-1);
xml_counter := REGEXP_INSTR(xml_clob, '\{(\s*?.*?)*?\}', xml_counter+1);
BEGIN
GET_TOKEN_RECORDID_PROCEDURE(token_from_xml, token_recordid);
IF length(token_recordid) > 0 THEN
BEGIN
SELECT CONTENTTEXTID INTO content_contentid
FROM CONTENTTEXTTOKEN
WHERE CONTENTTEXTID = :NEW.CONTENTID
AND TOKENID = token_recordid
AND TOKENNAME = token_from_xml;
EXCEPTION
WHEN NO_DATA_FOUND THEN
INSERT INTO CONTENTTEXTTOKEN (CONTENTTEXTID, TOKENID, TOKENNAME) VALUES (
:NEW.CONTENTID,
token_recordid,
token_from_xml
);
END;

BEGIN
SELECT CONTENTID INTO content_contentid
FROM CONTENTLINK
WHERE CONTENTID = :NEW.CONTENTID;
EXCEPTION
WHEN NO_DATA_FOUND THEN
INSERT INTO CONTENTLINK (CONTENTID, DOCID) VALUES (
:NEW.CONTENTID,
:NEW.DOCUMENTID
);
END;
END IF;
END;
content_contentid := NULL;
END LOOP;
END IF;
EXCEPTION
WHEN NO_DATA_FOUND THEN
NULL;
END;
/


CREATE OR REPLACE PROCEDURE GET_XML_CLOB_PROCEDURE (
ct_recordid IN VARCHAR2,
xml_clob OUT CLOB ) IS
BEGIN
SELECT XML INTO xml_clob FROM CONTENTDATA WHERE RECORDID = ct_recordid;
EXCEPTION
WHEN NO_DATA_FOUND THEN
xml_clob := EMPTY_CLOB();
END;
/

CREATE OR REPLACE PROCEDURE GET_TOKEN_RECORDID_PROCEDURE (
token_from_xml IN VARCHAR2,
token_recordid OUT VARCHAR2 ) IS
BEGIN
SELECT recordid INTO token_recordid FROM replacementtokens WHERE tokenname = token_from_xml;
EXCEPTION
WHEN NO_DATA_FOUND THEN
token_recordid := '';
END;
/