| |

VerySource

 Forgot password?
 Register
Search
View: 837|Reply: 4

Oracle ODBC development issues?

[Copy link]

1

Threads

2

Posts

3.00

Credits

Newbie

Rank: 1

Credits
3.00

 China

Post time: 2020-3-3 07:00:01
| Show all posts |Read mode
The oracle table (worker) is defined as:
workid number 10
workname varchar2 10

The stored procedure (pwork) is defined as
 (
pworkid in worker.workid% type,
pworkname in worker.workname% type
)
as
begin
insert into worker (workid, workname) values ​​(pworkid, pworkname);
end;

I wrote a program as follows:
int main ()
{
DBHANDLE * pDBHandle;
SQLUINTEGER PartID;
SQLCHAR PartName [10];
SQLINTEGER PartIDInd = 0, PartNameInd = 0;
SQLRETURN ret = 0;
Ranch
Programs such as connecting to the database (omitted)
Ranch
if (SQL_SUCCESS! = SQLBindParameter (pDBHandle-> hSTMT, 1, SQL_PARAM_INPUT, SQL_C_SLONG, SQL_INTEGER, 0, 0,&PartID, 0,&PartIDInd))
printf ("Error: SQLBindParameter.\n");
if (SQL_SUCCESS! = SQLBindParameter (pDBHandle-> hSTMT, 2, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_CHAR, 10, 0, PartName, 0,&PartNameInd))
printf ("Error: SQLBindParameter.\n");

Ranch
PartID = 1024;
strcpy (PartName, "ABC");
Ranch
if (mDBSuccess! = SQLExecDirect (pDBHandle-> hSTMT, "{call pwork (?,?)}", SQL_NTS))
{
printf ("ERROR.\n");
return -1;
}
Ranch

return 0;
}

The question is:
The query is as follows:
10:55:25 10:55:25
    WORKID WORKNAME
---------- ----------
      1024

1 row selected.

That is, why the data "ABC" of WORKNAME is not stored in the database. I checked it for a long time, I don't know? Hope to know who can give pointers!
Reply

Use magic Report

0

Threads

1

Posts

2.00

Credits

Newbie

Rank: 1

Credits
2.00

 China

Post time: 2020-5-14 16:45:01
| Show all posts
Whether the transaction is committed
The stored procedure (pwork) is defined as
 (
pworkid in worker.workid% type,
pworkname in worker.workname% type
)
as
begin
insert into worker (workid, workname) values ​​(pworkid, pworkname);
----
commit;
end;

Try
Reply

Use magic Report

0

Threads

71

Posts

50.00

Credits

Newbie

Rank: 1

Credits
50.00

 China

Post time: 2020-5-14 23:30:02
| Show all posts
Why the data "ABC" of WORKNAME is not saved in the database,


If you do n’t commit, if you do n’t, it will not be submitted to the database.
Reply

Use magic Report

1

Threads

2

Posts

3.00

Credits

Newbie

Rank: 1

Credits
3.00

 United States

 Author| Post time: 2020-5-15 23:30:01
| Show all posts
I changed the stored procedure to the following, it still doesn't work
 (
pworkid in worker.workid% type,
pworkname in worker.workname% type
)
as
begin
insert into worker (workid, workname) values ​​(pworkid, pworkname);
commit;
end;

In addition, I can directly enter the following statement in sqlplus to store, no matter whether there is a commit statement
begin
pwork (123, 'abc');
end;

So I feel like there is a problem with my program!
Reply

Use magic Report

0

Threads

6

Posts

6.00

Credits

Newbie

Rank: 1

Credits
6.00

 China

Post time: 2020-6-6 17:30:01
| Show all posts
You developed it using oci
The problem is that when you open your transaction, you use the request to display the commit. Therefore, you must call the function submitted by the transaction. Or when creating a connection, use a function that can be automatically submitted.
In sqlplus, you see it on the surface. If you enter after exiting sqlplus, you will not see the data you inserted. That's because you are looking at the dirty data that you inserted (or did not quit, when you opened a sqlplus, you can't see the data you inserted).
Reply

Use magic Report

You have to log in before you can reply Login | Register

Points Rules

Contact us|Archive|Mobile|CopyRight © 2008-2023|verysource.com ( 京ICP备17048824号-1 )

Quick Reply To Top Return to the list