New Application Development features in IDS 11.10. Keshava Murthy, Architect, Informix Development [email_address]
SQL Features in IDS v11 <ul><li>Language features </li></ul><ul><ul><li>Full support for subqueries in FROM clause </li></...
Language Features <ul><li>Full support for subqueries in FROM Clause </li></ul><ul><li>Enhancements to distributed queries...
Support For Subqueries in FROM Clause <ul><li>SELECT * FROM </li></ul><ul><li>(SELECT tab1.a, tab2.x, tab2.y FROM tab1, ta...
Enhancements to Distributed Queries Application IDS Server:  lenexa Database: geardb Table: winter_gear  with Boolean, lva...
Trigger Enhancements employee_tab Insert trigger Delete trigger employee_tab Pre 11.10 server 11.10 server Single insert a...
Optimizer Features <ul><li>Index Self-join Access method </li></ul><ul><li>Optimizer directives for ANSI joins </li></ul><...
Index Self-Join Access Method SELECT * FROM tab WHERE c1 >= 1 AND c1 <= 3 AND c2 >= 10 AND c2 <= 11 AND c3 >= 100 AND c3 <...
Prior Releases Lower Filter c1 >= 1  Upper Filter c1 <= 3 Index Scan Region Eliminated range on c1
With This Feature Lead Keys: c1, c2 Lower Filter c1 = c1 and c2 = c2 and c3 >= 100 Upper Filter c3 <= 102 Index Scan Regio...
Optimizer Directives for ANSI Joins <ul><li>Previously ANSI join queries allowed EXPLAIN, AVOID_EXECUTE and FIRST_ROWS/ALL...
Improvements to IDS Statistics Collection <ul><li>Automatic creation of distribution on leading key of the index </li></ul...
Explain Enhancements <ul><li>Explain enhancements </li></ul><ul><ul><li>Query Optimization Time </li></ul></ul><ul><ul><li...
Utility Features <ul><li>New Isolation level: Committed Read  Last Committed </li></ul><ul><li>Websphere MQ Messaging supp...
Committed Read Last Committed -- do more -- do more --will return 850.00 -- do more -- do more -- Status: lock wait Commit...
Committed Read Last Committed S3:reconstruct 1234  1250 customerid  balance S1: start a transaction 1234  850 S1:Withdraw ...
Websphere MQ Messaging Support MQI Connection Queue1 Websphere MQ Informix Dynamic Server Order Entry Application Queue2 S...
Automatic Re-Preparation of SQL <ul><li>The dreaded -710 error </li></ul><ul><li>Make -710 disappear </li></ul>fetch open ...
Named Parameters Support for JDBC <ul><li>This is an example of implicit positional binding: </li></ul><ul><li>CallableSta...
Named Parameters Support for JDBC Here is the same code rewritten using named parameter notation: // Set parameters (named...
New Functions and Expressions ASCII(character_expression) The ASCII function returns the decimal representation of the  fi...
New Functions and Expressions CEIL (numerical_expession) returns the DECIMAL(32) representation of the  smallest integer  ...
New Functions and Expressions LAST_DAY(date or datetime expression) Returns last day of the month in the argument. SELECT ...
New Functions and Expressions MONTHS_BETWEEN(date/datetime expr, date/datetime expr) Returns the difference between two da...
New Functions and Expressions TO_NUMBER(character or numeric expression) converts a number or a character expression repre...
Enhancements to Functions Works same as POW() function. POWER Returns the same value as CURRENT DATETIME year to fraction(...
Disabling Logging for Temporary Tables <ul><li>Logging on all temporary tables can be disabled by either of the following ...
SYSDBOPEN() and SYSDBCLOSE()  <ul><li>CREATE PROCEDURE  public.sysdbopen (); </li></ul><ul><li>SET pdqpriority 1; </li></u...
New Types and Indices <ul><li>Node Data Type </li></ul><ul><li>Binary Data Type </li></ul><ul><li>Basic Text Search Index ...
Node Data Type -- create employees table CREATE TABLE Employees(Employee_Id NODE, desc VARCHAR(60)); -- insert the hierarc...
Node Functions <ul><li>Equals </li></ul><ul><li>NotEqual </li></ul><ul><li>LessThan </li></ul><ul><li>LessThanOrEqual </li...
Binary Data Type <ul><li>BINARY18 and BINARYVAR </li></ul><ul><ul><li>CREATE TABLE bin18_test (int_col INTEGER, </li></ul>...
Basic Text Search Index Invocation of LUCENE for text index operations IDS Client IDS Client BTS: Basic Text Search Index ...
Basic Text Search Index mkdir /work/myapp/bts_expspace_directory -- Create an external space to hold the index onspaces -c...
Basic Text Search Index CREATE INDEX title_index ON article_tab(title  bts_lvarchar_ops ) USING bts IN bts_extspace; SELEC...
Stored Procedure Enhancements <ul><li>GO TO Statement </li></ul><ul><li>LOOP Statement </li></ul><ul><li>Stored procedure ...
GO TO Statement <ul><li>CREATE PROCEDURE simple_goto(a int) </li></ul><ul><li>RETURNS int; </li></ul><ul><li>IF a < 50 THE...
LOOP Statement <ul><li>CREATE PROCEDURE plusnum(a int) </li></ul><ul><li>RETURNS int; </li></ul><ul><li>DEFINE x int; </li...
LOOP Statement <ul><li>CREATE PROCEDURE sumto_a(a int) </li></ul><ul><li>RETURNS int; </li></ul><ul><li>DEFINE x int; </li...
LOOP Statement <ul><li>CREATE PROCEDURE facto(a int) </li></ul><ul><li>RETURNS int AS x, int AS factx; </li></ul><ul><li>D...
Stored Procedure Recompilation  <ul><li>This is in 10.00.xC7 and 11.10.xC2  </li></ul><ul><ul><li>Wells Fargo situation </...
XML Support <ul><li>XML Publishing functions </li></ul><ul><ul><li>Genxml </li></ul></ul><ul><ul><li>Genxmlelem </li></ul>...
XML Publishing UDR invoking the XSLT4C and XML4C libraries within IDS IDS Client IDS Client Extract functions extract() ex...
XML Publishing functions <ul><li>SELECT  </li></ul><ul><li>genxml( ROW(customer_num, fname, lname, address1, city, state, ...
XML Publishing functions <ul><li>EXECUTE FUNCTION  genxmlqueryhdr('manufact_set', </li></ul><ul><li>'SELECT * FROM manufac...
XPath Support <ul><li>SELECT  extract(booklist, '/bookstore/book[1]') </li></ul><ul><li>FROM books WHERE bookstore_id =123...
Q & A
Resources <ul><li>Infocentre </li></ul><ul><ul><li>http://publib.boulder.ibm.com/infocenter/idshelp/v111/index.jsp </li></...
Upcoming SlideShare
Loading in...5
×

IBM Informix dynamic server 11 10 Cheetah Sql Features

4,152

Published on

Informix SQL features in IBM Informix dynamic server 11.10 release. by Keshava Murthy.

Published in: Business, Technology
0 Comments
2 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
4,152
On Slideshare
0
From Embeds
0
Number of Embeds
4
Actions
Shares
0
Downloads
0
Comments
0
Likes
2
Embeds 0
No embeds

No notes for slide

IBM Informix dynamic server 11 10 Cheetah Sql Features

  1. 1. New Application Development features in IDS 11.10. Keshava Murthy, Architect, Informix Development [email_address]
  2. 2. SQL Features in IDS v11 <ul><li>Language features </li></ul><ul><ul><li>Full support for subqueries in FROM clause </li></ul></ul><ul><li>Optimizer features </li></ul><ul><ul><li>Index self-join access method </li></ul></ul><ul><li>Utility Features </li></ul><ul><ul><li>sysdbopen()/sysdbclose() </li></ul></ul><ul><ul><li>ADD_MONTHS(), ASCII(), etc., functions </li></ul></ul><ul><li>New Types and Indices. </li></ul><ul><ul><li>Node datatype </li></ul></ul><ul><ul><li>Basic Text Search Index </li></ul></ul><ul><li>Stored Procedure Enhancements </li></ul><ul><ul><li>GO TO and LOOP statements </li></ul></ul><ul><li>XML Support </li></ul>
  3. 3. Language Features <ul><li>Full support for subqueries in FROM Clause </li></ul><ul><li>Enhancements to distributed queries </li></ul><ul><li>Trigger Enhancements </li></ul>
  4. 4. Support For Subqueries in FROM Clause <ul><li>SELECT * FROM </li></ul><ul><li>(SELECT tab1.a, tab2.x, tab2.y FROM tab1, tab2 </li></ul><ul><li>WHERE tab1.a = tab2.z ORDER BY tab1.b ) vt(va, vb, vc), </li></ul><ul><li>emptab </li></ul><ul><li>WHERE vt.va = emptab.id; </li></ul><ul><li>SELECT * FROM </li></ul><ul><li>((SELECT c1,c2 FROM t3) AS vt3(v31,v32) LEFT OUTER JOIN </li></ul><ul><li>((SELECT c1,c2 FROM t1) AS vt1(vc1,vc2) LEFT OUTER JOIN </li></ul><ul><li> (SELECT c1,c2 FROM t2) AS vt2(vc3,vc4) </li></ul><ul><li> ON vt1.vc1 = vt2.vc3) </li></ul><ul><li>ON vt3.v31 = vt2.vc3); </li></ul><ul><li>SELECT * </li></ul><ul><li>FROM table(foo(5)) AS vt(a), tab1 t </li></ul><ul><li>WHERE vt.a = t.x; </li></ul>
  5. 5. Enhancements to Distributed Queries Application IDS Server: lenexa Database: geardb Table: winter_gear with Boolean, lvarchar and distinct types C, SPL, Java functions IDS Server: portland Database:geardb Table: rain_gear with Boolean, lvarchar, and distinct types C, SPL, Java functions IDS Server: menlo Database: geardb Table: winter_gear with Boolean, lvarchar and distinct types C, SPL, Java functions ISTAR: Distributed query connections SQL and result set exchange Multiple IDS server setup IDS Server: toronto Database:geardb C, SPL, Java functions
  6. 6. Trigger Enhancements employee_tab Insert trigger Delete trigger employee_tab Pre 11.10 server 11.10 server Single insert and delete triggers, and multiple update and select triggers on mutually exclusive columns Multiple insert, update, delete and select triggers without exclusivity rule. The multiple insert and delete triggers feature is new in Cheetah. Update triggers Insert triggers Delete triggers Update triggers Select triggers New Feature: Multiple Triggers New feature: No column Exclusivity rule Select triggers
  7. 7. Optimizer Features <ul><li>Index Self-join Access method </li></ul><ul><li>Optimizer directives for ANSI joins </li></ul><ul><li>Improvements to IDS statistics collection </li></ul><ul><li>Explain enhancements </li></ul><ul><ul><li>Dynamic explain enhancements </li></ul></ul><ul><li>Refresher features </li></ul><ul><ul><li>Subquery flattening </li></ul></ul><ul><ul><li>View folding </li></ul></ul><ul><ul><li>More on IDS Redbook </li></ul></ul>
  8. 8. Index Self-Join Access Method SELECT * FROM tab WHERE c1 >= 1 AND c1 <= 3 AND c2 >= 10 AND c2 <= 11 AND c3 >= 100 AND c3 <= 102; leafpage leafpage leafpage leafpage leafpage leafpage leafpage Root View of the index on (c1, c2, c3) Leaf level
  9. 9. Prior Releases Lower Filter c1 >= 1 Upper Filter c1 <= 3 Index Scan Region Eliminated range on c1
  10. 10. With This Feature Lead Keys: c1, c2 Lower Filter c1 = c1 and c2 = c2 and c3 >= 100 Upper Filter c3 <= 102 Index Scan Regions Regions eliminated by Index Self Join strategy
  11. 11. Optimizer Directives for ANSI Joins <ul><li>Previously ANSI join queries allowed EXPLAIN, AVOID_EXECUTE and FIRST_ROWS/ALL_ROWS </li></ul><ul><li>IDS v11 Adds </li></ul><ul><ul><li>Access method directives: FULL, INDEX.. </li></ul></ul><ul><ul><li>Join method directives: USE_HASH, USE_NL.. </li></ul></ul><ul><ul><li>Join Order directive: ORDERED </li></ul></ul><ul><li>SELECT --+ FULL(t2), INDEX(t1, t1i1), ORDERED </li></ul><ul><li>* </li></ul><ul><li>FROM t1 LEFT OUTER JOIN t2 ON (t1.c1=t2.c1 AND t1.c1=2) </li></ul><ul><li>WHERE t2.c1 IS NOT NULL </li></ul><ul><li>DIRECTIVES FOLLOWED: </li></ul><ul><li>FULL ( t2 ) </li></ul><ul><li>INDEX ( t1 t1i1 ) </li></ul><ul><li>ORDERED </li></ul><ul><li>DIRECTIVES NOT FOLLOWED: </li></ul><ul><li>Estimated Cost: 7 </li></ul><ul><li>Estimated # of Rows Returned: 1 </li></ul><ul><li>... </li></ul>
  12. 12. Improvements to IDS Statistics Collection <ul><li>Automatic creation of distribution on leading key of the index </li></ul><ul><li>Implicit UPDATE STATISTICS LOW </li></ul><ul><li>SAMPLING SIZE </li></ul><ul><ul><li>UPDATE STATISTICS MEDIUM FOR TABLE tab(c1, c2) SAMPLING SIZE 500 RESOLUTION 2; </li></ul></ul><ul><ul><li>UPDATE STATISTICS MEDIUM FOR TABLE tab(c1, c2) SAMPLING SIZE .2 RESOLUTION 2; </li></ul></ul><ul><li>Additional info in sysdistrib </li></ul>
  13. 13. Explain Enhancements <ul><li>Explain enhancements </li></ul><ul><ul><li>Query Optimization Time </li></ul></ul><ul><ul><li>Distributed query support </li></ul></ul><ul><ul><li>Estimated and Actual cardinalities </li></ul></ul><ul><ul><ul><li>Controlled by EXPLAIN_STAT </li></ul></ul></ul><ul><ul><li>Dynamic explain enhancements </li></ul></ul><ul><ul><ul><li>Prints the location the explain file in online.log </li></ul></ul></ul><ul><ul><ul><li>Provides any errors while trying to create the file </li></ul></ul></ul><ul><ul><ul><li>onmode –Y <sid> 0|1|2 [filename] </li></ul></ul></ul><ul><ul><ul><ul><li>Specify the location of the dynamic explain </li></ul></ul></ul></ul><ul><ul><ul><ul><li>Specify whether you need query stats </li></ul></ul></ul></ul>
  14. 14. Utility Features <ul><li>New Isolation level: Committed Read Last Committed </li></ul><ul><li>Websphere MQ Messaging support </li></ul><ul><li>Automatic repreparation of SQL statements </li></ul><ul><li>Named Parameters support for JDBC </li></ul><ul><li>New functions and expressions </li></ul><ul><li>Disabling logging for temporary tables. </li></ul><ul><li>SYSDBOPEN() and SYSDBCLOSE() procedures </li></ul>
  15. 15. Committed Read Last Committed -- do more -- do more --will return 850.00 -- do more -- do more -- Status: lock wait Commit work; -- Continue processing -- Continue processing -- Status: lock wait insert into daily_tab(“transfer”, 1234, 3456, 400); select balance from cust_tab where custid = 1234; -- No waiting -- will return 1250.00 select balance from cust_tab where custid = 1234; -- No waiting. will return 850.00. select balance from cust_tab where custid = 1234; -- wait for the lock on row for customer 1234 update cust_tab set balance = balance + 400 where cust_id = 3456; -- balance of customer 1234 is 850.00 begin work; begin work; begin work; update cust_tab set balance =balance – 400 where cust_id = 1234; begin work; set isolation to read committed; -- Current balance of customer 1234 is 1250.00 Transaction4 LAST COMMITTED (New in IDS 11.10) Transaction3 DIRTY READ Transaction2 COMMITTED READ (default in logged database) Transaction1 Event
  16. 16. Committed Read Last Committed S3:reconstruct 1234 1250 customerid balance S1: start a transaction 1234 850 S1:Withdraw $400 Lock the record and create Log for subtractting 400. 1234 850 S1:Read the updated record S2: committed read: RequestRead the record being updated Result: lock error or wait, if requested S3: Dirty Read request Result: The value returned is time sensitive. Wait for the update to complete and then return 850 S4: Last committed read Result: Recognizes the lock on the row. Goes to the log, returns the old row [1234, 1250] Last Committed Read, Visually
  17. 17. Websphere MQ Messaging Support MQI Connection Queue1 Websphere MQ Informix Dynamic Server Order Entry Application Queue2 Shipping Application MQ Functions and MQ VTI table.
  18. 18. Automatic Re-Preparation of SQL <ul><li>The dreaded -710 error </li></ul><ul><li>Make -710 disappear </li></ul>fetch open cursor -- IDS 10 used to raise -710 error. IDS 11.10 automatically re-prepares and gets new plan for this and subsequent execution. do something else -- continuing with create index close -- continuing with create index fetch CREATE INDEX ONLINE icln ON customers(lname) fetch fetch open cursor; declare cusor on s1; -- creates and uses the FirstPlan below. Prepare the statement s1; Session2 Session1
  19. 19. Named Parameters Support for JDBC <ul><li>This is an example of implicit positional binding: </li></ul><ul><li>CallableStatement cstmt = con.prepareCall(&quot;call order_item(?, ?, ?, ?, ?,?, ?)&quot;); </li></ul><ul><li>// Set parameters (positional notation) </li></ul><ul><li>cstmt.setInt( 1 , 5739 ); </li></ul><ul><li>cstmt.setInt( 2 , 8294); </li></ul><ul><li>cstmt.setString( 6 , &quot;345, University ave.&quot;); </li></ul><ul><li>cstmt.setInt( 7 , 94303); </li></ul><ul><li>cstmt.setString( 4 ,&quot;4100 Bohannon Dr.&quot;); </li></ul><ul><li>cstmt.setInt( 5 , 94025); </li></ul><ul><li>cstmt.setInt( 3 ,5); </li></ul><ul><li>// Execute </li></ul><ul><li>cstmt.execute(); </li></ul>
  20. 20. Named Parameters Support for JDBC Here is the same code rewritten using named parameter notation: // Set parameters (named notation) cstmt.setInt(&quot; cust_id &quot;, 5739 ); Chapter 9. SQL Language 275 cstmt.setInt(&quot; item_id &quot;, 8294); cstmt.setString(&quot; shipping_addr &quot;, &quot;345, University ave.&quot;); cstmt.setInt(&quot; shipping_zip &quot;, 94303); cstmt.setString(&quot; billing_addr &quot;,&quot;4100 Bohannon Dr.&quot;); cstmt.setInt(&quot; billing_zip &quot;, 94025); cstmt.setInt(&quot; count &quot;, 5); // Execute cstmt.execute();
  21. 21. New Functions and Expressions ASCII(character_expression) The ASCII function returns the decimal representation of the first character in a character string. ASCII(‘a’) returns: 97 ASCII(‘Hello World!’) returns: 72 ASCII ADD_MONTHS(date/datetime expression , integer ) Adds months to a date or datetime value or expression. The first argument is date or datetime expression and second is an integer. Return type is same as first argument. ADD_MONTHS('4/16/2004', 20) returns: 12/16/2005 ADD_MONTHS(CURRENT, 3) returns: 2007-09-19 10:04:11.00000 ADD_MONTHS()
  22. 22. New Functions and Expressions CEIL (numerical_expession) returns the DECIMAL(32) representation of the smallest integer that is greater than or equal to its single argument. FLOOR(numerical_expression) returns the DECIMAL(32) representation of the largest integer that is smaller than or equal to its single argument. CEIL(-54.232) returns -54 FLOOR(-54.232) returns -55 CEIL(54.232) returns 55 FLOOR(54.232) returns 54 CEIL FLOOR BITAND(num1, num2) – returns the bitwise ANDed value. BITOR(num1, num2) – returns the bitwise ORed value. BITXOR(num1, num2) – returns the bitwise XORed value. BITNOT(num1) – returns the bitwise ANDed value. BITANDNOT(num1, num2) – is a short form for BITAND(arg1, BITNOT(arg2)) Bitwise functions
  23. 23. New Functions and Expressions LAST_DAY(date or datetime expression) Returns last day of the month in the argument. SELECT TODAY AS today, CURRENT AS current, LAST_DAY(TODAY) AS last_from_today, LAST_DAY(CURRENT) AS last_from_current FROM systables WHERE tabid = 1; today 06/19/2007 current 2007-06-19 10:23:01.000 last_from_today 06/30/2007 last_from_current 2007-06-30 10:23:01.00000 LAST_DAY FORMAT_UNITS(number, precision, units) Helps formatting of numbers in kilobytes to peta bytes. Detailed explanation with examples is in IDS SQL Syntax guide. SELECT FORMAT_UNITS( SUM(chksize), 'P') size, FORMAT_UNITS( SUM(nfree), 'p') free FROM syschunks; size 117 MB free 8.05 MB FORMAT_UNITS
  24. 24. New Functions and Expressions MONTHS_BETWEEN(date/datetime expr, date/datetime expr) Returns the difference between two date or datetime expressions in decimal, based on 31day months. SELECT CURRENT, MONTHS_BETWEEN(TODAY, LAST_DAY(CURRENT)) FROM systables WHERE tabid = 1; (expression) (expression) 2007-06-19 10:51:57.000 -0.3694433243728 MONTHS_BETWEEN LTRIM(source_string, pad_string) Returns the source_string after removing specified leading pad characters from a string. LTRIM will remove leading blanks when you simply pass the source string. LTRIM(‘Hello Cheetah!’, ‘Hello ‘) returns: Cheetah! LTRIM
  25. 25. New Functions and Expressions TO_NUMBER(character or numeric expression) converts a number or a character expression representing a number value to a DECIMAL. TO_NUMBER NULLIF(arg1, arg2) Returns NULL if arg1 and arg2 are equal, else returns arg1. If both are NULL – they won’t be equal – but still returns NULL because arg1 is NULL. NULLIF Next_day(date or datetime expr, abbreviated day of the week) Returns the date or datetime for next day matching the second argument. EXECUTE FUNCTION NEXT_DAY(TODAY, 'Mon') returns: 06/25/2007 EXECUTE FUNCTION NEXT_DAY(CURRENT, 'Mon') returns: 2007-06-25 6:57:52.00000 NEXT_DAY
  26. 26. Enhancements to Functions Works same as POW() function. POWER Returns the same value as CURRENT DATETIME year to fraction(5) SYSDATE These two functions can now take date and datetime expressions. IDS Syntax guide explains this in detail. TRUNC ROUND TO_CHAR(numeric expression) In addition to exisiting functionality, in IDS v11.10, this function will convert a number into a charater string. TO_CHAR
  27. 27. Disabling Logging for Temporary Tables <ul><li>Logging on all temporary tables can be disabled by either of the following two ways: </li></ul><ul><ul><li>ONCONFIG </li></ul></ul><ul><ul><ul><li>TEMPTAB_NOLOG 1 # 0 (logging on) is the default value. </li></ul></ul></ul><ul><ul><li>Dynamically </li></ul></ul><ul><ul><ul><li>onmode -Wf &quot;TEMPTAB_NOLOG=1&quot; </li></ul></ul></ul><ul><ul><ul><li>onmode -Wm &quot;TEMPTAB_NOLOG=1&quot; </li></ul></ul></ul>
  28. 28. SYSDBOPEN() and SYSDBCLOSE() <ul><li>CREATE PROCEDURE public.sysdbopen (); </li></ul><ul><li>SET pdqpriority 1; </li></ul><ul><li>SET ENVIRONMENT OPTCOMPIND '1'; </li></ul><ul><li>SET ISOLATION COMMITTED READ; </li></ul><ul><li>SET ENVIRONMENT USELASTCOMMITTED 'ALL'; </li></ul><ul><li>SYSTEM &quot;echo Logged IN: &quot; || USER || &quot; &quot; || </li></ul><ul><li>CURRENT || &quot; >> /tmp/mylog&quot;; </li></ul><ul><li>END PROCEDURE; </li></ul><ul><li>-- log the entry. </li></ul><ul><li>CREATE PROCEDURE public.sysdbclose (); </li></ul><ul><li>SYSTEM &quot;echo Logged OUT: &quot; || USER || &quot; &quot; || </li></ul><ul><li>CURRENT || &quot; >> /tmp/mylog&quot;; </li></ul><ul><li>END PROCEDURE; </li></ul>
  29. 29. New Types and Indices <ul><li>Node Data Type </li></ul><ul><li>Binary Data Type </li></ul><ul><li>Basic Text Search Index </li></ul>
  30. 30. Node Data Type -- create employees table CREATE TABLE Employees(Employee_Id NODE, desc VARCHAR(60)); -- insert the hierarchical information. INSERT INTO Employees VALUES ('1.0', &quot;CEO&quot;); INSERT INTO Employees VALUES ('1.1', &quot;VP1&quot;); INSERT INTO Employees VALUES ('1.1.1', &quot;Admin for VP1&quot;); INSERT INTO Employees VALUES ('1.2', &quot;VP2&quot;); INSERT INTO Employees VALUES ('1.2.1', &quot;Manager1&quot;); INSERT INTO Employees VALUES ('1.2.2', &quot;Manager2&quot;); INSERT INTO Employees VALUES ('1.2.2.1', &quot;Admin for Manager2&quot;); -- Retrieve the hierarchy for the “Admin for Manager2” SELECT * FROM Employees E WHERE isAncestor(Employee_Id, '1.2.2.1') ORDER BY E.Employee_Id ; employee_id desc 1.0 CEO 1.2 VP2 1.2.2 Manager2
  31. 31. Node Functions <ul><li>Equals </li></ul><ul><li>NotEqual </li></ul><ul><li>LessThan </li></ul><ul><li>LessThanOrEqual </li></ul><ul><li>GreaterThan </li></ul><ul><li>GreaterThanOrEqual </li></ul><ul><li>Compare </li></ul><ul><li>Increment </li></ul><ul><li>Length </li></ul><ul><li>Depth </li></ul><ul><li>NewLevel </li></ul><ul><li>GetParent </li></ul><ul><li>IsParent </li></ul><ul><li>IsChild </li></ul><ul><li>Ancestors </li></ul><ul><li>Graft </li></ul><ul><li>IsDecendant </li></ul><ul><li>GetMember </li></ul>
  32. 32. Binary Data Type <ul><li>BINARY18 and BINARYVAR </li></ul><ul><ul><li>CREATE TABLE bin18_test (int_col INTEGER, </li></ul></ul><ul><ul><li>bdt_col BINARY18); </li></ul></ul><ul><ul><li>INSERT INTO bin18_test VALUES (0, '0102'); </li></ul></ul><ul><ul><li>INSERT INTO bin18_test VALUES (1, '01020304'); </li></ul></ul><ul><ul><li>CREATE INDEX idx_bin18 ON bin18_test(bdt_col); </li></ul></ul><ul><ul><li>CREATE INDEX idx_binvar ON bindata(bin_col); </li></ul></ul><ul><li>Functions on binary types </li></ul><ul><ul><li>Length() </li></ul></ul><ul><ul><li>Octet_length() </li></ul></ul><ul><ul><li>Bit_and() </li></ul></ul><ul><ul><li>Bit_or() </li></ul></ul><ul><ul><li>Bit_xor() </li></ul></ul><ul><ul><li>Bit_complement() </li></ul></ul>
  33. 33. Basic Text Search Index Invocation of LUCENE for text index operations IDS Client IDS Client BTS: Basic Text Search Index Interface Informix Dynamic Server C-LUCENE text search index analyze and arts behavior cut … with your 0, 8, 12, 15 1, 9, 15, 22, 44, 23, 1, 8, 10 1 2, 22 … … … Index Access method Query processing and Optimizer
  34. 34. Basic Text Search Index mkdir /work/myapp/bts_expspace_directory -- Create an external space to hold the index onspaces -c -x bts_extspace -l /work/myappbts_expspace_directory onmode –p +1 bts --Create a table with a BTS index CREATE TABLE article_tab(id integer, title lvarchar(512)); -- Load the data below Informix and Open source: database defense against the dark political arts 1 Understanding locking behavior and analyze lock conflicts in IDS 0 title id
  35. 35. Basic Text Search Index CREATE INDEX title_index ON article_tab(title bts_lvarchar_ops ) USING bts IN bts_extspace; SELECT id FROM article_tab WHERE bts_contains(title, 'informix'); -- with the AND Boolean operator (&& and + are allowed as well) SELECT id FROM article_tab WHERE bts_contains (title, 'informix AND dynamic'); SELECT id FROM article_tab WHERE bts_contains (title, 'inf*rmix'); SELECT id FROM article_tab WHERE bts_contains (title,'&quot;java&quot;~10');
  36. 36. Stored Procedure Enhancements <ul><li>GO TO Statement </li></ul><ul><li>LOOP Statement </li></ul><ul><li>Stored procedure recompilation </li></ul>
  37. 37. GO TO Statement <ul><li>CREATE PROCEDURE simple_goto(a int) </li></ul><ul><li>RETURNS int; </li></ul><ul><li>IF a < 50 THEN </li></ul><ul><li>GOTO lessval; -- jump to lessval. </li></ul><ul><li>END IF; </li></ul><ul><li>RETURN a * a; -- return something </li></ul><ul><li><<lessval>> -- define the label lessval </li></ul><ul><li>RETURN a * -1; </li></ul><ul><li>END PROCEDURE; </li></ul>
  38. 38. LOOP Statement <ul><li>CREATE PROCEDURE plusnum(a int) </li></ul><ul><li>RETURNS int; </li></ul><ul><li>DEFINE x int; </li></ul><ul><li>LET x = a; </li></ul><ul><li>LOOP -- start the loop </li></ul><ul><li>LET x = x + 1; </li></ul><ul><li>IF x < 0 THEN </li></ul><ul><li>CONTINUE; -- increment until +ve number. </li></ul><ul><li>ELIF x < 1000 THEN </li></ul><ul><li>RETURN x WITH RESUME; -- return and come back. </li></ul><ul><li>END IF; </li></ul><ul><li>EXIT LOOP WHEN x = 1000; -- exit loop at 1000. </li></ul><ul><li>END LOOP; </li></ul><ul><li>END PROCEDURE; </li></ul>
  39. 39. LOOP Statement <ul><li>CREATE PROCEDURE sumto_a(a int) </li></ul><ul><li>RETURNS int; </li></ul><ul><li>DEFINE x int; </li></ul><ul><li>DEFINE total int; </li></ul><ul><li>LET total = 0; </li></ul><ul><li>FOR x IN (1 TO a) LOOP -- start the loop </li></ul><ul><li>LET total = total + x; </li></ul><ul><li>END LOOP; </li></ul><ul><li>END PROCEDURE; </li></ul>
  40. 40. LOOP Statement <ul><li>CREATE PROCEDURE facto(a int) </li></ul><ul><li>RETURNS int AS x, int AS factx; </li></ul><ul><li>DEFINE x,y, factx int; </li></ul><ul><li>DEFING total int; </li></ul><ul><li>LET total = 0; </li></ul><ul><li>LET x = 1; </li></ul><ul><li><<main_loop>> </li></ul><ul><li>WHILE (x <= a) LOOP -- start the loop </li></ul><ul><li>LET factx = 1; </li></ul><ul><li><<facto_loop>> </li></ul><ul><li>FOR y IN (1 TO x) LOOP </li></ul><ul><li>-- Abruptly stop at 10 </li></ul><ul><li>EXIT main_loop WHEN x = 10; </li></ul><ul><li>LET factx = factx * y; </li></ul><ul><li>END LOOP facto_loop; </li></ul><ul><li>RETURN x, factx WITH RESUME; </li></ul><ul><li>LET X = x+1; </li></ul><ul><li>END LOOP main_loop; </li></ul><ul><li>END PROCEDURE; </li></ul>
  41. 41. Stored Procedure Recompilation <ul><li>This is in 10.00.xC7 and 11.10.xC2 </li></ul><ul><ul><li>Wells Fargo situation </li></ul></ul><ul><li>-211 error: Cannot read system catalog sysprocplan </li></ul><ul><ul><li>Happens after altering the table or creating/dropping indices. </li></ul></ul><ul><ul><li>Also happens if you lock procedure plans when you UPDATE STATISTICS for procedures within BEGIN– COMMIT. </li></ul></ul><ul><li>Automatic Recompilation </li></ul><ul><ul><li>Automatically recognize and recompile the required statements </li></ul></ul><ul><ul><li>Write back the plan in a separate transaction so the locks are release. </li></ul></ul><ul><li>Automatically available. Nothing for applications to do. </li></ul>
  42. 42. XML Support <ul><li>XML Publishing functions </li></ul><ul><ul><li>Genxml </li></ul></ul><ul><ul><li>Genxmlelem </li></ul></ul><ul><ul><li>Genxmlschema </li></ul></ul><ul><ul><li>Genxmlquery </li></ul></ul><ul><ul><li>genxmlqueryhdr </li></ul></ul><ul><li>XPath Support </li></ul><ul><ul><li>Extract </li></ul></ul><ul><ul><li>ExtractValue </li></ul></ul><ul><ul><li>ExistsNode </li></ul></ul><ul><li>IDSXMLParse() function </li></ul>
  43. 43. XML Publishing UDR invoking the XSLT4C and XML4C libraries within IDS IDS Client IDS Client Extract functions extract() extracevalue() existsnode() idsXMLParse() genxml functions genxml() genxmlelem() genxmlqueryhdr() XSLT4C Processor XML4C Parser ICU Informix Dynamic Server XSLT4C and XML4C
  44. 44. XML Publishing functions <ul><li>SELECT </li></ul><ul><li>genxml( ROW(customer_num, fname, lname, address1, city, state, zipcode, phone), 'customer' ) FROM customer WHERE customer_num < 105; </li></ul><ul><li>genxml < customer customer_num=&quot;101&quot; fname=&quot;Ludwig &quot; lname=&quot;Pauli </li></ul><ul><li>&quot; company=&quot;All Sports Supplies &quot; address1=&quot;213 Erstwild Court &quot; city=&quot;Sunnyvale &quot; state=&quot;CA&quot; zipcode=&quot;94086&quot; phone=&quot;408-789-8075&quot;/> </li></ul><ul><li>< customer customer_num=&quot;102&quot; fname=&quot;Carole &quot; lname=&quot;Sadler </li></ul><ul><li>&quot; company=&quot;Sports Spot &quot; address1=&quot;785 Geary St &quot; city=&quot;San Francisco &quot; state=&quot;CA&quot; zipcode=&quot;94117&quot; phone=&quot;415-822-1289&quot;/> </li></ul><ul><li>< customer customer_num=&quot;103&quot; fname=&quot;Philip &quot; lname=&quot;Currie </li></ul><ul><li>&quot; company=&quot;Phil&apos;s Sports &quot; address1=&quot;654 Poplar </li></ul><ul><li>&quot; address2=&quot;P. O. Box 3498 &quot; city=&quot;Palo Alto &quot; state=&quot;CA&quot; zipcode=&quot;94303&quot; phone=&quot;415-328-4543&quot;/> </li></ul><ul><li>< customer customer_num=&quot;104&quot; fname=&quot;Anthony &quot; lname=&quot;Higgins </li></ul><ul><li>&quot; company=&quot;Play Ball! &quot; address1=&quot;East Shopping Cntr. &quot; address2=&quot;422 Bay Road &quot; city=&quot;Redwood City &quot; state=&quot;CA&quot; zipcode </li></ul><ul><li>=&quot;94026&quot; phone=&quot;415-368-1100&quot;/> </li></ul><ul><li>1 row(s) retrieved. </li></ul>
  45. 45. XML Publishing functions <ul><li>EXECUTE FUNCTION genxmlqueryhdr('manufact_set', </li></ul><ul><li>'SELECT * FROM manufact'); </li></ul><ul><li>(expression) <?xml version=&quot;1.0&quot; encoding=&quot;en_US.819&quot; ?> </li></ul><ul><li><xs:schema xmlns:xs=&quot;http://www.w3.org/2001/XMLSchema&quot;> </li></ul><ul><li><manufact_set> </li></ul><ul><li><row> </li></ul><ul><li><manu_code>SMT</manu_code> </li></ul><ul><li><manu_name>Smith </manu_name> </li></ul><ul><li><lead_time> 3</lead_time> </li></ul><ul><li></row> </li></ul><ul><li>... </li></ul>
  46. 46. XPath Support <ul><li>SELECT extract(booklist, '/bookstore/book[1]') </li></ul><ul><li>FROM books WHERE bookstore_id =1234; </li></ul><ul><li>(expression) <book category=&quot;COOKING&quot;> </li></ul><ul><li><title lang=&quot;en&quot;>Everyday Italian</title> </li></ul><ul><li><author>Giada De Laurentiis</author> </li></ul><ul><li><year>2005</year> </li></ul><ul><li><price>30.00</price> </li></ul><ul><li></book> </li></ul><ul><li>SELECT extractvalue(booklist, '/bookstore/book[last()]') </li></ul><ul><li>FROM books where bookstore_id =1234; </li></ul><ul><li>(expression) Learning XML Erik T. Ray 2003 39.95 </li></ul><ul><li>SELECT docid FROM books </li></ul><ul><li>WHERE existsnode(booklist, </li></ul><ul><li>'/bookstore/book[author=&quot;Kurt Cagle&quot;]/title') = 1 </li></ul><ul><li>AND bookstore_id =1234; </li></ul><ul><li>docid </li></ul><ul><li>1 </li></ul>
  47. 47. Q & A
  48. 48. Resources <ul><li>Infocentre </li></ul><ul><ul><li>http://publib.boulder.ibm.com/infocenter/idshelp/v111/index.jsp </li></ul></ul><ul><li>IDS v11 Redbook </li></ul><ul><ul><li>http://www.redbooks.ibm.com/abstracts/sg247465.html </li></ul></ul><ul><li>Keshava Murthy rkeshav@us.ibm.com </li></ul><ul><li>Thank You </li></ul>

×