Hi Noel, Please see my comments inline.
On Fri, Feb 24, 2012 at 8:20 AM, Noel Marquez Batista <[email protected]>wrote: > HI ALL, I´VE CREATED A CLIENT THAT ACCESS DIRECTLY INTO A DB USING JDBC > AND IT´S WORKS PERFECTLY, BY I WANT TO DO THE SAME WITH A DATA SERVICE IN > AS, AND IT IS NOT WORKING AT ALL. HERE IS THE QUERY: > > String parameter = "'100-047'"; > > Select * from schema.function_get_tree('table.id = 1 AND table.number = > '"+parameter+"'') > > SO WHEN I PUT THIS QUERY INTO THE SERVICE I SPPECIFIED THE PARAMETER IN > THIS WAY: > > Select * from schema.function_get_tree('table.id = 1 AND table.number = > :parameter') > If you carefully look at the aforementioned query, the parameter notation ":parameter" is specified within the string literal "table.id=1...." . If you define a named parameter in a dataservice query that will internally be mapped into a standard SQL query string containing "?" notations corresponding to the places in the query where the parameter value assignment is required. If we take your query as an example, it will be mapped into the following form if you try to define it the way you already did. Select * from schema.function_get_tree('table.id = 1 AND table.number = ?') Since you have specified the parameter within quotation marks, it will not be interpreted as an input field to which a value should be assigned even though you register an input parameter to assign values, thereby throwing those exceptions. Not only that, you also need to use proper string concatinations when you provide parameter values as a combination of string literals and parameters. Therefore, mentioned below is the proper way you should define your query in order to make it compatible with postgres. Select * from schema.function_get_tree('table.id = 1 AND table.number =' || :parameter) AND THIS IS THE ERROR WHEN I TRY IT: > > TID: [0] [WSO2 Application Server] [2012-02-23 15:50:34,777] ERROR > {org.apache.axiom.om.impl.llom.OMSourcedElementImpl} - Could not get parser > from data source for element {http://empresa.co}Grupos > {org.apache.axiom.om.impl.llom.OMSourcedElementImpl}javax.xml.stream.XMLStreamException: > DS Fault Message: Error in 'SQLQuery.processNormalQuery' DS Code: > DATABASE_ERROR Source Data Service:- Name: PregradoWS Location: > /PregradoWS.dbs Description: N/A Default Namespace: http://empresa.coCurrent > Request Name: ObtenerGrupoDadoIdGrupo Current Params: > {parameter="'100-047'"} Nested Exception:- DS Fault Message: Error in > 'createProcessedPreparedStatement' DS Code: UNKNOWN_ERROR Nested > Exception:- org.postgresql.util.PSQLException: The column index is out of > range: 1, number of columns: 0. at > org.wso2.carbon.dataservices.core.engine.DSOMDataSource.execute(DSOMDataSource.java:105) > at > org.wso2.carbon.dataservices.core.engine.DSOMDataSource.serialize(DSOMDataSource.java:110) > at > org.wso2.carbon.dataservices.core.engine.DSOMDataSource.getReader(DSOMDataSource.java:116) > at > org.apache.axiom.om.impl.llom.OMSourcedElementImpl.getDirectReader(OMSourcedElementImpl.java:225) > at > org.apache.axiom.om.impl.llom.OMSourcedElementImpl.forceExpand(OMSourcedElementImpl.java:254) > at > org.apache.axiom.om.impl.llom.OMSourcedElementImpl.getFirstOMChild(OMSourcedElementImpl.java:867) > at > > > HELP, thanks. > > > Fin a la injusticia, LIBERTAD AHORA A NUESTROS CINCO COMPATRIOTAS QUE SE > ENCUENTRAN INJUSTAMENTE EN PRISIONES DE LOS EEUU! > http://www.antiterroristas.cu > http://justiciaparaloscinco.wordpress.com > _______________________________________________ > Carbon-dev mailing list > [email protected] > http://mail.wso2.org/cgi-bin/mailman/listinfo/carbon-dev > -- Prabath Abeysekara Software Engineer WSO2 Inc. Email: [email protected] <[email protected]> Mobile: +94774171471 <http://harshana05.blogspot.com/>
_______________________________________________ Carbon-dev mailing list [email protected] http://mail.wso2.org/cgi-bin/mailman/listinfo/carbon-dev
