User: kz      
Date: 2006/07/06 07:21:15

Modified:
   dba/connectivity/source/drivers/kab/KStatement.cxx

Log:
 INTEGRATION: CWS kabparam (1.3.6); FILE MERGED
 2006/07/03 07:49:31 ebischoff 1.3.6.2: Adding support for "Name LIKE ?" 
statements
 2006/06/29 08:15:23 ebischoff 1.3.6.1: #i66691# Support for parametrized 
queries in KDE address book connector

File Changes:

Directory: /dba/connectivity/source/drivers/kab/
================================================

File [changed]: KStatement.cxx
Url: 
http://dba.openoffice.org/source/browse/dba/connectivity/source/drivers/kab/KStatement.cxx?r1=1.3&r2=1.4
Delta lines:  +56 -21
---------------------
--- KStatement.cxx      20 Jun 2006 01:40:03 -0000      1.3
+++ KStatement.cxx      6 Jul 2006 14:21:13 -0000       1.4
@@ -94,6 +94,25 @@
 {
 }
 // 
-----------------------------------------------------------------------------
+void KabCommonStatement::disposing()
+{
+       KabCommonStatement_BASE::disposing();
+}
+// 
-----------------------------------------------------------------------------
+void KabCommonStatement::resetParameters() const 
throw(::com::sun::star::sdbc::SQLException)
+{
+       ::dbtools::throwGenericSQLException(
+               ::rtl::OUString::createFromAscii("Parameters can appear only in 
prepared statements."),
+               NULL);
+}
+// 
-----------------------------------------------------------------------------
+void KabCommonStatement::getNextParameter(::rtl::OUString &) const 
throw(::com::sun::star::sdbc::SQLException)
+{
+       ::dbtools::throwGenericSQLException(
+               ::rtl::OUString::createFromAscii("Parameters can appear only in 
prepared statements."),
+               NULL);
+}
+// 
-----------------------------------------------------------------------------
 KabCondition *KabCommonStatement::analyseWhereClause(const OSQLParseNode 
*pParseNode) const throw(SQLException)
 {
        if (pParseNode->count() == 3)
@@ -126,14 +145,21 @@
                         break;
                                }
                        }
-                       else if (SQL_ISRULE(pLeft, column_ref) && 
pRight->isToken())
+                       else if (SQL_ISRULE(pLeft, column_ref))
                        {
                                ::rtl::OUString sColumnName,
-                                               sTableRange,
-                                               sMatchString;
+                                               sTableRange;
 
                                m_aSQLIterator.getColumnRange(pLeft, 
sColumnName, sTableRange);
+
+                               if (pRight->isToken() || SQL_ISRULE(pRight, 
parameter))
+                               {
+                                       ::rtl::OUString sMatchString;
+
+                                       if (pRight->isToken())                  
                        // WHERE Name = 'Doe'
                                sMatchString = pRight->getTokenValue();
+                                       else if (SQL_ISRULE(pRight, parameter)) 
        // WHERE Name = ?
+                                               getNextParameter(sMatchString);
 
                                switch (pMiddle->getNodeType())
                                {
@@ -150,6 +176,7 @@
                                }
                        }
                }
+               }
                else if (SQL_ISRULE(pParseNode, search_condition))
                {
                        if (SQL_ISTOKEN(pMiddle, OR))
@@ -203,20 +230,27 @@
                }
                else if (SQL_ISRULE(pParseNode, like_predicate))
                {
-                       if (SQL_ISRULE(pLeft, column_ref) && 
pMiddleRight->getNodeType() == SQL_NODE_STRING)
+                       if (SQL_ISRULE(pLeft, column_ref))
                        {
                                ::rtl::OUString sColumnName,
-                                               sTableRange,
-                                               sMatchString;
+                                               sTableRange;
 
                                m_aSQLIterator.getColumnRange(pLeft, 
sColumnName, sTableRange);
+
+                               if (pMiddleRight->isToken() || 
SQL_ISRULE(pMiddleRight, parameter))
+                               {
+                                       ::rtl::OUString sMatchString;
+
+                                       if (pMiddleRight->isToken())            
                        // WHERE Name LIKE 'Sm%'
                                sMatchString = pMiddleRight->getTokenValue();
+                                       else if (SQL_ISRULE(pMiddleRight, 
parameter))   // WHERE Name LIKE ?
+                                               getNextParameter(sMatchString);
 
-                               // WHERE Name LIKE 'Sm%'
                                return new KabConditionSimilar(sColumnName, 
sMatchString);
                        }
                }
        }
+       }
        ::dbtools::throwGenericSQLException(
                ::rtl::OUString::createFromAscii("Syntax error or keyword not 
recognized."),
                NULL);
@@ -314,6 +348,7 @@
        {
                if (SQL_ISRULE(pParseNode, where_clause))
                {
+                       resetParameters();
                        pParseNode = pParseNode->getChild(1);
                        pCondition = analyseWhereClause(pParseNode);
                        if (pCondition->isAlwaysTrue())




---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to