Transcript
Page 1: From MySQL to SiR via ODBC John S. Lemon. From MySQL to SiR via ODBC How did it start ? Interdivisional rivalry / power complex- Calls are being delayed

From MySQL to SiR via ODBC

From

MySQLto

SiRvia

ODBC

John S. Lemon

Page 2: From MySQL to SiR via ODBC John S. Lemon. From MySQL to SiR via ODBC How did it start ? Interdivisional rivalry / power complex- Calls are being delayed

From MySQL to SiR via ODBC

How did it start ?Interdivisional ‘rivalry’ / ‘power complex’-

“Calls are being delayed longer this year in your division and this is reflecting on the service”

Had to prove it in 24 hours before weekly division managers meeting.

Page 3: From MySQL to SiR via ODBC John S. Lemon. From MySQL to SiR via ODBC How did it start ? Interdivisional rivalry / power complex- Calls are being delayed

From MySQL to SiR via ODBC

Summary• Initial crude solution – ODBC & SPSS

• ‘hoist by own petard’ - too successful

• MySQL extractions no help – bugs / features

• Re-think

• Need to ‘automate’ / ‘replicate’

• Use vPQL + ODBC > SiR > SPSS

Page 4: From MySQL to SiR via ODBC John S. Lemon. From MySQL to SiR via ODBC How did it start ? Interdivisional rivalry / power complex- Calls are being delayed

From MySQL to SiR via ODBC

Problem• Needed to know poor response rates.

• System provided reports and charts were no help

Page 5: From MySQL to SiR via ODBC John S. Lemon. From MySQL to SiR via ODBC How did it start ? Interdivisional rivalry / power complex- Calls are being delayed

From MySQL to SiR via ODBC

Problem

• Charts and tables geared towards ‘management’

• Gave overall views but fail to answer detailed questions

• Why ?

Page 6: From MySQL to SiR via ODBC John S. Lemon. From MySQL to SiR via ODBC How did it start ? Interdivisional rivalry / power complex- Calls are being delayed

From MySQL to SiR via ODBC

Problem

• Organisation is the problem

• Calls can ‘enter’ at any point not just ‘top’

• Then migrate anywhereHelpDesks

Applications Support Network Support Desktop Support

Hardware Maintenace

Page 7: From MySQL to SiR via ODBC John S. Lemon. From MySQL to SiR via ODBC How did it start ? Interdivisional rivalry / power complex- Calls are being delayed

From MySQL to SiR via ODBC

Problem

• Charts and tables geared towards ‘management’

• Didn’t show movement between subgroups

• Only times were ‘Open’ and ‘Close’

• So if call closed by subgroup ‘X’ then reports allocated total time to ‘X’ even if 90% was in ‘Y’ !!!

Page 8: From MySQL to SiR via ODBC John S. Lemon. From MySQL to SiR via ODBC How did it start ? Interdivisional rivalry / power complex- Calls are being delayed

From MySQL to SiR via ODBC

ODBC and SPSS

• Use ODBC from SPSS to extract data

• Create two files and manipulate within SPSS

• Merge and Aggregate create data file

• Still not good enough as limited ‘cross record functions’

Page 9: From MySQL to SiR via ODBC John S. Lemon. From MySQL to SiR via ODBC How did it start ? Interdivisional rivalry / power complex- Calls are being delayed

From MySQL to SiR via ODBC

ODBC and SPSS

• Use my SPSS2SiR routines ?

• No – ‘one-off’ and time constrained – hadn’t used for some years so ….. ?

• ‘Save As’ fixed ASCII from SPSS

• Create simple data base in SiR

• Allowed cross record functions

Page 10: From MySQL to SiR via ODBC John S. Lemon. From MySQL to SiR via ODBC How did it start ? Interdivisional rivalry / power complex- Calls are being delayed

From MySQL to SiR via ODBC

ODBC and SPSS• Crude but effective solution

• Unfortunately not end of problem

• ‘Hoist by my own petard’– “A petard is an explosive device used to

break down doors or walls with a ‘slow burning fuse’ “

– Sometimes the burn was not as slow as the bomb placer would like.

Page 11: From MySQL to SiR via ODBC John S. Lemon. From MySQL to SiR via ODBC How did it start ? Interdivisional rivalry / power complex- Calls are being delayed

From MySQL to SiR via ODBC

My ‘Petard’• Met the deadline – but ….

• Management requested more detail and complexity

• Actually heard that the phrase was – “If it is not your ….ing division that

needs a ‘kick up the a..e’ ! Then whose does.”

Page 12: From MySQL to SiR via ODBC John S. Lemon. From MySQL to SiR via ODBC How did it start ? Interdivisional rivalry / power complex- Calls are being delayed

From MySQL to SiR via ODBC

My ‘Petard’• Also wanted weekly updates

• Using SPSS route wasn’t practical – Cumbersome

– Crude

– Had tailored process for one division

– So couldn’t be easily extended or ‘automated’

• Back to drawing board

Page 13: From MySQL to SiR via ODBC John S. Lemon. From MySQL to SiR via ODBC How did it start ? Interdivisional rivalry / power complex- Calls are being delayed

From MySQL to SiR via ODBC

Next Step – First thoughts• MySQL data base - so obvious answer

• Use MySQL queries to generate data files– Even though updates were via SiR vPQL

generated SQL code thought might work

– Few more grey hairs later – no success

– Dump data out and read into SiR

• ‘Feature’ – no last column !!

Page 14: From MySQL to SiR via ODBC John S. Lemon. From MySQL to SiR via ODBC How did it start ? Interdivisional rivalry / power complex- Calls are being delayed

From MySQL to SiR via ODBC

Next Step – Second thoughts• ODBC worked for MySQL to SPSS so

why not use for this

• Dave Doulton uses a lot so …it must be good !

• How to do it ?

• Direct into SiR

Page 15: From MySQL to SiR via ODBC John S. Lemon. From MySQL to SiR via ODBC How did it start ? Interdivisional rivalry / power complex- Calls are being delayed

From MySQL to SiR via ODBC

Next Step – Second thoughts• Appeared to work well

• However– Many very short records for describing the

action

– Also many ‘actions’ missing

• Why ?

• Took some while to ‘crack’ the reason

Page 16: From MySQL to SiR via ODBC John S. Lemon. From MySQL to SiR via ODBC How did it start ? Interdivisional rivalry / power complex- Calls are being delayed

From MySQL to SiR via ODBC

Next Step – Second thoughts

LF / CR

Page 17: From MySQL to SiR via ODBC John S. Lemon. From MySQL to SiR via ODBC How did it start ? Interdivisional rivalry / power complex- Calls are being delayed

From MySQL to SiR via ODBC

Next Step – Second thoughts• Why was this important ?

• Whatever I was doing ( right or wrong ) SiR treated it as ‘end of record’

• Truncated MySQL records and so missed out the important bit !!

Page 18: From MySQL to SiR via ODBC John S. Lemon. From MySQL to SiR via ODBC How did it start ? Interdivisional rivalry / power complex- Calls are being delayed

From MySQL to SiR via ODBC

Next Step – Second thoughts

Page 19: From MySQL to SiR via ODBC John S. Lemon. From MySQL to SiR via ODBC How did it start ? Interdivisional rivalry / power complex- Calls are being delayed

From MySQL to SiR via ODBC

Next Step – Third thoughts• Back to the ‘drawing board’

• Have to write a vPQL programme

• How ?

• Obvious thing RTFM

• Read The Fine Manual

• You thought I was going say Flipping !

• Or something else !!

Page 20: From MySQL to SiR via ODBC John S. Lemon. From MySQL to SiR via ODBC How did it start ? Interdivisional rivalry / power complex- Calls are being delayed

From MySQL to SiR via ODBC

Next Step – Third thoughts• Actually not a manual

– ( how many are nowadays ? )

• Help files – complete with sample program

• RTFHF doesn’t flow as easily off the tongue as RTFM

• Didn’t quite understand all the options

• Now for a bit of ‘history’

Page 21: From MySQL to SiR via ODBC John S. Lemon. From MySQL to SiR via ODBC How did it start ? Interdivisional rivalry / power complex- Calls are being delayed

From MySQL to SiR via ODBC

PROGRAM INTEGER*4 errid conid statid rnum cnum STRING*20 cname colval STRING*80 qtext errstr CONNECT conid SERVER 'ODBC' DATABASE 'Company' USER 'me'

PASSWORD 'mypwd,COMPANY,HIGH,HIGH' PREFIX 'c:\SIR2002\TEST\' ERROR errid STATEMENT statid CONNECT conid ERROR errid WRITE errid PREPARE STATEMENT statid CONNECT conid COMMAND 'SELECT * FROM EMPLOYEE' ERROR errid WRITE errid EXECUTE STATEMENT statid CONNECT conid ERROR errid WRITE errid COMPUTE cnum = COLCOUNT (conid,statid) COMPUTE rnum = ROWCOUNT (conid,statid) WRITE 'Columns returned ' cnum ' Rows returned ' rnum FOR I = 1,cnum . COMPUTE cname = COLNAME (conid,statid,i) . WRITE cname END FOR SET J (0) LOOP . COMPUTE j = j+1 . COMPUTE res = NEXTROW (conid,statid) . IF (res LE 0) EXIT LOOP . FOR I = 1,cnum . IFTHEN (COLTYPE(conid,statid,i) eq 1) . COMPUTE colval = COLVALS (conid,statid,j,i) . ELSE . COMPUTE colval = FORMAT (COLVALN (conid,statid,j,i)) . ENDIF . WRITE colval . END FOR END LOOP DELETE STATEMENT statid CONNECT conid DISCONNECT conid END PROGRAM

The ‘Good’ old days ?

Page 22: From MySQL to SiR via ODBC John S. Lemon. From MySQL to SiR via ODBC How did it start ? Interdivisional rivalry / power complex- Calls are being delayed

From MySQL to SiR via ODBC

Progress ?• Number of basic ‘crucial commands to

get ODBC data– CONNECT– STATEMENT– PREPARE STATEMENT– EXECUTE STATEMENT– DELETE STATEMENT– DISCONNECT

• After ‘RTFHFing’ still had problems

Page 23: From MySQL to SiR via ODBC John S. Lemon. From MySQL to SiR via ODBC How did it start ? Interdivisional rivalry / power complex- Calls are being delayed

From MySQL to SiR via ODBC

Progress ?• Just couldn’t get a ‘connection’ or

anything

• Solution – E-mail David Baxter !!!

• As usual came to rescue – problem solved

• Still not sure why – just happy it does

Page 24: From MySQL to SiR via ODBC John S. Lemon. From MySQL to SiR via ODBC How did it start ? Interdivisional rivalry / power complex- Calls are being delayed

From MySQL to SiR via ODBC

Progress ? • This is the help file suggestion CONNECT conid SERVER 'ODBC' DATABASE 'Company' USER 'me' PASSWORD 'mypwd,COMPANY,HIGH,HIGH' PREFIX 'c:\SIR2002\TEST\' ERROR errid

• This is what I (we!!) got to work CONNECT conid SERVER 'ODBC‘ DATABASE 'Supportworks ODBC‘ USER 'train01‘ PASSWORD 'train01‘ PREFIX '‘ ERROR errid

Page 25: From MySQL to SiR via ODBC John S. Lemon. From MySQL to SiR via ODBC How did it start ? Interdivisional rivalry / power complex- Calls are being delayed

From MySQL to SiR via ODBC

Progress ?• Can’t ‘re-read’ / ‘re-extract’ a column

• Why would you want tocom045 - user identifiercom - department code

• If needed then extract twice ODBC doesn’t complain !!!

• Or extract to string and ‘chop up’ which is what I did for Date/Time vars

Page 26: From MySQL to SiR via ODBC John S. Lemon. From MySQL to SiR via ODBC How did it start ? Interdivisional rivalry / power complex- Calls are being delayed

From MySQL to SiR via ODBC

Progress ?COMPUTE TEMP468= COLVALS ( conid, statid, ROWNUM, 4 );

TEMP4D = CDATE ( ( SBST ( TEMP468, 1, 10 ) ), 'DDIMMIYYYY' ); TEMP4T = CTIME ( ( SBST ( TEMP468, 12, 8 ) ), 'HHIMMISS' );

• Extract the MySQL Date/Time variable into a string ( COLVALS )

• Then ‘chop out’ the bit you want and convert to date or time

• Numeric values need COLVALN COMPUTE TEMP2 = COLVALN ( conid, statid, ROWNUM, 2 );

Page 27: From MySQL to SiR via ODBC John S. Lemon. From MySQL to SiR via ODBC How did it start ? Interdivisional rivalry / power complex- Calls are being delayed

From MySQL to SiR via ODBC

SiR wins• Typical output but presents problem

• Start date and end date but no ‘intermediates’

• Generate ‘dummy’ records

Page 28: From MySQL to SiR via ODBC John S. Lemon. From MySQL to SiR via ODBC How did it start ? Interdivisional rivalry / power complex- Calls are being delayed

From MySQL to SiR via ODBC

Hindsight• Would I use ODBC again ?

• Yes – with what I know now

• I would not attempt extracting data from two MySQL tables and merge them in ODBC query statement

• SiR does it more ‘cleanly’

• Would be more careful in the planning.


Recommended