I've did a program using vb6 to connect to oracle9i, i can establish the connection, the problem is when i execute the query in oracle sql*plus, it can execute successfully, but when run in vb application, the records affected return 0, it do nothing for this query, any setting need to be done?
because this query insert and select to/from different database, i've created a database link for these 2 database, everything work find in oracle sql*plus.
thanks for help.. -
db.Open "Provider=OraOLEDB.Oracle.1;Persist Security Info=False;USER ID=max;PASSWORD=max;Data Source=oracledb"
-
-
sSQL = "INSERT INTO FWDINVOICE_DET@ORACLEAR (COMPANYCODE,BRANCHCODE,INVOICENO,JOBNO,CHARGECODE)" & _
-
" (SELECT FWDINVOICE_DET.COMPANYCODE,FWDINVOICE_DET.BRANCHCODE," & _
-
" FWDINVOICE_DET.InvoiceNo,FWDINVOICE_DET.JobNo,FWDINVOICE_DET.ChargeCode" & _
-
" FROM FWDINVOICE_DET@ORACLEDB,FWDINVOICE_HD@ORACLEDB" & _
-
" Where FWDINVOICE_HD.CompanyCode = FWDINVOICE_DET.CompanyCode" & _
-
" AND FWDINVOICE_HD.BRANCHCODE=FWDINVOICE_DET.BRANCHCODE" & _
-
" AND FWDINVOICE_HD.INVOICENO=FWDINVOICE_DET.INVOICENO" & _
-
" AND ( FWDINVOICE_HD.CANCEL= 'Y' OR FWDINVOICE_HD.APPROVED='Y') AND "
-
sSQL = sSQL & oLib.SQLRangeDate("FWDINVOICE_HD.InvoiceDate", Format(dtDateFrom, "dd-MMM-yyyy"), Format(dtDateTo, "dd-MMM-yyyy"))
-
sSQL = sSQL & ")"
-
-
sSQL = UCase(sSQL)
-
db.Execute sSQL
-
9 2504
I don't know the cause of your problem, but if those dates are going into date/time fields in Access, I think you need to put them in m/d/yyyy format rather than dd-mm-yyyy, and put hashes (#) around them.
You might also need a semicolon on the end of the query.
i've tried using to_char, to_date, trunc, the problem still can't solve..
may i know what is the correct date format?
i've tried using to_char, to_date, trunc, the problem still can't solve..
may i know what is the correct date format?
Generally, in SQL (for Access, at least) the format for a date is American format with hashes around it. Taking today as an example, that would be #11/30/2006#.
Can you tell us what oLib.SQLRangeDa te() does? Or better still, post a copy of what's in sSQL immediately before issuing the Execute.
here is the result from immediate window.
run this query in sql*plus, it returns result, but it returns 0 records affected in when i try to debug it.. -
INSERT INTO FWDINVOICE_DET@ORACLEAR (COMPANYCODE,BRANCHCODE,INVOICENO,JOBNO,CHARGECODE)
-
(SELECT FWDINVOICE_DET.COMPANYCODE,FWDINVOICE_DET.BRANCHCODE, FWDINVOICE_DET.INVOICENO,
-
FWDINVOICE_DET.JOBNO,FWDINVOICE_DET.CHARGECODE
-
FROM FWDINVOICE_DET@ORACLEDB,FWDINVOICE_HD@ORACLEDB
-
WHERE FWDINVOICE_HD.COMPANYCODE = FWDINVOICE_DET.COMPANYCODE
-
AND FWDINVOICE_HD.BRANCHCODE=FWDINVOICE_DET.BRANCHCODE
-
AND FWDINVOICE_HD.INVOICENO=FWDINVOICE_DET.INVOICENO
-
AND ( FWDINVOICE_HD.CANCEL= 'Y' OR FWDINVOICE_HD.APPROVED='Y')
-
AND (FWDINVOICE_HD.INVOICEDATE BETWEEN '30-NOV-2003' AND '30-NOV-2006'))
-
here is the coding for your reference coding in VB -
dtDateFrom = dtpDate1.Value
-
dtDateTo = dtpDate2.Value
-
Set db = New ADODB.Connection
-
db.Open "Provider=OraOLEDB.Oracle.1;Persist Security Info=False;USER ID=max;PASSWORD=max;Data Source=oracledb"
-
-
sSQL = "INSERT INTO FWDINVOICE_DET@ORACLEAR (COMPANYCODE,BRANCHCODE,INVOICENO,JOBNO,CHARGECODE)" & _
-
" (SELECT FWDINVOICE_DET.COMPANYCODE,FWDINVOICE_DET.BRANCHCODE," & _
-
" FWDINVOICE_DET.InvoiceNo,FWDINVOICE_DET.JobNo,FWDINVOICE_DET.ChargeCode" & _
-
" FROM FWDINVOICE_DET@ORACLEDB,FWDINVOICE_HD@ORACLEDB" & _
-
" Where FWDINVOICE_HD.CompanyCode = FWDINVOICE_DET.CompanyCode" & _
-
" AND FWDINVOICE_HD.BRANCHCODE=FWDINVOICE_DET.BRANCHCODE" & _
-
" AND FWDINVOICE_HD.INVOICENO=FWDINVOICE_DET.INVOICENO" & _
-
" AND ( FWDINVOICE_HD.CANCEL= 'Y' OR FWDINVOICE_HD.APPROVED='Y') AND "
-
sSQL = sSQL & oLib.SQLRangeDate("FWDINVOICE_HD.InvoiceDate", Format(dtDateFrom, "dd-mmm-yyyy"), Format(dtDateTo, "dd-Mmm-yyyy"))
-
sSQL = sSQL & ")"
-
-
sSQL = UCase(sSQL)
-
Dim i As Integer
-
db.Execute sSQL, i
-
db.CommitTrans
-
-
Debug.Print sSQL
-
Debug.Print "records return: "; i
-
Debug.Print "Errors: "; Error
-
Debug.Print "DB Error Count: "; db.Errors.Count
-
Debug.Print "Connection Mode: "; db.Mode
-
Stop
-
Result from immediate window
INSERT INTO FWDINVOICE_DET@ ORACLEAR (COMPANYCODE,BR ANCHCODE,INVOIC ENO,JOBNO,CHARG ECODE) (SELECT FWDINVOICE_DET. COMPANYCODE,FWD INVOICE_DET.BRA NCHCODE, FWDINVOICE_DET. INVOICENO,FWDIN VOICE_DET.JOBNO ,FWDINVOICE_DET .CHARGECODE FROM FWDINVOICE_DET@ ORACLEDB,FWDINV OICE_HD@ORACLED B WHERE FWDINVOICE_HD.C OMPANYCODE = FWDINVOICE_DET. COMPANYCODE AND FWDINVOICE_HD.B RANCHCODE=FWDIN VOICE_DET.BRANC HCODE AND FWDINVOICE_HD.I NVOICENO=FWDINV OICE_DET.INVOIC ENO AND ( FWDINVOICE_HD.C ANCEL= 'Y' OR FWDINVOICE_HD.A PPROVED='Y') AND (FWDINVOICE_HD. INVOICEDATE BETWEEN '30-NOV-2003' AND '30-NOV-2006'))
records return: 0
Errors:
DB Error Count: 0
Connection Mode: 0
Ok, for starters I think you might get a better response to this question in the Access forum.
Now, given the SQL string you posted, I can see a couple of things which look a bit odd. Whether they will cause problems, I don't know. You need to keep in mind that I'm a VB6 developer and not an Access expert. With luck, someone more knowledgeable in this area might pick up the thread.
Comments: - Perhaps Access doesn't like "@" in a field name?
- Date formats do not look like Access dates, as mentioned previously.
Here's a modified version. Let me know whether it's any help. Sorry about the layout - I just chopped up the lines so I could more easily identify the pieces involved. - INSERT INTO
-
FWDINVOICE_DET@ORACLEAR
-
(COMPANYCODE, BRANCHCODE, INVOICENO, JOBNO, CHARGECODE)
-
(SELECT
-
FWDINVOICE_DET.COMPANYCODE,
-
FWDINVOICE_DET.BRANCHCO DE,
-
FWDINVOICE_DET.INVOICENO,
-
FWDINVOICE_DET.JOBNO,
-
FWDINVOICE_DET.CHARGECODE
-
FROM
-
FWDINVOICE_DET@ORACLEDB,
-
FWDINVOICE_HD@ORACLEDB
-
WHERE
-
FWDINVOICE_HD.COMPANYCODE = FWDINVOICE_DET.COMPANYCODE
-
AND FWDINVOICE_HD.BRANCHCODE = FWDINVOICE_DET.BRANCHCODE
-
AND FWDINVOICE_HD.INVOICENO = FWDINVOICE_DET.INVOICENO
-
AND (FWDINVOICE_HD.CANCEL= 'Y' OR FWDINVOICE_HD.APPROVED = 'Y')
-
AND (FWDINVOICE_HD.INVOICEDATE BETWEEN #11/30/2003# AND #11/30/2006#)
-
)
here is the coding for your reference ... - ...
-
db.Execute sSQL, i
-
db.CommitTrans
-
...
I'm not saying this is a problem, just curious - did you ever do a BeginTrans?
this query is not for access, is for oracle..
i've mentioned it in the first thread..
I included the db.CommitTrans as well, just forgot to paste it here..sorry man..
this query is not for access, is for oracle..
i've mentioned it in the first thread..
Sorry, I'm getting it mixed up with other threads. (By the way, it was the first post, or message. The "thread" refers to the whole conversation.)
However, you'll find much more SQL expertise in the Access thread. If the problem is the database conenction then you might find some help here - for instance, willakawill seems to know this area quite well.
I can't think of any way to help further, sorry. I'm surprised it has been so quiet - normally a couple of people would have jumped into the conversation by now.
I included the db.CommitTrans as well, just forgot to paste it here..sorry man..
You mean the BeginTrans, I hope. :)
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Ruben Schoenefeld |
last post by:
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Hi -
after I got sql*plus to work on my Linux box and I recompiled PHP 5 to include
the oracle instant client, I run into a weird problem:
I get 'ORA-01017: invalid username/password; logon denied' when using the same
combination of username/password and Oracle instance that works in...
|
by: valexena |
last post by:
In order to set SQL*PLUS session so that NLS_DATE_FORMAT information is
altered in a specific way every time I log into Oracle which method
would be used?
--
Posted via http://dbforums.com
|
by: GP |
last post by:
Consider the following: (extracted from a .bat)
sqlplus toto/titi ^
@%pdl%\islqz033 ^
'1 ' ^
'aaa' ^
' ' ^
'zzz' ^
....
|
by: Peter |
last post by:
Has anyone seen this before?
I start SQL*Plus, and login by typing
sqlplus Quantum/Password@BPrd
I type:
select '&1' from dual;
it responds
|
by: Miori |
last post by:
Dear all,
Server machine running Oracle Database Server on Linux
and a Client machine running Oracle Client on WIndows XP.
HOw it is possible to shut down/start up the Oracle database
on the server from SQL*Plus of the client. I know it can be done from
SQL*Plus of the server but the point is that I want to do it from
SQL*Plus of the...
| |
by: Ant |
last post by:
Hi,
I have an SQL assignment to do and at my school we use SQL *Plus there
however I don't have Oracle at home, where I would like to do the work ,so I
was wondering whats the easiest way to get an SQL environment up so I can
code in that then just paste it into SQL *Plus later.
I don't really want to install Oracle on my home pc and I...
|
by: gomathy |
last post by:
Hello All!
I am newbie to oracle. As a first step, i tried to install oracle sql*plus instant client on my machine to start working with sql simple commands like "table creation etc".
This installation was successfull. But when i tried to access from command line, i was prompted to enter username and password. I have no clue to what should...
|
by: DTV12345 |
last post by:
Greetings!
This is an excerpt from the Oracle documentation:"...ORACLE SQL*Plus BREAK command creates a subset of records and add space and/or summary lines after each subset. The column you specify in a BREAK command is called a break column which suppresses duplicate values. For example
SQL> BREAK ON DEPTNO SKIP 1 // To insert...
|
by: ghssal |
last post by:
HI
I am using ORACLE forms and trying to insert a new order, by enter the customer_ID and i will get the latest order
för this customer and save the new order with new order_date.
I use this Trigger
select .....
from customer_order, (
select customer_ID AS B, MAX(order_date) AS S
from customer_order
|
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it. ...
| |
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
|
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
|
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
|
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |