Showing posts with label sql. Show all posts
Showing posts with label sql. Show all posts

Wednesday, 2 March 2016

REGEXP_LIKE To Find Unwanted Characters

This SQL will search for filenames that contain characters other than

  1. a-z
  2. A-Z
  3. 0-9
  4. underscore
  5. parenthesis
  6. dash
  7. period
  8. square brackets

Friday, 5 February 2016

Find Temp Tables used by Application Engine

I've been running into situations where our application engines are not clearing the temp tables even after process instance has been deleted.

Also, multiple occurrences of the process halting for no reason.

Oracle's workaround is to clear the temp tables and restart the process.

But which temp tables do you clear?

Try this script.

Friday, 15 January 2016

Remove Dead Worklist Entries

I want to remove worklist entries which have dead links.

But they only gave me a screenshot of the worklist page.

  1. Get OPRID of recipient
  2. Get OPRID of sender. If you look at the screenshot, it's the guy under FROM column.
  3. Get EOAWTHREAD_ID. If worklist is delivered, look at the 2nd value of the Link column.
  4. Execute SQL below.

Wednesday, 4 March 2015

Export All Results from ORACLE SQL DEVELOPER

I want to export all my query results from Oracle SQL Developer

I have two (2) options.

  1. Use /*csv*/
  2. CTRL + End

Oracle SQL Developer
Version 2.1.1.64
Build MAIN-64.65

SELECT /*csv*/ *
FROM PS_JOB

Or just click on query results and click Ctrl + End.

Thursday, 26 February 2015

Use SUBSELECT in PS Query Expression

I encountered this error when I used a subselect in my PSQuery expression.

FROM clauses are not allowed in expressions (50,536)
SQL error. Stmt #: 5682 Error Position: 107 Return: 936 - ORA-00936: missing expression
A SQL error occurred. Please consult your system log for details.
Error in running query because of SQL Error, Code=936, Message=ORA-00936: missing expression (50,380)

Here's the workaround:

Tuesday, 20 January 2015

SQL To Identify Actual Customized PeopleCode

For some reason, the demo environment is not up to date with all the patches and bundles applied to production.

I need to do a full compare of all the PeopleCode in the system and I need to identify which ones are actual customizations vs patches.

  1. Create the compare report.
  2. Run this SQL.

Friday, 16 January 2015

Top 10 Awesome Meta-SQL

Here is a list of my top 10 awesome meta-sql that makes my lazy life easier.
%EffdtCheck
%InsertSelect
%InsertValues
%Join
%KeyEqual
%SQL
%SelectAll
%SelectDistinct
%SelectByKey
%SelectByKeyEffDt

Now for some examples...

Friday, 2 January 2015

SQL to get Child Records

I want a list of PS_JOB's child record.

SELECT RECNAME 
FROM PSRECDEFN
CONNECT BY PRIOR RECNAME = PARENTRECNAME
START WITH PARENTRECNAME = 'Record Name Here';

Tuesday, 23 December 2014

SQL - Extract Month, Day, or Year from Date Value

Happy Holidays!

SELECT 
extract(YEAR from SYSDATE) as Year, 
extract(MONTH from SYSDATE) as Month, 
extract(DAY from SYSDATE) as Day
FROM DUAL;

Friday, 19 December 2014

SQL - GRANT Access to Record

I want to grant SELECT, UPDATE, DELETE, or all of these to a record.

Fire up Data Mover:

  1. Application Designer > Go > Data Mover
  2. or
  3. \Pt848\bin\client\winx86\psdmt.exe
SET LOG C:\TEMP\GRANTLOG2014.LOG;

GRANT ALL ON SYSADM.PS_MYRECORDNAME TO myusername;

Tuesday, 16 December 2014

SQL - Using OVER (PARTITION BY)

I want to list all phone numbers for a specific employee in one row.

Let's look at my progress with the OVER PARTITION command.

SELECT A.EMPLID, B.PHONE, ROW_NUMBER() OVER (ORDER BY A.EMPLID) as SEQ
FROM PS_PERSON A, PS_PERSONAL_PHONE B
WHERE B.EMPLID = A.EMPLID;

Results:

Now we add PARTITION BY EMPLID

Friday, 12 December 2014

DateTime Format

This is for SQL.

SELECT TO_CHAR(AUDIT_STAMP, 'yyyy-mm-dd hh24:mi:ss')
FROM PSAUDIT;

And this is using PeopleCode.

DateTimeToLocalizedString(%Date, "yyyyMMdd");

Tuesday, 9 December 2014

Find Portal Navigation Using Component Name

I want to find the navigation path using only a Component name.

Simple SQL

SELECT LEVEL0.PORTAL_LABEL || ' > ' || LEVEL1.PORTAL_LABEL || ' > '  || LEVEL2.PORTAL_LABEL || ' > '  ||  level3.PORTAL_LABEL PATH_TO_COMPONENT
FROM PSPRSMDEFN level3
, PSPRSMDEFN level2
, PSPRSMDEFN level1
, PSPRSMDEFN LEVEL0
WHERE level3.PORTAL_URI_SEG2 = "Your Component Name"
AND level3.PORTAL_PRNTOBJNAME = level2.PORTAL_OBJNAME
AND level2.PORTAL_PRNTOBJNAME = level1.PORTAL_OBJNAME
AND level1.PORTAL_PRNTOBJNAME = LEVEL0.PORTAL_OBJNAME
AND level3.PORTAL_NAME = level2.PORTAL_NAME
AND level2.PORTAL_NAME = level1.PORTAL_NAME
AND level1.PORTAL_NAME = LEVEL0.PORTAL_NAME;

The next one is actually better.

Friday, 14 November 2014

Alter Schema

No need to add SYSADM in front of every PS record.

ALTER SESSION SET CURRENT_SCHEMA = SYSADM;

Last used on Oracle SQL Developer Version 2.1.1.64.

Tuesday, 11 November 2014

SQL for Max Effective Dated Row from JOB table

SQL for max effective dated row from JOB table.

SELECT *
FROM PS_JOB J
WHERE J.EFFDT = (SELECT MAX (J_ED.EFFDT)
                 FROM PS_JOB J_ED
                 WHERE J_ED.EMPLID = J.EMPLID
                 AND J_ED.EMPL_RCD = J.EMPL_RCD
                 AND J_ED.EFFDT <= SYSDATE)
AND J.EFFSEQ = (SELECT MAX (J_ES.EFFSEQ)
                FROM PS_JOB J_ES
                WHERE J_ES.EMPLID = J.EMPLID
                AND J_ES.EMPL_RCD = J.EMPL_RCD
                AND J_ES.EFFDT = J.EFFDT)
ORDER BY J.EMPLID, J.EMPL_RCD, J.EFFDT, J.EFFSEQ;

If that returns multiple rows for a specific employee, that means he/she has additional assignments.
Use this SQL instead.