Recordset.first()
Hi,
How do I make a recordset that I can call first() on? Right now I'm getting an error saying that I'm not allowed to do it on the type of recordset I have.
Also, what is the overhead of this operation?
Hi
To use first(), last(), absolute() you need to use JDBC2. If the driver does not support JDBC2 : change the driver.
In the source code :
Statement myStatement = myConnection.createStatement( ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY);
ResulSet myResultSet = st.executeQuery(mySQL);
myResultSet.first();
For more informations : http://java.sun.com/j2se/1.3/docs/api/java/sql/package-summary.html#2.0 API
Simon Pierre NOLIN
Similar Messages
-
Navigating through recordSet values
Hello Everybody
Could somebody guide me as to how i can navigate within a recordset. actually i want that if a search criteria is met and recorsets generated then i can view one recordset values at a time, click button to view next and so on till the end of the recordset. could somebody please help
ruchiHi ,
to navigate within a recordset you can use the following methods of ResultSet interface:
next() //returns true if next record esists and moves cursor to it,else return false
beforeFirst()//moves cursor before the first record of recordset
first()//moves cursor to the first record ofe recordset
last()//moves the cursor to last record of recordset
and so on.
Take a look to Java APIs Documentation at
http://java.sun.com/j2se/1.4.1/docs/api/ -
Dynamic NX form generation from recordset
Quite often I've needed different forms (edit from an ADDT nextensio list)
dependent on user level or company
it would be very useful to be able to define the form fields from a recordset first
rather than create individually tailored forms
PaulHi
1. You're on the wrong forum. Please post on the LiveCycle designer forum.
2. Use a Table or a repeating subform. Bind the table row to "persons[*]" and the column cells to person/first_name.
Howard
http://www.avoka.com -
Need help with dreamweaverMX tutorial
I am using dreamweaverMX tutorial with coldfusion free
edition developement.
On dreamweaver, when I tried to insert a record on the server
behavior panel, I get this message saying:
"This server behavior requires a Coldfusion data source".
Please Help!
Georgeslys,You are trying to add a recordset to a page, right? You need
to have told
the page where to GET that recordset first, by adding a data
connection to
it.
Maybe this will help -
http://www.adobe.com/devnet/dreamweaver/articles/develop_web_application.html
Murray --- ICQ 71997575
Adobe Community Expert
(If you *MUST* email me, don't LAUGH when you do so!)
==================
http://www.projectseven.com/go
- DW FAQs, Tutorials & Resources
http://www.dwfaq.com - DW FAQs,
Tutorials & Resources
==================
"georgeslys" <[email protected]> wrote in
message
news:fooa82$eb4$[email protected]..
> Dear Murry,
> What exactly do you mean by specify data source?
>
> Georgeslys,
>
>
>
>
>
>
>
>
>
>
>
> -
I'm trying to insert a dynamicly generated form list/menu dropdown item.
Everything works but the list always shows me the last record from the database as the first item in the list (ASC or DESC).
I want to put a dummy label as the first item in the list like: Select from list
How can i do this, because even if i put a static value in the value list items, it still shows the last item from the recordset first instead of the static value.
Does anybody have an idea how i can create a dynamic pulldown list in my form with the first item listed to be a statich dummy tekst or label like "Select from list etc"
Thanks,I created a normal recordset with Dreamweaver getting tea
m_id and team_names out of the database. Then i list the teamnames in a form list/
menu (dropdown) to show all the available teams. Again it shows me the last record from the
recordset as the first list item and i want a standard "select this" text or something default.
The form code below is generated by dreamweaver itself. I already tried to also put one static value in the value list property but i get the same result. To me it looks like the while loop is overriding whatever you put as static text.
<form id="form1" name="form1" method="post" action="">
<label for="list_teams">Teams:</label>
<select name="list_teams" id="list_teams">
<?php
do {
?>
<option value="<?php echo $row_Teams['team_id']?>"<?php if (!(strcmp($row_Teams['team_id'], $row_Teams['team_id']))) {echo "selected=\"selected\"";} ?>><?php echo $row_Teams['team_name']?></option>
<?php
} while ($row_Teams = mysql_fetch_assoc($Teams));
$rows = mysql_num_rows($Teams);
if($rows > 0) {
mysql_data_seek($Teams, 0);
$row_Teams = mysql_fetch_assoc($Teams);
?>
</select>
</form> -
Need Help with DataboundComponents Tutorial
Running XP SP2 with local derby and remote Oracle 9i
SJSC2.1 on XP - up-to-date
Completed the DataboundComponents tutorial, I am trying to use the same "idea" with app myyrock that uses Oracle 9i (remote Sun Solaris 9 box)
The derby/travel version works ..The oracle/myyrock version fails with the following error:
I believe it is a problem is within the sessionBean1.java file and also the prerender in page1.jsp...
"Report" is a table and ReportID is the PK of the table
Table report coincides with table Travel.Person.
Thanks ever so much for looking at this..
The server log - stack trace is here:
Exception Handler
Description: An unhandled exception occurred during the execution of the web application. Please review the following stack trace for more information regarding the error.
Exception Details: java.lang.IllegalArgumentException
REPORT.REPORTID
Possible Source of Error:
Class Name: com.sun.data.provider.impl.CachedRowSetDataProvider
File Name: CachedRowSetDataProvider.java
Method Name: getFieldKeyInternal
Line Number: 481
Source not available. Information regarding the location of the exception can be identified using the exception stack trace below.
Stack Trace:
com.sun.data.provider.impl.CachedRowSetDataProvider.getFieldKeyInternal(CachedRowSetDataProvider.java:481)
com.sun.data.provider.impl.CachedRowSetDataProvider.getFieldKey(CachedRowSetDataProvider.java:439)
com.sun.data.provider.impl.AbstractDataProvider.getValue(AbstractDataProvider.java:62)
myyrockdata.Page1.prerender(Page1.java:543)
com.sun.rave.web.ui.appbase.faces.ViewHandlerImpl.prerender(ViewHandlerImpl.java:860)
com.sun.rave.web.ui.appbase.faces.ViewHandlerImpl.renderView(ViewHandlerImpl.java:295)
com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:87)
com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:221)
com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:117)
javax.faces.webapp.FacesServlet.service(FacesServlet.java:198)
sun.reflect.NativeMethodAccessorImpl.invoke0(NativeMethodAccessorImpl.java:-2)
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
java.lang.reflect.Method.invoke(Method.java:585)
org.apache.catalina.security.SecurityUtil$1.run(SecurityUtil.java:249)
java.security.AccessController.doPrivileged(AccessController.java:-2)
javax.security.auth.Subject.doAsPrivileged(Subject.java:517)
org.apache.catalina.security.SecurityUtil.execute(SecurityUtil.java:282)
org.apache.catalina.security.SecurityUtil.doAsPrivilege(SecurityUtil.java:165)
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:257)
org.apache.catalina.core.ApplicationFilterChain.access$000(ApplicationFilterChain.java:55)
org.apache.catalina.core.ApplicationFilterChain$1.run(ApplicationFilterChain.java:161)
java.security.AccessController.doPrivileged(AccessController.java:-2)
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:157)
com.sun.rave.web.ui.util.UploadFilter.doFilter(UploadFilter.java:194)
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:210)
org.apache.catalina.core.ApplicationFilterChain.access$000(ApplicationFilterChain.java:55)
org.apache.catalina.core.ApplicationFilterChain$1.run(ApplicationFilterChain.java:161)
java.security.AccessController.doPrivileged(AccessController.java:-2)
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:157)
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:263)
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:551)
org.apache.catalina.core.StandardContextValve.invokeInternal(StandardContextValve.java:225)
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:173)
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:551)
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:170)
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:551)
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:132)
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:551)
org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:933)
org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:189)
com.sun.enterprise.web.connector.grizzly.ProcessorTask.doProcess(ProcessorTask.java:604)
com.sun.enterprise.web.connector.grizzly.ProcessorTask.process(ProcessorTask.java:475)
com.sun.enterprise.web.connector.grizzly.ReadTask.executeProcessorTask(ReadTask.java:371)
com.sun.enterprise.web.connector.grizzly.ReadTask.doTask(ReadTask.java:264)
com.sun.enterprise.web.connector.grizzly.TaskBase.run(TaskBase.java:281)
com.sun.enterprise.web.connector.grizzly.WorkerThread.run(WorkerThread.java:83)
Exception Details: com.sun.rave.web.ui.appbase.ApplicationException
REPORT.REPORTID
Possible Source of Error:
Class Name: com.sun.rave.web.ui.appbase.faces.ViewHandlerImpl
File Name: ViewHandlerImpl.java
Method Name: destroy
Line Number: 601
Source not available. Information regarding the location of the exception can be identified using the exception stack trace below.
Stack Trace:
com.sun.rave.web.ui.appbase.faces.ViewHandlerImpl.destroy(ViewHandlerImpl.java:601)
com.sun.rave.web.ui.appbase.faces.ViewHandlerImpl.renderView(ViewHandlerImpl.java:302)
com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:87)
com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:221)
com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:117)
javax.faces.webapp.FacesServlet.service(FacesServlet.java:198)
sun.reflect.NativeMethodAccessorImpl.invoke0(NativeMethodAccessorImpl.java:-2)
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
java.lang.reflect.Method.invoke(Method.java:585)
org.apache.catalina.security.SecurityUtil$1.run(SecurityUtil.java:249)
java.security.AccessController.doPrivileged(AccessController.java:-2)
javax.security.auth.Subject.doAsPrivileged(Subject.java:517)
org.apache.catalina.security.SecurityUtil.execute(SecurityUtil.java:282)
org.apache.catalina.security.SecurityUtil.doAsPrivilege(SecurityUtil.java:165)
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:257)
org.apache.catalina.core.ApplicationFilterChain.access$000(ApplicationFilterChain.java:55)
org.apache.catalina.core.ApplicationFilterChain$1.run(ApplicationFilterChain.java:161)
java.security.AccessController.doPrivileged(AccessController.java:-2)
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:157)
com.sun.rave.web.ui.util.UploadFilter.doFilter(UploadFilter.java:194)
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:210)
org.apache.catalina.core.ApplicationFilterChain.access$000(ApplicationFilterChain.java:55)
org.apache.catalina.core.ApplicationFilterChain$1.run(ApplicationFilterChain.java:161)
java.security.AccessController.doPrivileged(AccessController.java:-2)
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:157)
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:263)
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:551)
org.apache.catalina.core.StandardContextValve.invokeInternal(StandardContextValve.java:225)
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:173)
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:551)
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:170)
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:551)
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:132)
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:551)
org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:933)
org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:189)
com.sun.enterprise.web.connector.grizzly.ProcessorTask.doProcess(ProcessorTask.java:604)
com.sun.enterprise.web.connector.grizzly.ProcessorTask.process(ProcessorTask.java:475)
com.sun.enterprise.web.connector.grizzly.ReadTask.executeProcessorTask(ReadTask.java:371)
com.sun.enterprise.web.connector.grizzly.ReadTask.doTask(ReadTask.java:264)
com.sun.enterprise.web.connector.grizzly.TaskBase.run(TaskBase.java:281)
com.sun.enterprise.web.connector.grizzly.WorkerThread.run(WorkerThread.java:83)You are trying to add a recordset to a page, right? You need
to have told
the page where to GET that recordset first, by adding a data
connection to
it.
Maybe this will help -
http://www.adobe.com/devnet/dreamweaver/articles/develop_web_application.html
Murray --- ICQ 71997575
Adobe Community Expert
(If you *MUST* email me, don't LAUGH when you do so!)
==================
http://www.projectseven.com/go
- DW FAQs, Tutorials & Resources
http://www.dwfaq.com - DW FAQs,
Tutorials & Resources
==================
"georgeslys" <[email protected]> wrote in
message
news:fooa82$eb4$[email protected]..
> Dear Murry,
> What exactly do you mean by specify data source?
>
> Georgeslys,
>
>
>
>
>
>
>
>
>
>
>
> -
I'm using a plug-in for Eclipse to help identify possible memory leaks however we are having trouble interpreting the results. The top, and pretty much the only, suspect is this...
7,874 instances of "macromedia.jdbc.oracle.OracleConnection", loaded by "coldfusion.bootstrap.BootstrapClassLoader @ 0xf935218" occupy 604,781,904 (71.02%) bytes. These instances are referenced from one instance of "java.util.HashMap$Entry[]", loaded by "<system class loader>"
Any ideas what could cause this many instances? How do we track this back to a particular cfm or cfc? Do these number seem high or is that normal? The system in question normally only has 30-60 concurrent users.
The one item I'm a little skeptical of is the use of the "coldfusion.server.ServiceFactory" and "coldfusion.sql.QueryTable" objects. We use them for 1000s of different queries, even queries within large loops. Could these be the problem? Each time we need to execute a query we do a createObject for each of these objects, when done we close the connection. I recently found a similar example where they close the recordSet first and then close the connection, we are not closing the recordSet. Any help at all is much appreciated.It could simply be caused by the obvious: a query or queries making a large number of connections and/or consuming large resources on the Oracle database. Use Eclipse to search your application folder for queries. Can you identify any queries that could be the culprit? Is there a loop containing a method or an instance of a component that queries an Oracle database?
What's your Coldfusion version? If you're on CF8 or CF9 then the server monitor (in the Coldfusion Administrator) might tell you the process responsible for the high consumption. -
Asp code does not render for first record in looped recordset
I have posted this question on a javascript forum as it
contains javascript code however it was believed to be an asp
issue.
The following head section javascript code contains the
function showBigImage( isource,bigImage,header ) function call of
discussion:
var currentImage;
function showBigImage( isource,bigImage,header ) {
var theImage = document.getElementById( 'largeimage' );
theImage.src = isource;
currentImage = bigImage;
document.getElementById( 'photoHeader' ).innerHTML=header;
document.getElementById( 'largeimage' ).alt=header;
The following rendered looped recordset code illustrates how
the "header" parameter of this showBigImage(
isource,bigImage,header ) function call does not render ONLY FOR
THE FIRST RECORD OF THE RECORDSET as it is blank:
<a href= "javascript:;" > <td height=36
valign="middle" class="small_img" onmouseover="showBigImage(
'imagescript.asp?path=images/portable_stage.jpg&width=250','images/portable_stage.jpg',''
)"> <img
src="imagescript.asp?path=images/portable_stage.jpg&width=36"
border="0" alt="" /> </td> </a>
<a href= "javascript:;" > <td height=36
valign="middle" class="small_img" onmouseover="showBigImage(
'imagescript.asp?path=images/seated_riserset.jpg&width=250','images/seated_riserset.jpg', 'Portable
stage configuration using 9 units of the 3 ft x 8 ft platforms in 3
different heights' )"> <img
src="imagescript.asp?path=images/seated_riserset.jpg&width=36"
border="0" alt="" /> </td> </a>
<a href= "javascript:;" > <td height=36
valign="middle" class="small_img" onmouseover="showBigImage(
'imagescript.asp?path=images/Stageset.jpg&width=250','images/Stageset.jpg','Portable
stage configuration using 16 units of the 4 ft x 8 ft platforms'
)"> <img
src="imagescript.asp?path=images/Stageset.jpg&width=36"
border="0" alt="" /> </td> </a>
<a href= "javascript:;" > <td height=36
valign="middle" class="small_img" onmouseover="showBigImage(
'imagescript.asp?path=images/Runset.jpg&width=250','images/Runset.jpg','Portable
stage runset configuration' )"> <img
src="imagescript.asp?path=images/Runset.jpg&width=36"
border="0" alt="" /> </td> </a>
Because of this problem, the caption text does not display
for this first image record once the thumbnail images are moused
over. You can view this page example at
http://www.canchair.com/new_web_product_detail.asp?ProductID=198&ProductFamily=1&ProductFa milySub=10Please help with this issue!!!
-
Want to retrieve first row from recordset
hi,
I am trying to retrieve a value from frist row , second cloumn.
from recordset and it is an integer value, but when I try to do that, it is throwing an error.
java.sql.SQLException: Result set type is TYPE_FORWARD_ONLY
at sun.jdbc.odbc.JdbcOdbcResultSet.first(Unknown Source)
at TicketClientRetriever.TicketNumberGenerator.checkLastTicket(TicketNum
berGenerator.java:35)
at TicketClientRetriever.TicketCreator$3.actionPerformed(TicketCreator.j
ava:204)
at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Sour
ce)
at java.awt.Component.processMouseEvent(Unknown Source)
at javax.swing.JComponent.processMouseEvent(Unknown Source)
at java.awt.Component.processEvent(Unknown Source)
at java.awt.Container.processEvent(Unknown Source)
at java.awt.Component.dispatchEventImpl(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Window.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)
please check the part of the code Below which is used to retrieve the data
public static int checkLastTicket()
//int i =0;
connection1();
try
Ex1rs = Ex1Stmt.executeQuery("Select * from Ticketlog Order By TicketNumber DESC");
if (Ex1rs!=null)
Ex1rs.isFirst();
ticket = Ex1rs.getInt(2);
System.out.println(ticket);
else
System.out.println("Recordset is empty");
catch (Exception e)
e.printStackTrace();
System.out.println(ticket);
return ticket;
A JDBC tutorial would really help you out. You can find one at:
http://java.sun.com/developer/onlineTraining/Database/JDBC20Intro/JDBC20.html
If your too busy (or lazy) to take the tutorial, this might get you going:
A ResultSet is initially positioned BEFORE the first row. You need to move to the first row most commonly done using rs.next()
rs.isFirst() returns a boolean that is true IF you are on the first row. You don't seem to be using it that way...
Good Luck! -
Redirecting a user to the first page in a recordset (PHP/MySQL)
On my site I have a comments page with a small text box to
enter a page number to navigate through the comments. If a user
enters a page number greater than the highest page, I want them to
be redirected to the first page. I'm having a lot of trouble
figuring out how to do this because the 'current page' variable is
set before the mysql query, and its not until after that, the total
'page variable' is set.
The 'total page' variable must be set after the query because
it relies on other variables from the query, and the 'current page'
variable must be set before the query because the query relies on
the 'current page' variable. So it seems impossible to rearranges
these things to put in something such as:
if ($pageNum_submission_comments >
$totalPages_submission_comments) {
$pageNum_submission_comments = 0;
Is there something else I can do? I would really appreciate
some help on this, as I've been trying to figure out how to do it
for such a long time now.
Thanks in advanced to anyone who is able to help me.AngryCloud wrote:
> If you wouldn't mind explaining the example code you
provided, that would be
> very convenient... but if you do mind, I'm sure I can
figure it out eventually.
You need to find the number of comments associated with a
particular
article, and use that number to calculate the number of pages
they will
occupy. SELECT COUNT(*) finds the number of records in a
table. So,
something like this would find the number of comments
associated with a
specific article:
$getTotal = "SELECT COUNT(*) FROM myTable WHERE articleID =
$articleID";
You then pass that SQL query to mysql_query() to process it.
mysql_fetch_row() extracts the result as an array, which I
have assigned
to $row. Since there's only one value in the result, $row[0]
contains
the number you want.
$result = mysql_query($getTotal);
$row = mysql_fetch_row($result);
$totalComments = $row[0];
$totalComments contains the number of comments. You can now
use that
figure to calculate the maximum number of pages.
David Powers, Adobe Community Expert
Author, "Foundation PHP for Dreamweaver 8" (friends of ED)
Author, "PHP Solutions" (friends of ED)
http://foundationphp.com/ -
Why must you check for null first?
Post Author: sliese
CA Forum: Data Connectivity and SQL
Hi All -I am a bit confused. If I have a record selection formula like this:isnull({Product.Size}) or ({Product.Size} <> "xlrg")I realize that the null condition must come first in order for nulls to be included in the recordset. But, I don't understand why. Even if it can just be explained away by saying "that's a bug," isn't this being done by the dbms anyways? I thought the dbms looks at your SQL query strings, retrieves the appropriate records, then sends them back to Crystal. The dbms should give us the null values whether or not it comes first in the or condition. Am I missing something? Does crystal do some additional processesing after the records are retrieved that causes it to throw away all the null value records?Thanks in advance to anyone who can shed light on this issue for me.-StephaniePost Author: sliese
CA Forum: Data Connectivity and SQL
Right, I realize null values always return false. Which is exactly why I don't understand why it has to come first in record selection criteria. In other words, this works just fine:
isnull(field) or field <> "xlrg"
But, this does not, even though they are equivalent:
field <> "xlrg" or isnull(field)
When the DBMS first sees that I've checked if field <> xlrg, this will be false, thus it SHOULD go to the second criteria in my OR condition to determine whether or not to include the record. But, it does not seem to do that. Instead, it decides not to include the record at all even though the second part of the OR condition may still return true. Does my wording make sense now? -
How to get an updatable ADODB Recordset from a Stored Procedure?
In VB6 I have this code to get a disconnected ADODB Recordset from a Oracle 9i database (the Oracle Client is 10g):
Dim conSQL As ADODB.Connection
Dim comSQL As ADODB.Command
Dim recSQL As ADODB.Recordset
Set conSQL = New ADODB.Connection
With conSQL
.ConnectionString = "Provider=OraOLEDB.Oracle;Password=<pwd>;Persist Security Info=True;User ID=<uid>;Data Source=<dsn>"
.CursorLocation = adUseClientBatch
.Open
End With
Set comSQL = New ADODB.Command
With comSQL
.ActiveConnection = conSQL
.CommandType = adCmdStoredProc
.CommandText = "P_PARAM.GETALLPARAM"
.Properties("PLSQLRSet").Value = True
End With
Set recSQL = New ADODB.Recordset
With recSQL
Set .Source = comSQL
.CursorLocation = adUseClient
.CursorType = adOpenStatic
.LockType = adLockBatchOptimistic
.Open
.ActiveConnection = Nothing
End With
The PL/SQL Procedure is returning a REF CURSOR like this:
PROCEDURE GetAllParam(op_PARAMRecCur IN OUT P_PARAM.PARAMRecCur)
IS
BEGIN
OPEN op_PARAMRecCur FOR
SELECT *
FROM PARAM
ORDER BY ANNPARAM DESC;
END GetAllParam;
When I try to update some values in the ADODB Recordset (still disconnected), I get the following error:
Err.Description: Multiple-step operation generated errors. Check each status value.
Err.Number: -2147217887 (80040E21)
Err.Source: Microsoft Cursor Engine
The following properties on the Command object doesn't change anything:
.Properties("IRowsetChange") = True
.Properties("Updatability") = 7
How can I get an updatable ADODB Recordset from a Stored Procedure?4 years later...
I was having then same problem.
Finally, I've found how to "touch" the requierd bits.
Obviously, it's hardcore, but since some stupid at microsoft cannot understand the use of a disconnected recordset in the real world, there is no other choice.
Reference: http://download.microsoft.com/downlo...MS-ADTG%5D.pdf
http://msdn.microsoft.com/en-us/library/cc221950.aspx
http://www.xtremevbtalk.com/showthread.php?t=165799
Solution (VB6):
<pre>
Dim Rst As Recordset
Rst.Open "select 1 as C1, '5CHARS' as C5, sysdate as C6, NVL(null,15) as C7, null as C8 from DUAL", yourconnection, adOpenKeyset, adLockBatchOptimistic
Set Rst.ActiveConnection = Nothing
Dim S As New ADODB.Stream
Rst.Save S, adPersistADTG
Rst.Close
Set Rst = Nothing
With S
'Debug.Print .Size
Dim Bytes() As Byte
Dim WordVal As Integer
Dim LongVal As Long
Bytes = .Read(2)
If Bytes(0) <> 1 Then Err.Raise 5, , "ADTG byte 0, se esperaba: 1 (header)"
.Position = 2 + Bytes(1)
Bytes = .Read(3)
If Bytes(0) <> 2 Then Err.Raise 5, , "ADTG byte 9, se esperaba: 2 (handler)"
LongVal = Bytes(1) + Bytes(2) * 256 ' handler size
.Position = .Position + LongVal
Bytes = .Read(3)
If Bytes(0) <> 3 Then Err.Raise 5, , "ADTG, se esperaba: 3 (result descriptor)"
LongVal = Bytes(1) + Bytes(2) * 256 ' result descriptor size
.Position = .Position + LongVal
Bytes = .Read(3)
If Bytes(0) <> 16 Then Err.Raise 5, , "ADTG, se esperaba: 16 (adtgRecordSetContext)"
LongVal = Bytes(1) + Bytes(2) * 256 ' token size
.Position = .Position + LongVal
Bytes = .Read(3)
If Bytes(0) <> 5 Then Err.Raise 5, , "ADTG, se esperaba: 5 (adtgTableDescriptor)"
LongVal = Bytes(1) + Bytes(2) * 256 ' token size
.Position = .Position + LongVal
Bytes = .Read(1)
If Bytes(0) <> 6 Then Err.Raise 5, , "ADTG, se esperaba: 6 (adtgTokenColumnDescriptor)"
Do ' For each Field
Bytes = .Read(2)
LongVal = Bytes(0) + Bytes(1) * 256 ' token size
Dim NextTokenPos As Long
NextTokenPos = .Position + LongVal
Dim PresenceMap As Long
Bytes = .Read(3)
PresenceMap = Val("&H" & Right$("0" & Hex$(Bytes(0)), 2) & Right$("0" & Hex$(Bytes(1)), 2) & Right$("0" & Hex$(Bytes(2)), 2))
Bytes = .Read(2) 'ColumnOrdinal
'WordVal = Val("&H" & Right$("0" & Hex$(Bytes(0)), 2) & Right$("0" & Hex$(bytes(1)), 2))
'Aca pueden venir: friendly_columnname, basetable_ordinal,basetab_column_ordinal,basetab_colname
If PresenceMap And &H800000 Then 'friendly_columnname
Bytes = .Read(2) 'Size
LongVal = Bytes(0) + Bytes(1) * 256 ' Size
.Position = .Position + LongVal * 2 '*2 debido a UNICODE
End If
If PresenceMap And &H400000 Then 'basetable_ordinal
.Position = .Position + 2 ' 2 bytes
End If
If PresenceMap And &H200000 Then 'basetab_column_ordinal
.Position = .Position + 2 ' 2 bytes
End If
If PresenceMap And &H100000 Then 'basetab_colname
Bytes = .Read(2) 'Size
LongVal = Bytes(0) + Bytes(1) * 256 ' Size
.Position = .Position + LongVal * 2 '*2 debido a UNICODE
End If
Bytes = .Read(2) 'adtgColumnDBType
'WordVal = Val("&H" & Right$("0" & Hex$(Bytes(0)), 2) & Right$("0" & Hex$(bytes(1)), 2))
Bytes = .Read(4) 'adtgColumnMaxLength
'LongVal = Val("&H" & Right$("0" & Hex$(Bytes(3)), 2) & Right$("0" & Hex$(Bytes(2)), 2) & Right$("0" & Hex$(Bytes(1)), 2) & Right$("0" & Hex$(Bytes(0)), 2))
Bytes = .Read(4) 'Precision
'LongVal = Val("&H" & Right$("0" & Hex$(Bytes(3)), 2) & Right$("0" & Hex$(Bytes(2)), 2) & Right$("0" & Hex$(Bytes(1)), 2) & Right$("0" & Hex$(Bytes(0)), 2))
Bytes = .Read(4) 'Scale
'LongVal = Val("&H" & Right$("0" & Hex$(Bytes(3)), 2) & Right$("0" & Hex$(Bytes(2)), 2) & Right$("0" & Hex$(Bytes(1)), 2) & Right$("0" & Hex$(Bytes(0)), 2))
Dim ColumnFlags() As Byte, NewFlag0 As Byte
ColumnFlags = .Read(1) 'DBCOLUMNFLAGS, First Byte only (DBCOLUMNFLAGS=4 bytes total)
NewFlag0 = ColumnFlags(0)
If (NewFlag0 And &H4) = 0 Then 'DBCOLUMNFLAGS_WRITE (bit 2) esta OFF
'Lo pongo en ON, ya que quiero escribir esta columna LOCALMENTE en el rst DESCONECTADO
NewFlag0 = (NewFlag0 Or &H4)
End If
If (NewFlag0 And &H8) <> 0 Then 'DBCOLUMNFLAGS_WRITEUNKNOWN (bit 3) esta ON
'Lo pongo en OFF, ya que no me importa si NO sabes si se puede updatear no, yo lo se, no te preocupes
'ya que quiero escribir esta columna LOCALMENTE en el rst DESCONECTADO
NewFlag0 = (NewFlag0 And Not &H8)
End If
If (NewFlag0 And &H20) <> 0 Then 'DBCOLUMNFLAGS_ISNULLABLE (bit 5) esta OFF
'Lo pongo en ON, ya que siendo un RST DESCONECTADO, si le quiero poner NULL, le pongo y listo
NewFlag0 = (NewFlag0 Or &H20)
End If
If NewFlag0 <> ColumnFlags(0) Then
ColumnFlags(0) = NewFlag0
.Position = .Position - 1
.Write ColumnFlags
End If
.Position = NextTokenPos
Bytes = .Read(1)
Loop While Bytes(0) = 6
'Reconstruyo el Rst desde el stream
S.Position = 0
Set Rst = New Recordset
Rst.Open S
End With
'TEST IT
On Error Resume Next
Rst!C1 = 15
Rst!C5 = "MUCHOS CHARS"
Rst!C7 = 23423
If Err.Number = 0 Then
MsgBox "OK"
Else
MsgBox Err.Description
End If
</pre> -
Help with multiple recordsets and pulling an ID value (ASP)
I started this discussion when first developing my project and posted on the General Tab. I have figured out that issue (trying to get my Insert to work in ASP) but now am having trouble retrieving an ID value. It should be simple. I want to insert a new record into a single table and want to create a unique ID field. I am using SQL Server and tried the Identity setting but won't be able to have admin privileges which are required to set the ID. So, I'd like to just take the ID value from the last record and just add '1' to it to get a new unique ID manually. My INSERT portion was working, so I just decided to query the records to retrieve the last CatalogID and add '1' to get my new ID. But it's not working! I tried opening both a command and a recordset, but get various errors on invalid command use.
Any help would be great! I'm new to all of this!
I've posted a code snippet of what I thought I should do:
<%LANGUAGE = “VBSCRIPT” CODEPAGE=”65001”%)
<!--#include file=”Connections/CapConnect.asp”” -->
<%
If (Cstr(Request(“MM_insert”)) = “form1”) Then
Dim MM_editCmd
Dim MM_Lookup
Dim NextCatalogID
Set MM_Lookup = Server.CreateObject (“ADOB.Recordset”)
MM_Lookup.ActiveConnection = MM_CapConnect_STRING
MM_Liikup.Source = “Select CatalogID From dbo.tblCatalogItems ORDERBY CatalogID Ascending”
MMLookup.Open
MM_Lookup.MoveLast
NextCatalogID = MM_Lookup.Fields(“CatalogID”) + 1 'this is supposed to be my new ID value
Set MM_Lookup = Nothing
Set MM_editCmd = Server.CreateObject(“ADOB.Command”)
MM_editCmd.ActiveConnection = MM_CapConnect_STRING
MM_editcmd.CommandText = “INSET INTO dbo.tblCatalogItems (CatalogID, ModelName, Description, POCName, [POCPhone]) VALUES (NextCatalogID, ?,?,?,?)
MM_editcmd.Prepared = True
MM_edit.Parameters.Append MM_editcmd.CreateParameter(“param2”, 202, 1, 100, Request.Form(“modelname”) )
MM_edit.Parameters.Append MM_editcmd.CreateParameter(“param3”, 202, 1, 300, Request.Form(“Description”) )
[Subject line edited by moderator to add server model]Ok, you've got lots of problems. First, explain again why you are not able to modify the CatologID to be an identity column? What is the datatype of that column now?
Next, you are going about selecting your recordset incorrectly. If you are just looking for the last value inserted, there is no need to return all values to the recordset. Just select the max value:
MM_Liikup.Source = “Select MAX (CatalogID) From dbo.tblCatalogItems”
Next, you have a typo in your insert statement "“INSET INTO" should be "INSERT INTO"
Next, your CommandText is wrong. There is no ending quote, and NextCatalogID will be treated as a string literal, not a variable. Use a ? placeholder for it and use the CreateParameter method to populate it.
Next, your command text includes 4 placeholder, but you are only populating 2.
But even when you get this to work it will be problematic. What happens when 2 users execute this at the same time? They both read the same value for the max record and increment by one, but the first will succeed and the second will fail. That's why it is always better to use an auto increment (Identity) column. -
How do I copy recordsets from one database table to another?
I am using the Database Connectivity Toolset, and would like to copy either one recordset or multiple recordsets from one Access table to a table in a different database. I would like to do it directly with the data in variant form, but I can't get it to work. I can get it to work(on a small test table) if I first convert my source variant data to a cluster, then insert that into the other database table. My real database has many items with a variety of date types. Can I copy directly variant to variant?
Is it necessary to read all the data back into LabVIEW first? The reason I'm asking is that it is much more efficient to just use SQL statements to get the data you need and write that directly to the second database. I did a quick Google search on it and came up with lots of responses on what the correct syntax is for setting that up. Using an SQL command to copy the data back and forth is analogous to copying data from one file to another using the Copy file function rather than reading the entire contents of the file, converting the file string to the data arrays, converting back to a string, and then writing it back to another file.
Chapter 5 of the Database Connectivity Toolset User Manual describes how to execute SQL queries.
If you do need to actually
see the data in LabVIEW first, then the only way to get it back into the other database is to convert those variants to LV datatypes and then cluster those values again and write them back out to the second database. -
How do I get a recordset to display three images horizontally?
Hi,
I'm using DWCS3 with MAMP.
I want to display three images horizontally in a recordset. I have downloaded Tom Muck's extension horizontal looper and followed the instructions.
However when I tried to add the recordset navigation bar I ran into some problems.
If I add a repeat region to Tom Muck's extension then the page doesn't load.
If I don't add a repeat region to Tom's extension everything works really well except only one image displays rather than three.
Here is all of my code for the page.
Could someone help me please.
<?php require_once('Connections/connQuery.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
$theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
return $theValue;
$currentPage = $_SERVER["PHP_SELF"];
$maxRows_rshlimgs = 1;
$pageNum_rshlimgs = 0;
if (isset($_GET['pageNum_rshlimgs'])) {
$pageNum_rshlimgs = $_GET['pageNum_rshlimgs'];
$startRow_rshlimgs = $pageNum_rshlimgs * $maxRows_rshlimgs;
mysql_select_db($database_connQuery, $connQuery);
$query_rshlimgs = "SELECT * FROM image";
$query_limit_rshlimgs = sprintf("%s LIMIT %d, %d", $query_rshlimgs, $startRow_rshlimgs, $maxRows_rshlimgs);
$rshlimgs = mysql_query($query_limit_rshlimgs, $connQuery) or die(mysql_error());
$row_rshlimgs = mysql_fetch_assoc($rshlimgs);
if (isset($_GET['totalRows_rshlimgs'])) {
$totalRows_rshlimgs = $_GET['totalRows_rshlimgs'];
} else {
$all_rshlimgs = mysql_query($query_rshlimgs);
$totalRows_rshlimgs = mysql_num_rows($all_rshlimgs);
$totalPages_rshlimgs = ceil($totalRows_rshlimgs/$maxRows_rshlimgs)-1;
$queryString_rshlimgs = "";
if (!empty($_SERVER['QUERY_STRING'])) {
$params = explode("&", $_SERVER['QUERY_STRING']);
$newParams = array();
foreach ($params as $param) {
if (stristr($param, "pageNum_rshlimgs") == false &&
stristr($param, "totalRows_rshlimgs") == false) {
array_push($newParams, $param);
if (count($newParams) != 0) {
$queryString_rshlimgs = "&" . htmlentities(implode("&", $newParams));
$queryString_rshlimgs = sprintf("&totalRows_rshlimgs=%d%s", $totalRows_rshlimgs, $queryString_rshlimgs);
?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Untitled Document</title>
<link href="styles/orderlist3.css" rel="stylesheet" type="text/css" />
<link rel="stylesheet" href="lightbox_assets/css/lightbox.css" type="text/css" media="screen" />
<script src="lightbox_assets/js/prototype.js" type="text/javascript"></script>
<script src="lightbox_assets/js/scriptaculous.js?load=effects" type="text/javascript"></script>
<script src="lightbox_assets/js/lightbox.js" type="text/javascript"></script>
<style type="text/css">
<!--
a:link {
color: #999966;
a:visited {
color: #FFFFFF;
a:hover {
color: #006600;
a:active {
color: #666699;
-->
</style></head>
<body class="oneColFixCtrHdr" onload="initLightbox()">
<div id="container">
<div id="header">
<h1>Header</h1>
<!-- end #header --></div>
<div id="mainContent">
<h3>Image catalog</h3>
<p> </p>
<table >
<tr>
<?php
$rshlimgs_endRow = 0;
$rshlimgs_columns = 3; // number of columns
$rshlimgs_hloopRow1 = 0; // first row flag
do {
if($rshlimgs_endRow == 0 && $rshlimgs_hloopRow1++ != 0) echo "<tr>";
?>
<td><p><a href="images/weddingprivate/mr_and_mrs_lowe_18_15.jpg" title="Mr and Mrs Lowe_18_15" rel="lightbox"><img src="<?php echo $row_rshlimgs['imagethumb_url']; ?>" alt="The bride to be getting ready" longdesc="http://The bride to be with her hairdresser" width="100" height="150" /></a></p>
<p><?php echo $row_rshlimgs['caption']; ?> <img src="images/Untitled-1.gif" alt="spacer" width="170" height="1" /></p>
<p> </p>
<form target="paypal" action="https://www.paypal.com/cgi-bin/webscr" method="post">
<input type="hidden" name="cmd" value="_s-xclick" />
<input type="hidden" name="hosted_button_id" value="6782561" />
<table>
<tr>
<td><input type="hidden" name="on0" value="Sizes" />
Sizes</td>
</tr>
<tr>
<td><select name="os0">
<option value="6x4">6x4 £3.00 </option>
<option value="7x5">7x5 £5.00 </option>
<option value="12x8">12x8 £6.50 </option>
</select>
</td>
</tr>
</table>
<input type="hidden" name="currency_code" value="GBP" />
<input type="image" src="https://www.paypal.com/en_GB/i/btn/btn_cart_LG.gif" border="0" name="submit" alt="PayPal - The safer, easier way to pay online." />
<img alt="" border="0" src="https://www.paypal.com/en_GB/i/scr/pixel.gif" width="1" height="1" />
</form></td>
<?php $rshlimgs_endRow++;
if($rshlimgs_endRow >= $rshlimgs_columns) {
?>
</tr>
<?php
$rshlimgs_endRow = 0;
} while ($row_rshlimgs = mysql_fetch_assoc($rshlimgs));
if($rshlimgs_endRow != 0) {
while ($rshlimgs_endRow < $rshlimgs_columns) {
echo("<td> </td>");
$rshlimgs_endRow++;
echo("</tr>");
}?>
</table>
<table border="0">
<tr>
<td><?php if ($pageNum_rshlimgs > 0) { // Show if not first page ?>
<a href="<?php printf("%s?pageNum_rshlimgs=%d%s", $currentPage, 0, $queryString_rshlimgs); ?>"><img src="images/First.gif" border="0" /></a>
<?php } // Show if not first page ?>
</td>
<td><?php if ($pageNum_rshlimgs > 0) { // Show if not first page ?>
<a href="<?php printf("%s?pageNum_rshlimgs=%d%s", $currentPage, max(0, $pageNum_rshlimgs - 1), $queryString_rshlimgs); ?>"><img src="images/Previous.gif" border="0" /></a>
<?php } // Show if not first page ?>
</td>
<td><?php if ($pageNum_rshlimgs < $totalPages_rshlimgs) { // Show if not last page ?>
<a href="<?php printf("%s?pageNum_rshlimgs=%d%s", $currentPage, min($totalPages_rshlimgs, $pageNum_rshlimgs + 1), $queryString_rshlimgs); ?>"><img src="images/Next.gif" border="0" /></a>
<?php } // Show if not last page ?>
</td>
<td><?php if ($pageNum_rshlimgs < $totalPages_rshlimgs) { // Show if not last page ?>
<a href="<?php printf("%s?pageNum_rshlimgs=%d%s", $currentPage, $totalPages_rshlimgs, $queryString_rshlimgs); ?>"><img src="images/Last.gif" border="0" /></a>
<?php } // Show if not last page ?>
</td>
</tr>
</table>
<p> </p>
<p> </p>
<!-- end #mainContent --></div>
<div id="footer">
<p>Footer</p>
<!-- end #footer --></div>
<!-- end #container --></div>
</body>
</html>
<?php
mysql_free_result($rshlimgs);
?>Hi Charles,
Use [Dr%] Variable formula as =if(IsNull([Dr%]);0;[DR%])
Here IsNull returns the Boolean value of variable [Dr%] if its true then inserts 0 else the percentage values of failed tests based on the total number of assembly tests performed.
I Hope this is what you want to achieve....
Thanks....
Pratik
Maybe you are looking for
-
Family sharing & two Apple IDs
I have two AppleIDs - one for my iCloud (email etc) and a second for all Store purchases. I share the Store AppleID with my kids' iPads so that we can share purchases as per this recommendation ( Using your Apple ID for Apple services ). And that has
-
Using webaccess with ipad and android tabs
Because of different browser agent, the gw 2012 webclient has not the same behavior as the standard webclient using firefox or chrome on pc. I want to access the documents folder. How to do it on this mobile devices? with regards and thx Go Gotthard
-
Function Does Not Return any value .
Hi , I am wrtting the below funtion without using any cursor to return any message if the value enters by parameters does not match with the value reterived by the function select statement or it does not reterive any value that for the parameters en
-
Add a buffer space between two parts of formula
I have a formula that combines a date command (field) and some text at the end. It's repeated for each row of a cross-tab, so they are stacked vertically. I need to add a buffer of blank space in between the date command and the text at then end, s
-
I want to make a series of text titles zoom out and then stretch in the middle as they reach full size like a rubber band having over stretched and then pinging back into place in CS4. I have looked through the text animation presets and can't find a