How to use count sql statement?

i've never used the count function and i'm not sure how to use it to print it onto a html page...my code is below...
<%
String tot = (String)session.getAttribute("total");
int total = Integer.parseInt(tot);
Class.forName("org.postgresql.Driver");
// create connection url
String URL2 = "jdbc:postgresql://dbhost/ug59sxn";
// pass database parameters to JDBC driver
Connection Conn2 = DriverManager.getConnection(URL2, "ug59sxn", "hupeswop");
// query statement
Statement SQLStatement2 = Conn2.createStatement();
// generate query
String Query2 = "SELECT COUNT(*) FROM userteam WHERE total > '"+total+"'";
// get result code
ResultSet SQLResult2 = SQLStatement2.executeQuery(Query2);
int position = (int)SQLResult2 + 1;
%>
<TD valign=top>
<P align=center><FONT size=+1>Welcome <%= session.getAttribute("fName") %> <%= session.getAttribute("surname") %><BR>
Your Team, <%= session.getAttribute("teamname") %>, are currently lying in position <FONT color=red><% out.println(position) %></font>, with <FONT color=red><%= session.getAttribute("total") %></font> points.<BR>
</FONT></P>
<P align=justify>      Use the shorcuts on the left to visit different sections of the game.
You can change your squad around to prepare for forthcoming games (fixtures can be found in the statistics section),
transfer a player in to your squad to add some depth or replace injured members, or perhaps browse the statistics section to see how your team is doing in the FFL table.</P>
<HR>
<%
SQLResult2.close();
SQLStatement2.close();
Conn2.close();
%>
i get the following errors:
type Exception report
message Internal Server Error
description The server encountered an internal error (Internal Server Error) that prevented it from fulfilling this request.
exception
org.apache.jasper.JasperException: Unable to compile class for JSPNote: sun.tools.javac.Main has been deprecated.
An error occured between lines: 62 and 84 in the jsp file: /main2.jsp
Generated servlet error:
/home/students/ug/ug59sxn/servlets-local/work/localhost/myapp/main2$jsp.java:80: Invalid cast from java.sql.ResultSet to int.
int position = (int)SQLResult2 + 1;
^
An error occurred at line: 88 in the jsp file: /main2.jsp
Generated servlet error:
/home/students/ug/ug59sxn/servlets-local/work/localhost/myapp/main2$jsp.java:108: Invalid type expression.
out.println(position)
^
An error occurred at line: 88 in the jsp file: /main2.jsp
Generated servlet error:
/home/students/ug/ug59sxn/servlets-local/work/localhost/myapp/main2$jsp.java:111: Invalid declaration.
out.write("</font>, with <FONT color=red>");
^
3 errors, 1 warning
if anyone can help me out, please do so..thanx in advance...

You cannot cast a ResultSet object (or any other object for that matter) to a primitive (such as an int)
Replace the following line of code:
int position = (int)SQLResult2 + 1;with this:
int position = 0;
if(SQLResult2.next())
  position = SQLResult2.getInt(1) + 1;
}Additionally I noticed that you have put single quotes around total in the following line:
String Query2 = "SELECT COUNT(*) FROM userteam WHERE total > '"+total+"'";Are you sure that the total column in the userteam table is of string type? If not, you don't need the single quotes.

Similar Messages

  • How to use Native SQL statement in JDBC receiver interface

    Dear All,
    Can any one please help us in using Native SQL statement in a JDBC receiver channel. The reason why I need to use Native SQL statement instead of standard XML structure is that I need to execute a dynamic SQL query in third party database system lke:-
    Select Field1 Field2 from TABLE Where Field3 like "%Name'
    I expect the the response in the form of XML file which I can pick up using synchornous interface as mentioned on help.sap.com:-
    http://help.sap.com/saphelp_nw04/helpdata/en/64/ce4e886334ec4ea7c2712e11cc567c/frameset.htm
    http://help.sap.com/saphelp_nw04/helpdata/en/64/ce4e886334ec4ea7c2712e11cc567c/frameset.htm
    The value for %Name can change dynamically according to the transaction and hence cannot be inluded as a KEY element in standard XLM structure,
    Hence I need to know:-
    1. What message mapping I should use in case if I have to use Native SQL statement.
    2.What operation mapping I should use in case if I have to use Native SQL statement.
    If guess correclty I may have to use Java mapping to do the above activities. Hence I want to know
    3 .How do to go about it to do the Java mapping.
    Thanks
    Ameet

    >
    Ameet Deshpande wrote:
    > Dear All,
    >
    > Can any one please help us in using Native SQL statement in a JDBC receiver channel. The reason why I need to use Native SQL statement instead of standard XML structure is that I need to execute a dynamic SQL query in third party database system lke:-
    >
    > "
    > Select Field1 Field2 from TABLE Where Field3 like "%Name'
    > "
    > I expect the the response in the form of XML file which I can pick up using synchornous interface as mentioned on help.sap.com:-
    >
    > http://help.sap.com/saphelp_nw04/helpdata/en/64/ce4e886334ec4ea7c2712e11cc567c/frameset.htm
    > http://help.sap.com/saphelp_nw04/helpdata/en/64/ce4e886334ec4ea7c2712e11cc567c/frameset.htm
    >
    > The value for %Name can change dynamically according to the transaction and hence cannot be inluded as a KEY element in standard XLM structure,
    >
    > Hence I need to know:-
    >
    > 1. What message mapping I should use in case if I have to use Native SQL statement.
    > 2.What operation mapping I should use in case if I have to use Native SQL statement.
    > If guess correclty I may have to use Java mapping to do the above activities. Hence I want to know
    > 3 .How do to go about it to do the Java mapping.
    >
    > Thanks
    > Ameet
    You can use a stored procedure, and call it from jdbc receiver adapter.
    I also solve this issue, with a DBLookup in message mapping. You can refer to my blog, and this usefull 3d:
    http://simonlesflex.wordpress.com/2010/12/07/pi-oracle-dblookup/
    /people/alessandro.guarneri/blog/2006/03/27/sap-xi-lookup-api-the-killer
    /people/siva.maranani/blog/2005/08/23/lookup146s-in-xi-made-simpler

  • How to use  alternative SQL  statements  in  EJB

    I have a probelm to use alternative sql statements in EJB,
    could any one sugg on this topic,
    Thanks in advance.

    Please explain your problem better. Really can't figure what you are trying to do.....
    choosing which sql statement to use at runtime
    or creating dynamic sql statement at runtime
    which??
    Regards

  • How to use alternative sql statements in ejb 2.0

    hi
    i have written the alternative sql statement in persistence.xml like  "select max(modifieddate) from tmp_dlv_mgmt".
    i am getting the error
    java.rmi.RemoteException: com.sap.engine.services.ejb.exceptions.BaseRemoteException: Exception in method in.kgs.bean.Dlv_EntityHomeImpl0.findMaxModifiedByUserID(java.lang.String).
         at in.kgs.bean.Dlv_EntityHomeImpl0.findMaxModifiedByUserID(Dlv_EntityHomeImpl0.java:1477)
         at in.kgs.bean.Dlv_EntityHomeImpl0p4_Skel.dispatch(Dlv_EntityHomeImpl0p4_Skel.java:387)
         at com.sap.engine.services.rmi_p4.DispatchImpl._runInternal(DispatchImpl.java:320)
         at com.sap.engine.services.rmi_p4.DispatchImpl._run(DispatchImpl.java:198)
         at com.sap.engine.services.rmi_p4.server.P4SessionProcessor.request(P4SessionProcessor.java:129)
         at com.sap.engine.core.service630.context.cluster.session.ApplicationSessionMessageListener.process(ApplicationSessionMessageListener.java:33)
         at com.sap.engine.core.cluster.impl6.session.MessageRunner.run(MessageRunner.java:41)
         at com.sap.engine.core.thread.impl3.ActionObject.run(ActionObject.java:37)
         at java.security.AccessController.doPrivileged(Native Method)
         at com.sap.engine.core.thread.impl3.SingleThread.execute(SingleThread.java:100)
         at com.sap.engine.core.thread.impl3.SingleThread.run(SingleThread.java:170)
    Caused by: com.sap.engine.services.ejb.exceptions.BaseEJBException: Exception in method Dlv_EntityBean0.FindMaxModifiedByUserID(java.lang.String).
         at in.kgs.bean.Dlv_EntityBean0PM.ejbFindMaxModifiedByUserID(Dlv_EntityBean0PM.java:900)
         at in.kgs.bean.Dlv_EntityHomeImpl0.findMaxModifiedByUserID(Dlv_EntityHomeImpl0.java:1449)
         ... 10 more
    Caused by: com.sap.sql.log.OpenSQLException: A column with name DLVNO is unknown.
         at com.sap.sql.log.Syslog.createAndLogOpenSQLException(Syslog.java:85)
         at com.sap.sql.log.Syslog.createAndLogOpenSQLException(Syslog.java:124)
         at com.sap.sql.jdbc.common.CommonResultSet.findColumn(CommonResultSet.java:643)
         at com.sap.sql.jdbc.common.CommonResultSet.getLong(CommonResultSet.java:382)
         at in.kgs.bean.Dlv_EntityBean0Persistent.extractPK(Dlv_EntityBean0Persistent.java:213)
         at in.kgs.bean.Dlv_EntityBean0Persistent.extractPrimaryKey(Dlv_EntityBean0Persistent.java:206)
         at com.sap.engine.services.ejb.entity.finder.FindPKCollection.extractSinglePK(FindPKCollection.java:152)
         at com.sap.engine.services.ejb.entity.finder.FindPKCollection.extractAndAddSinglePK(FindPKCollection.java:167)
         at com.sap.engine.services.ejb.entity.finder.FindPKCollection.onlyLoadAllElementsFromRS(FindPKCollection.java:146)
         at com.sap.engine.services.ejb.entity.finder.FindPKCollection.forceLoadingOfAllElementsFromRS(FindPKCollection.java:128)
         at com.sap.engine.services.ejb.entity.finder.FindPKCollection.<init>(FindPKCollection.java:99)
         at in.kgs.bean.Dlv_EntityBean0PM.ejbFindMaxModifiedByUserID(Dlv_EntityBean0PM.java:896)
         ... 11 more
    ; nested exception is:
         javax.ejb.EJBException: com.sap.engine.services.ejb.exceptions.BaseEJBException: Exception in method Dlv_EntityBean0.FindMaxModifiedByUserID(java.lang.String).
         at in.kgs.bean.Dlv_EntityBean0PM.ejbFindMaxModifiedByUserID(Dlv_EntityBean0PM.java:900)
         at in.kgs.bean.Dlv_EntityHomeImpl0.findMaxModifiedByUserID(Dlv_EntityHomeImpl0.java:1449)
         at in.kgs.bean.Dlv_EntityHomeImpl0p4_Skel.dispatch(Dlv_EntityHomeImpl0p4_Skel.java:387)
         at com.sap.engine.services.rmi_p4.DispatchImpl._runInternal(DispatchImpl.java:320)
         at com.sap.engine.services.rmi_p4.DispatchImpl._run(DispatchImpl.java:198)
         at com.sap.engine.services.rmi_p4.server.P4SessionProcessor.request(P4SessionProcessor.java:129)
         at com.sap.engine.core.service630.context.cluster.session.ApplicationSessionMessageListener.process(ApplicationSessionMessageListener.java:33)
         at com.sap.engine.core.cluster.impl6.session.MessageRunner.run(MessageRunner.java:41)
         at com.sap.engine.core.thread.impl3.ActionObject.run(ActionObject.java:37)
         at java.security.AccessController.doPrivileged(Native Method)
         at com.sap.engine.core.thread.impl3.SingleThread.execute(SingleThread.java:100)
         at com.sap.engine.core.thread.impl3.SingleThread.run(SingleThread.java:170)
    Caused by: com.sap.sql.log.OpenSQLException: A column with name DLVNO is unknown.
         at com.sap.sql.log.Syslog.createAndLogOpenSQLException(Syslog.java:85)
         at com.sap.sql.log.Syslog.createAndLogOpenSQLException(Syslog.java:124)
         at com.sap.sql.jdbc.common.CommonResultSet.findColumn(CommonResultSet.java:643)
         at com.sap.sql.jdbc.common.CommonResultSet.getLong(CommonResultSet.java:382)
         at in.kgs.bean.Dlv_EntityBean0Persistent.extractPK(Dlv_EntityBean0Persistent.java:213)
         at in.kgs.bean.Dlv_EntityBean0Persistent.extractPrimaryKey(Dlv_EntityBean0Persistent.java:206)
         at com.sap.engine.services.ejb.entity.finder.FindPKCollection.extractSinglePK(FindPKCollection.java:152)
         at com.sap.engine.services.ejb.entity.finder.FindPKCollection.extractAndAddSinglePK(FindPKCollection.java:167)
         at com.sap.engine.services.ejb.entity.finder.FindPKCollection.onlyLoadAllElementsFromRS(FindPKCollection.java:146)
         at com.sap.engine.services.ejb.entity.finder.FindPKCollection.forceLoadingOfAllElementsFromRS(FindPKCollection.java:128)
         at com.sap.engine.services.ejb.entity.finder.FindPKCollection.<init>(FindPKCollection.java:99)
         at in.kgs.bean.Dlv_EntityBean0PM.ejbFindMaxModifiedByUserID(Dlv_EntityBean0PM.java:896)
         ... 11 more
    com.sap.sql.log.OpenSQLException: A column with name DLVNO is unknown.
         at com.sap.sql.log.Syslog.createAndLogOpenSQLException(Syslog.java:85)
         at com.sap.sql.log.Syslog.createAndLogOpenSQLException(Syslog.java:124)
         at com.sap.sql.jdbc.common.CommonResultSet.findColumn(CommonResultSet.java:643)
         at com.sap.sql.jdbc.common.CommonResultSet.getLong(CommonResultSet.java:382)
         at in.kgs.bean.Dlv_EntityBean0Persistent.extractPK(Dlv_EntityBean0Persistent.java:213)
         at in.kgs.bean.Dlv_EntityBean0Persistent.extractPrimaryKey(Dlv_EntityBean0Persistent.java:206)
         at com.sap.engine.services.ejb.entity.finder.FindPKCollection.extractSinglePK(FindPKCollection.java:152)
         at com.sap.engine.services.ejb.entity.finder.FindPKCollection.extractAndAddSinglePK(FindPKCollection.java:167)
         at com.sap.engine.services.ejb.entity.finder.FindPKCollection.onlyLoadAllElementsFromRS(FindPKCollection.java:146)
         at com.sap.engine.services.ejb.entity.finder.FindPKCollection.forceLoadingOfAllElementsFromRS(FindPKCollection.java:128)
         at com.sap.engine.services.ejb.entity.finder.FindPKCollection.<init>(FindPKCollection.java:99)
         at in.kgs.bean.Dlv_EntityBean0PM.ejbFindMaxModifiedByUserID(Dlv_EntityBean0PM.java:896)
         at in.kgs.bean.Dlv_EntityHomeImpl0.findMaxModifiedByUserID(Dlv_EntityHomeImpl0.java:1449)
         at in.kgs.bean.Dlv_EntityHomeImpl0p4_Skel.dispatch(Dlv_EntityHomeImpl0p4_Skel.java:387)
         at com.sap.engine.services.rmi_p4.DispatchImpl._runInternal(DispatchImpl.java:320)
         at com.sap.engine.services.rmi_p4.DispatchImpl._run(DispatchImpl.java:198)
         at com.sap.engine.services.rmi_p4.server.P4SessionProcessor.request(P4SessionProcessor.java:129)
         at com.sap.engine.core.service630.context.cluster.session.ApplicationSessionMessageListener.process(ApplicationSessionMessageListener.java:33)
         at com.sap.engine.core.cluster.impl6.session.MessageRunner.run(MessageRunner.java:41)
         at com.sap.engine.core.thread.impl3.ActionObject.run(ActionObject.java:37)
         at java.security.AccessController.doPrivileged(Native Method)
         at com.sap.engine.core.thread.impl3.SingleThread.execute(SingleThread.java:100)
         at com.sap.engine.core.thread.impl3.SingleThread.run(SingleThread.java:170)
         at com.sap.engine.services.ejb.exceptions.BaseRemoteException.writeReplace(BaseRemoteException.java:276)
         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
         at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
         at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
         at java.lang.reflect.Method.invoke(Method.java:324)
         at java.io.ObjectStreamClass.invokeWriteReplace(ObjectStreamClass.java:896)
         at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1011)
         at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:278)
         at com.sap.engine.services.rmi_p4.DispatchImpl.throwException(DispatchImpl.java:144)
         at com.sap.engine.services.rmi_p4.DispatchImpl._runInternal(DispatchImpl.java:322)
         at com.sap.engine.services.rmi_p4.DispatchImpl._run(DispatchImpl.java:198)
         at com.sap.engine.services.rmi_p4.server.P4SessionProcessor.request(P4SessionProcessor.java:129)
         at com.sap.engine.core.service630.context.cluster.session.ApplicationSessionMessageListener.process(ApplicationSessionMessageListener.java:33)
         at com.sap.engine.core.cluster.impl6.session.MessageRunner.run(MessageRunner.java:41)
         at com.sap.engine.core.thread.impl3.ActionObject.run(ActionObject.java:37)
         at java.security.AccessController.doPrivileged(Native Method)
         at com.sap.engine.core.thread.impl3.SingleThread.execute(SingleThread.java:100)
         at com.sap.engine.core.thread.impl3.SingleThread.run(SingleThread.java:170)
    Caused by: javax.ejb.EJBException: com.sap.engine.services.ejb.exceptions.BaseEJBException: Exception in method Dlv_EntityBean0.FindMaxModifiedByUserID(java.lang.String).
         at in.kgs.bean.Dlv_EntityBean0PM.ejbFindMaxModifiedByUserID(Dlv_EntityBean0PM.java:900)
         at in.kgs.bean.Dlv_EntityHomeImpl0.findMaxModifiedByUserID(Dlv_EntityHomeImpl0.java:1449)
         at in.kgs.bean.Dlv_EntityHomeImpl0p4_Skel.dispatch(Dlv_EntityHomeImpl0p4_Skel.java:387)
         at com.sap.engine.services.rmi_p4.DispatchImpl._runInternal(DispatchImpl.java:320)
         at com.sap.engine.services.rmi_p4.DispatchImpl._run(DispatchImpl.java:198)
         at com.sap.engine.services.rmi_p4.server.P4SessionProcessor.request(P4SessionProcessor.java:129)
         at com.sap.engine.core.service630.context.cluster.session.ApplicationSessionMessageListener.process(ApplicationSessionMessageListener.java:33)
         at com.sap.engine.core.cluster.impl6.session.MessageRunner.run(MessageRunner.java:41)
         at com.sap.engine.core.thread.impl3.ActionObject.run(ActionObject.java:37)
         at java.security.AccessController.doPrivileged(Native Method)
         at com.sap.engine.core.thread.impl3.SingleThread.execute(SingleThread.java:100)
         at com.sap.engine.core.thread.impl3.SingleThread.run(SingleThread.java:170)
    Caused by: com.sap.sql.log.OpenSQLException: A column with name DLVNO is unknown.
         at com.sap.sql.log.Syslog.createAndLogOpenSQLException(Syslog.java:85)
         at com.sap.sql.log.Syslog.createAndLogOpenSQLException(Syslog.java:124)
         at com.sap.sql.jdbc.common.CommonResultSet.findColumn(CommonResultSet.java:643)
         at com.sap.sql.jdbc.common.CommonResultSet.getLong(CommonResultSet.java:382)
         at in.kgs.bean.Dlv_EntityBean0Persistent.extractPK(Dlv_EntityBean0Persistent.java:213)
         at in.kgs.bean.Dlv_EntityBean0Persistent.extractPrimaryKey(Dlv_EntityBean0Persistent.java:206)
         at com.sap.engine.services.ejb.entity.finder.FindPKCollection.extractSinglePK(FindPKCollection.java:152)
         at com.sap.engine.services.ejb.entity.finder.FindPKCollection.extractAndAddSinglePK(FindPKCollection.java:167)
         at com.sap.engine.services.ejb.entity.finder.FindPKCollection.onlyLoadAllElementsFromRS(FindPKCollection.java:146)
         at com.sap.engine.services.ejb.entity.finder.FindPKCollection.forceLoadingOfAllElementsFromRS(FindPKCollection.java:128)
         at com.sap.engine.services.ejb.entity.finder.FindPKCollection.<init>(FindPKCollection.java:99)
         at in.kgs.bean.Dlv_EntityBean0PM.ejbFindMaxModifiedByUserID(Dlv_EntityBean0PM.java:896)
         ... 11 more
    com.sap.sql.log.OpenSQLException: A column with name DLVNO is unknown.
         at com.sap.sql.log.Syslog.createAndLogOpenSQLException(Syslog.java:85)
         at com.sap.sql.log.Syslog.createAndLogOpenSQLException(Syslog.java:124)
         at com.sap.sql.jdbc.common.CommonResultSet.findColumn(CommonResultSet.java:643)
         at com.sap.sql.jdbc.common.CommonResultSet.getLong(CommonResultSet.java:382)
         at in.kgs.bean.Dlv_EntityBean0Persistent.extractPK(Dlv_EntityBean0Persistent.java:213)
         at in.kgs.bean.Dlv_EntityBean0Persistent.extractPrimaryKey(Dlv_EntityBean0Persistent.java:206)
         at com.sap.engine.services.ejb.entity.finder.FindPKCollection.extractSinglePK(FindPKCollection.java:152)
         at com.sap.engine.services.ejb.entity.finder.FindPKCollection.extractAndAddSinglePK(FindPKCollection.java:167)
         at com.sap.engine.services.ejb.entity.finder.FindPKCollection.onlyLoadAllElementsFromRS(FindPKCollection.java:146)
         at com.sap.engine.services.ejb.entity.finder.FindPKCollection.forceLoadingOfAllElementsFromRS(FindPKCollection.java:128)
         at com.sap.engine.services.ejb.entity.finder.FindPKCollection.<init>(FindPKCollection.java:99)
         at in.kgs.bean.Dlv_EntityBean0PM.ejbFindMaxModifiedByUserID(Dlv_EntityBean0PM.java:896)
         at in.kgs.bean.Dlv_EntityHomeImpl0.findMaxModifiedByUserID(Dlv_EntityHomeImpl0.java:1449)
         at in.kgs.bean.Dlv_EntityHomeImpl0p4_Skel.dispatch(Dlv_EntityHomeImpl0p4_Skel.java:387)
         at com.sap.engine.services.rmi_p4.DispatchImpl._runInternal(DispatchImpl.java:320)
         at com.sap.engine.services.rmi_p4.DispatchImpl._run(DispatchImpl.java:198)
         at com.sap.engine.services.rmi_p4.server.P4SessionProcessor.request(P4SessionProcessor.java:129)
         at com.sap.engine.core.service630.context.cluster.session.ApplicationSessionMessageListener.process(ApplicationSessionMessageListener.java:33)
         at com.sap.engine.core.cluster.impl6.session.MessageRunner.run(MessageRunner.java:41)
         at com.sap.engine.core.thread.impl3.ActionObject.run(ActionObject.java:37)
         at java.security.AccessController.doPrivileged(Native Method)
         at com.sap.engine.core.thread.impl3.SingleThread.execute(SingleThread.java:100)
         at com.sap.engine.core.thread.impl3.SingleThread.run(SingleThread.java:170)
         at com.sap.engine.services.ejb.exceptions.BaseEJBException.writeReplace(BaseEJBException.java:274)
         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
         at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
         at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
         at java.lang.reflect.Method.invoke(Method.java:324)
         at java.io.ObjectStreamClass.invokeWriteReplace(ObjectStreamClass.java:896)
         at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1011)
         at java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java:1332)
         at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1304)
         at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1247)
         at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1052)
         ... 11 more

    Hi Guruvulu,
    >
    Guruvulu Bojja wrote:
    > i have written the alternative sql statement in persistence.xml like  "select max(modifieddate) from tmp_dlv_mgmt".
    Could you please explain in detail - what you have done and what you want to achieve? You can also post the code of your persistence.xml for reference...
    Regards,
    Yordan

  • Hi experts, how to use open sql to read data from one " maintenance view"?

    i want to use this part of data within report ,so how to use open sql statement to read data from one " maintenance view"?

    Hi
    You can't use OPEN SQl statements to fetch data from maintenance view
    You have to use only Database views
    see the different types of views and the difference
    The followings are different types of views:
    - Database View (SE11)
    Database views are implement an inner join, that is, only records of the primary table (selected via the join operation) for which the corresponding records of the secondary tables also exist are fetched. Inconsistencies between primary and secondary table could, therefore, lead to a reduced selection set.
    In database views, the join conditions can be formulated using equality relationships between any base fields. In the other types of view, they must be taken from existing foreign keys. That is, tables can only be collected in a maintenance or help view if they are linked to one another via foreign keys.
    - Help View ( SE54)
    Help views are used to output additional information when the online help system is called.
    When the F4 button is pressed for a screen field, a check is first made on whether a matchcode is defined for this field. If this is not the case, the help view is displayed in which the check table of the field is the primary table. Thus, for each table no more than one help view can be created, that is, a table can only be primary table in at most one help view.
    - Projection View
    Projection views are used to suppress or mask certain fields in a table (projection), thus minimizing the number of interfaces. This means that only the data that is actually required is exchanged when the database is accessed.
    A projection view can draw upon only one table. Selection conditions cannot be specified for projection views.
    - Maintenance View ( SE54 )
    Maintenance views enable a business-oriented approach to looking at data, while at the same time, making it possible to maintain the data involved. Data from several tables can be summarized in a maintenance view and maintained collectively via this view. That is, the data is entered via the view and then distributed to the underlying tables by the system.
    Please have a look at below link. It will help you.
    http://help.sap.com/saphelp_nw04/helpdata/en/cf/21ed06446011d189700000e8322d00/frameset.htm
    for more detailed info look on:
    http://www.sap-img.com/abap/what-is-the-different-types-and-usage-of-views.htm
    https://www.sdn.sap.com/irj/sdn/wiki?path=/display/home/abap+dictionary&
    Reward points for useful Answers
    Regards
    Anji

  • How can i use one SQL statement to solve problem?

    How can i use one SQL statement to solve the question below?
    For a Table named A, there is a column named F(char type).
    Now select all the records where F like '%00' and update their F value to '%01'
    Just one SQL statement.Do not use PL/SQL block.
    How to do that?
    Thanks.

    What is the data volume for this table?
    Do you expect lots of rows to have '%00' as their value?
    Following two statements come to mind. Other experts would be able to provide better alternatives:
    If you have index on SUBSTR(f, 2):
    UPDATE A
    SET    f = SUBSTR(f,
                      1,
                      length(f) - 2) || '01'
    WHERE  substr(f,
                  -2) = '00';If most of the rows have pattern '%00':
    UPDATE A
    SET    f = SUBSTR(f,
                      1,
                      length(f) - 2) ||
               DECODE(SUBSTR(f,
                             -2),
                      '00',
                      '01',
                      SUBSTR(f,
                             -2));

  • How to Use Dynamic SQL

    Can anybody please send me a small program on How to Use Dynamic SQL.
    How to execute and run give details.
    Thanks
    null

    You can certainly use the INTO (and USING) clauses of EXECUTE IMMEDIATE to pass in and return data, i.e.
    EXECUTE IMMEDIATE sqlStmt
      USING variable1, variable2
       INTO output1, output2The more complex the statement, however, the more appropriate DBMS_SQL is. DBMS_SQL also has the potential to allow you to use bind variables rather than reparsing the statement many times.
    Justin
    Distributed Database Consulting, Inc.
    http://www.ddbcinc.com/askDDBC

  • How to run a SQL statement which is stored inside an SQL Table

    Hello,
    If anyone please help me with the following problem I would be forever grateful
    I have an SQL statement which is stored inside a certain SQL table, I want to use that SQL statement inside my PL/SQL procedure.
    Was thinking of a simple solution of obtaining the SQL statement into an array and then execute it, yet how could I do so exactly with PL/SQL? I've only started playing around with PL/SQL in the last few days.
    Thanks in advance!
    This is how it looks like more or less:
    Displaying result for:
    SELECT TRIM(OBJ_VALU_TXT)
    FROM   OBJ_VALU_DOC
    WHERE  OBJECT_TYPE  = 'FLD'
      AND  OBJECT_CODE  = 15443
      AND  OBJ_VALU_CD  = 'ACR'
    ORDER BYDOC_SEQ_NO
    00001                                                            
    SELECT
    VALUE(MAX(RECEIPT_NO) + 1, :OUT-COMP-FACTOR)
    FROM RECEIPT
    WHERE (RECEIPT_NO BETWEEN
    :OUT-COMP-FACTOR AND :OUT-TO-NUMBER) OR
    (RECEIPT_NO > :OUT-COMP-FACTOR AND
    :OUT-TO-NUMBER = 0)

    Here's a demo of your requirement.
    create table t ( col1 varchar2(200));
    table created
    insert into t values('select * from dual');
    1 row inserted
    declare
    v_col varchar2(200);
    v_val varchar2(200);
    begin
    select col1 into v_col from t;
    execute immediate v_col into v_val;
    dbms_output.put_line(v_val);
    end;
    X
    Using into clause, you can use as many variables as required. But the basic approach reamins the same.
    But storing SQL in DB is not an efficient design.
    Ishan

  • How to use Count with Date Parameters

    Hello,
    I am having issues using the Count() function in conjunction with date parameters.
    This is a Siebel report and in my report I have 2 date parameters(From Date, To Date). In a nutshell I am basically trying to count Opportunities that has a start date within the given date period. However I don't see a reasonable way to put my date parameters within the Count() function. The reason being is that I need to have a huge chunk of code to convert the dates into a common format that can be compared, and it won't even fit within the code block in my rtf template. I am not even sure how to put multiple conditional statements inside a Count() function since all the examples I have seen are very simple.
    Anyone have a suggestion on how to use Count() with date parameters?
    Thanks.

    Any chance you can get the date formats in the correct format from siebel?
    I don't know Siebel - so I can't help you with that. If you get the correct format it is just
    <?count(row[(FromDate>=date) and  (date<=ToDate))?>
    Otherwise the approach would probably need to use string function to get year/monthd/day from the date
    and store it into a varialbe and compare later the same way
    <?variable@incontext:from; ....?>
    <?variable@incontext:to; ...?>
    <?count(row[($from>=date) and  (date<=$to))?>
    Potentially you can use the date functions such as xdofx:to_date to do the conversion
    [http://download.oracle.com/docs/cd/E12844_01/doc/bip.1013/e12187/T421739T481158.htm]
    But I am not sure if they are available in your siebel implementation.
    Hope that helps

  • How to put the SQL-statement returned value into the field (as a default)

    Hi,
    I am using Developer/2000 (Forms Designer) under windows 98.
    Please tell me how to put the SQL-statement value (as a default value) into the field before enter-query mode. Noted that I have tried the following ways but still some problems:-
    1) Place the SQL-statement into PRE_QUERY trigger in the form/block level.
    There is a message box which ask 'Do you want to save the changes?'.
    2) Place the SQL-statement before execute enter_query. There is still a
    message box which ask 'Do you want to save the changes?'.
    Any hints? Thanks. Urgent.

    solved it!
    1) Suppress DEFAULT save message
    if form_failure then
    raise form_trigger_failure;
    end if;
    2) Place the default value before enter-query.
    Ref: Title='Default value in query field in ENTER_QUERY mode' in designer forum by CVZ
    form level trigger
    ============
    WHEN-NEW-ITEM-INSTANCE
    =======================
    if :system.mode = 'ENTER-QUERY' then
    :block.item := 'default waarde';
    end if;
    3) Suppress the changes whenever leaving the default field.
    if :block.item is null then
    -- assign statement
    end if;

  • How to use an if statement in javascript code

    Hello,
    I have a batch processing script to search for text "employee signature" on each page in a multiple page file and to then list in the console any pages that do not have the "Employee Signature" text included.
    The script is not yet functional as an if statement needs to be included.
    Can anyone please advise how to use an if statement in javascript code?
    var numpages = this.numPages;
    for (var i=0; i < numpages; i++)
    search.query("Employee Signature", "ActiveDoc");
    console.println('Pages that do not include an employee signature: ' + this.pageNum +' ');
    Any assistance will be most appreciated.

    Thank you very much for your assistance try.
    I have modified the code as suggested and the page numbers are now listing correctly, thank you, but....................,
    The console  lists every page as having an "employee signature" when there are pages in the document that do not have an employee signature.
    The code (revised as follows) is not processing the "getPageNthWord part of the statement" in the console report?
    Can you please advise where the code needs reworking?
    var ckWords; // word pair to test
    var bFound = false; // logical status of found words
    // loop through pages
    for (var i = 0; i < this.numPages; i++ ) {
       bFound = false; // set found flag to false
       numWords = this.getPageNumWords(i); // number of words on page
       // loop through the words on page
       for (var j = 0; j < numWords; j++) {
          // get word pair to test
          ckWords = this.getPageNthWord(i, j) + ' ' + this.getPageNthWord(i, j + 1); // test words
          // check to see if word pair is 'Employee' string is present
          if ( ckWord == "Employee") {
             bFound = true; // indicate found logical value
             console.println('Pages that includes an employee signature: ' + (i + 1) +' ');
             break; // no need to further test for this page
          } // end Employee Signature
       } // end word loop
       // test to see if words not found
       if(bFound == false) {
             console.println('Pages that do include an employee signature: ' + (i + 1) +' ');
        } // end not found on page  
    } // end page loop
    Thank you

  • How to use the Include Statement in the BADI

    Dear All,
            I am trying to implement the BADI. So i need to use the Include in the BADI.
    How to use the Include statement in the BADI. I cant able to use it in the Public, Private and protected statement.
    Where should i mention that,,,,
    Thanks
    Yogesh

    Hi Sharat,
      Thanks for your reply.
    I need to use the BADI HRWPC_PCR_APPR_FORM. In which the values are available in the Container. So if i need to use the container values then i need to use that include <cntain>.
    Is there any possible ways to make it.
    Thanks
    Yogesh

  • How to write the sql statement of my finder function in cmp?

    hi,
    I create a cmp ejb from table INFOCOLUMN,and I create a my finder function ,which sql statement is :
    select * from INFOCOLUMN WHERE employee_id=id
    employee_id is a column of the table,and id is the finder function parameter.
    The error is : invalid column name
    So,how to write the sql statement.
    Thanks .

    Mole-
    Bind variables are of the form $1, $2, etc., so your query stmt should look like:
    select * from INFOCOLUMN WHERE employee_id=$1
    -Jon

  • Can you use nested sql statements in jsp??

    HI, I was wondering if you can use nexted sql statements...
    example...
    <%@ page language="java" contentType="text/html" %>
    <%@ page import="java.sql.*" %>
    <%@ page import="forum.DataAccess" %>
    <%
         // Create a new instance of the DataAccess Class
              DataAccess d = new DataAccess();
         // This call the database connection method from the DataAccess Class
              d.ConnectDatabase();
         /* This gets the threads from database for the categories */
              // This is initilzing the variables
                   String threadname = null;
                   int threadid = 0;
              // This sets the sql variable to nothing
                   String sql = "";
                   String sql1 = "";
              // This sets the rs variable to null
                   ResultSet rs = null;
                   ResultSet rs1 = null;
              // This is doing a SELECT on the thread table based on the category id
                   sql += "select * from forum_threads where ft_catid = 2";
                   rs = d.SQLQuery(sql);
         /* End of categories */
         while (rs.next()){
                                       threadid = rs.getInt("ft_threadid");
                                       threadname = rs.getString("ft_threadname");
         sql1 += "select * from forum_messages where fm_catid = 2 and fm_threadid = " + threadid + "";
         rs1 = d.SQLQuery(sql1);
    %>
    THis is the error I get.....
    javax.servlet.ServletException: [Microsoft][ODBC SQL Server Driver]Connection is busy with results for another hstmt
    I know what that is.. it is because I am trying to open another result set before the first one is closed... but I need that one open cause I need to loop through the ids and run it against the second query??
    Any suggestions...

    I am not positive but it seems from your error message you will not be able to use the nested SQL. Another option would be to store the values of the ResultSet in a Vector (or Array), and then close your ResultSet and loop through the vector or array instead...
    Zac

  • How to use Counter and variable in xslt

    All,
    How to use Counter in XSLT, and How to do a increament for a count variable?
    How to use a Variable in xslt? and How to define variable inbetween XSLT
    If I am using
    Count=Count+1, its throwin an error ...
    Error: Text is not Supported Under a XSLT Element: $count=$count+1
    Regards
    Francis
    Edited by: Francis on Aug 23, 2012 9:33 AM
    Edited by: Francis on Aug 23, 2012 11:23 AM

    How to use a Variable in xslt? and How to define variable inbetween XSLT
    <xsl:variable name="VariableName">
    <xsl:value-of select='/ns0:SyncItemListEBM/ns0:DataArea/ns0:SyncItemList/corecomEBO:ItemSpecificationGroup/corecom:SpecificationGroup[corecom:Name = "GROUP_NAME"]/corecom:Specification[corecom:Name = "SPECIFICATION_NAME"]/corecom:ValueText'/>
    </xsl:variable>
    How to use Counter in XSLT, and How to do a increament for a count variable?
    You can make use of for-each tag, its simplified in XSLT where you dont need counter if at all needed then you can use of position() to identify the loop counter.
    Thanks,
    Vijay

Maybe you are looking for

  • Error while executing the perl script txkChkFormsDeployment.pl

    I run adstrtal.sh after update EBS from 12.1.1 to 12.1.3, when execute adformsctl.sh , it prompt the following error We have determined that you need to redeploy Forms (using txkChkFormsDeployment.pl). But could not do it automatically for you, due t

  • Satellite M40-225 and Vista PCMCIA driver

    I lost my original disks for my M40 so bought a copy of Vista to install on my computer, when I first installed it the computer would not start up so I looked on the internet and it seems there is a conflict with the PCMCIA drivers and Vista. I follo

  • Console does not launch OVM 3.1.1, Win7x32 Firefox15/IE8 - Empty .jnlp file

    I have installed Oracle VM Manager 3.1.1, and two Oracle VMS servers; all seems to have gone pretty well after some learning curve. After success here, I created Clone of the most recent PeopleTools 8.5.2 and PeopleSoft HCM templates, and was able to

  • Blocked Invoices WF

    I have created 2 workflows based on BUS2081 - Invoice blocked - see below.  Both are activated in SWETPV bit the blockedquant event is not triggered from MIRO when a quantioty block is created.  The wf tests fine when triggered amnually, but for smoe

  • Java won't compile for me

    hi. I'm new to Java. Installed JAva from a book's CD. Java1.3. When I compile, I get an error message saying "bad command or file name". It doesn't compile. Thank goodness for the book's exercises being on CD. The .class files are already there, whic