473,404 Members | 2,114 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,404 software developers and data experts.

asp.net Oracle TEMP table woes

I'm having trouble using a temp table in Oracle. Here's my code:

Dim myConn As OleDbConnection
Dim strconn As String = Session.Item("optSrcDBConnect")

Dim dcSQL As OleDbCommand
Dim strSQL As String
Dim drSQL As OleDbDataReader

WriteLog("Open connection")
Try
myConn = New OleDbConnection(strconn)
myConn.Open()
Catch ex As Exception
WriteLog("Error opening connection " & vbCrLf & ex.Message)
Exit Sub
End Try

Try
strSQL = "DROP TABLE TEMPODSWIP"
dcSQL = New OleDbCommand(strSQL, myConn)
dcSQL.ExecuteNonQuery()
WriteLog(strSQL)
Catch ex As Exception
WriteLog("Error processing SQL " & vbCrLf & strSQL & vbCrLf &
ex.ToString & " " & ex.Message)
' Exit Sub
End Try

Dim trSQL As OleDbTransaction
trSQL = myConn.BeginTransaction
Try
strSQL = "CREATE GLOBAL TEMPORARY TABLE TEMPODSWIP ON COMMIT
PRESERVE ROWS AS SELECT /*+ ORDERED */ RMAM.RMA_NBR AS RMAM_RMA_NBR,
RMAD.LN_NBR AS RMAD_LN_NBR, SORD.ORD_NBR AS SORM_ORD_NBR, SORD.LN_NBR AS
SORD_LN_NBR, RMAD.OUT_PART_NBR, SORD.PRODUCT_ID, RMAD.OUT_TRACE_ID,
RMAD.DT_RECEIVED, SORD.DT_CREATED, ZORD.ORD_NBR AS ZORD_ORD_NBR,
ZORD.SALES_SUB_ORD_NBR AS ZORD_SALES_SUB_ORD_NBR FROM RMAM, RMAD, SORD,
ZORD WHERE RMAM.RMA_NBR = RMAD.RMA_NBR AND RMAD.RMA_NBR=SORD.ORD_NBR AND
SORD.PRODUCT_ID=ZORD.PART_NBR AND RMAM.RMA_NBR=ZORD.SALES_ORD_NBR AND
SORD.REC_CD='DT' AND TRIM(SORD.PRODUCT_ID) NOT LIKE '%=_' AND TRIM
(SORD.CNCL_ITM_RSN_CD) Is Null AND RMAD.DT_RECEIVED Is Not Null AND TRIM
(SORD.INVOICE_ID) is null AND ZORD.PART_NBR Not Like '*-R *' AND
ZORD.SERV_ORDER='Y'"
dcSQL = New OleDbCommand(strSQL, myConn)
dcSQL.Transaction = trSQL
dcSQL.ExecuteNonQuery()
trSQL.Commit()
WriteLog(strSQL)
Catch ex As Exception
trSQL.Rollback()
WriteLog("Error processing SQL " & vbCrLf & strSQL & vbCrLf &
ex.Message)
Exit Sub
End Try

Try
strSQL = "COMMIT WORK"
dcSQL = New OleDbCommand(strSQL, myConn)
dcSQL.ExecuteNonQuery()
WriteLog(strSQL)
Catch ex As Exception
WriteLog("Error processing SQL " & vbCrLf & strSQL & vbCrLf &
ex.Message)
Exit Sub
End Try

Try
strSQL = "SELECT /*+ ORDERED */ RMAM.RMA_NBR, SORD.LN_NBR,
TRIM(RMAD.OUT_TRACE_ID), TRIM(RMAM.CUST_ID), TRIM(RMAD.OUT_PART_NBR),
SORD.PRODUCT_ID, RMAD.DT_RECEIVED, SORD.DT_CREATED, SORD.DT_LST_UPDATE,
ZORD.ORD_NBR, ZORD.SALES_SUB_ORD_NBR, OORD.ACTUAL_OPEN_DATE FROM
TEMPODSWIP, RMAM, RMAD, SORD, ZORD, OORD WHERE TEMPODSWIP.RMAM_RMA_NBR =
RMAM.RMA_NBR And TEMPODSWIP.RMAM_RMA_NBR = RMAD.RMA_NBR And
TEMPODSWIP.RMAD_LN_NBR = RMAD.LN_NBR AND TEMPODSWIP.SORM_ORD_NBR =
SORD.ORD_NBR AND TEMPODSWIP.SORD_LN_NBR = SORD.LN_NBR AND
TEMPODSWIP.ZORD_ORD_NBR = ZORD.ORD_NBR AND ZORD.ORD_NBR=OORD.ORD_NBR AND
ZORD.SUB_ORD_NBR=OORD.SUB_ORD_NBR"
Dim daOrders = New OleDbDataAdapter(strSQL, strconn)
'WriteLog(txtSpecificQuery.Text)
If myDS.Tables.Contains("SpecificQuery") Then myDS.Tables
("SpecificQuery").Dispose()
daOrders.fill(myDS, "SpecificQuery")
WriteLog(strSQL & vbCrLf & myDS.Tables("SpecificQuery")
..Rows.Count & " rows returned", EventLogEntryType.Information)
Catch ex As Exception
WriteLog("Error processing SQL" & vbCrLf & strSQL & vbCrLf &
ex.Message)
End Try
Try
strSQL = "DROP TABLE TEMPODSWIP"
dcSQL = New OleDbCommand(strSQL, myConn)
dcSQL.ExecuteNonQuery()
WriteLog(strSQL)
Catch ex As Exception
WriteLog("Error processing SQL " & vbCrLf & strSQL & vbCrLf &
ex.Message)
End Try

Session.Item("myDS") = myDS
Radiobutton8.Checked = True
DataGrid2.CurrentPageIndex = 0
DataGrid2.DataSource = myDS.Tables("SpecificQuery")
DataBind()

The problem is that the commit doesn't appear to be working (despite trying
it two different ways!). I get a temp table, but no data. Very occasionally
I do get data, but I have to idea why!

I basically need to create a temp table to use as a "root" for a series of
related queries, all going off at different tangents in the database from
this subset of about 2,000 records out of 30,000.

Anyone know where my data is going?

--
Message posted via http://www.dotnetmonster.com
Nov 19 '05 #1
1 3544
Thanks everyone, I have sorted it myself ;)

My problem (obvious now) is that the DataAdapter creates a new connection.
The temp table data is connection dependant, so obviously the table
definition persists, but the temp table for the new connection created by
the DataAdapter is empty!

I've pulled the data using a DataReader instead, then converted that to a
DataSet.

--
Message posted via http://www.dotnetmonster.com
Nov 19 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

11
by: Philip D Heady | last post by:
Ok I'm a newbie to using Oracle9i w/ PHP, been a MySQL guy... What is the proper sql statement to use insert tables, etc. as below.? I don't know much about how OciParse works. I can connect...
1
by: Uma | last post by:
Hi.. here is my question.. these are my Oracle scripts . I want the similar concepts in DB2 connect system/manager /********************************************/ /* Create the two roles...
1
by: Mike Landis | last post by:
Hello, Has anyone a small tool or somekind of document which could help me to convert Oracle SQL scripts to SQL Server? Scripts are not very Oracle specified. Thanks, Below is a Script...
2
by: Nelson Xu | last post by:
Hi All Does anyone knows how to pass an array from .net application to oracle stored procedure Thank you in advance Nelson
11
by: jrefactors | last post by:
I want to know the differences between SQL Server 2000 stored procedures and oracle stored procedures? Do they have different syntax? The concept should be the same that the stored procedures...
1
by: Randy | last post by:
Hello All, I'm trying to connect to an Oracle 9i database on a 2000 Pro box using my XP Pro development machine. I've got Oracle client 9i (and .NET 2003) on my dev XP box and Oracle 9i client and...
8
by: YeCkeL | last post by:
Warning: oci_new_connect() : OCIEnvNlsCreate() failed. There is something wrong with your system - please check that ORACLE_HOME is set and points to the right directory in...
2
by: Vinod Sadanandan | last post by:
All, Below listed are the new features in Oracle 11g ,please join me in this discussion to generate a testcase and analyze each of the listed features . Precompilers:...
0
by: Chris Leonard | last post by:
James - you could be running into a known issue with installing Oracle8i software on a P4. Here is a plain-text section of our internal documentation of the issue: Subject/Title: Installing...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.