
Signature
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"
Hi,
basically i just want to avoid showing document_no again if the
previous record in the SQL RESULT recordset (the one we get after doing
the select statement) (not the database) matches the document_no of the
current record position in the recordset
So as anthony says it should go like:
dim docno
docno = ""
do until rs.eof
if docno = rs("document_no") then
response.wirte "<BR> - " & rs("ledger_ac")
else
response.write rs("document_no") & " - " &
rs("ledger_ac")
docno = rs("document_no")
end if
rs.movenext
loop
now instead of doing all this cant this be doine in the sql statement
itself ??? the main purpose is to make the program smaller because
there are lots of such statements in the reports.... makin arrays and
such if then statements code blows up alarmingly.....
regards,
shripal.
> > Hi,
> >
[quoted text clipped - 46 lines]
> don't check it very often. If you must reply off-line, then remove the
> "NO SPAM"
Bob Barrows [MVP] - 15 Oct 2006 19:18 GMT
> now instead of doing all this cant this be doine in the sql statement
> itself ???
Again, relational databases have no concept of "previous record" so there is
nothing built into sql to allow the "previous record" to be referenced.
> the main purpose is to make the program smaller because
> there are lots of such statements in the reports.... makin arrays and
> such if then statements code blows up alarmingly.....
If your table design permitted it*, it is remotely possible it could be done
by means of a self-join, but from the looks of your situation, it does not
appear to be possible. Even if it was, performance would likely be
atrocious, and you would simply be transferring the "alarming" code into an
"alarming" sql statement. This is a presentation issue that should be
handled by presentation code.
* Your table would need a field, or a combination of fields that would
enable the records to be ordered (ranked) with no ties.

Signature
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"
Mike Brind - 15 Oct 2006 19:32 GMT
> Hi,
>
[quoted text clipped - 23 lines]
> there are lots of such statements in the reports.... makin arrays and
> such if then statements code blows up alarmingly.....
Easy. Move the SQL from the pages to the database as saved queries. You'll
get the benefit of execution plans being pre-compiled as well as reducing
the code in your ASP pages.
--
Mike Brind
Bob Barrows [MVP] - 15 Oct 2006 19:35 GMT
> now instead of doing all this cant this be doine in the sql statement
> itself ??? the main purpose is to make the program smaller because
> there are lots of such statements in the reports.... makin arrays and
> such if then statements code blows up alarmingly.....
I was intrigued so i started playing with this.
If you add an autonumber field to your table (call it doc_id and make it the
primary key; create a non-unique index on the document_no field as well),
you can do something like this:
Create a saved query called PriorDocuments with this sql:
Select [doc_id] + 1 As PriorDoc_id, document_no From accounts
Then use this sql statement to retrieve your records:
Select IIf([p].[document_no] Is Null,[c].[document_no],'') AS document_no,
document_date, ledger_ac, debit, credit
From accounts c left join PriorRecord p ON c.document_no= p.document_no
AND (c.doc_id= p.PriorDoc_id)
I only did this as an intellectual puzzle. I still believe this method
should not be used in production. However, it is your application ...

Signature
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"