473,409 Members | 2,004 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,409 software developers and data experts.

PROC Problem : Select for update

Hello,
I am working with Oracle 9Ri2 version on Linux AS 2.1 for IA64.

I have a problem when i try to lanch the following program :
EXEC SQL PREPARE MyStmt FROM
SELECT CHAMP1 FROM TAB1 WHERE CHAMP2="4" AND CHAMP3 = "C" FOR
UPDATE;

EXEC SQL DECLARE MyCursor CURSOR FOR MyStmt;

EXEC SQL OPEN MyCursor;

EXEC SQL DESCRIBE MyStmt into q_APP;
EXEC SQL FETCH MyCursor into :Var1;

EXEC SQL CLOSE MyCursor;

When I don't use the PREPARE Statement i don't have problem. But when
i add the PREPARE statement program crached when it try to Open Cursor
( EXEC SQL OPEN MyCursor)

Thank you for your help.
Jul 19 '05 #1
4 13770
rb*******@hotmail.com (Oracle 9Ri2 AS 2.1 IA 64) wrote in message news:<7f**************************@posting.google. com>...
Hello,
I am working with Oracle 9Ri2 version on Linux AS 2.1 for IA64.

I have a problem when i try to lanch the following program :
EXEC SQL PREPARE MyStmt FROM
SELECT CHAMP1 FROM TAB1 WHERE CHAMP2="4" AND CHAMP3 = "C" FOR
UPDATE;

EXEC SQL DECLARE MyCursor CURSOR FOR MyStmt;

EXEC SQL OPEN MyCursor;

EXEC SQL DESCRIBE MyStmt into q_APP;
EXEC SQL FETCH MyCursor into :Var1;

EXEC SQL CLOSE MyCursor;

When I don't use the PREPARE Statement i don't have problem. But when
i add the PREPARE statement program crached when it try to Open Cursor
( EXEC SQL OPEN MyCursor)

Thank you for your help.


Try using PL/SQL

declare
cursor work_cur is
SELECT CHAMP1 FROM TAB1 WHERE CHAMP2="4" AND CHAMP3 = "C" FOR UPDATE;
begin
for x in work_cur loop
update tab1 set champ1 = 'test'
where current of work_cur;

end loop;

commit;
end;
/
Jul 19 '05 #2
J
rb*******@hotmail.com (Oracle 9Ri2 AS 2.1 IA 64) wrote in message news:<7f**************************@posting.google. com>...
Hello,
I am working with Oracle 9Ri2 version on Linux AS 2.1 for IA64.

I have a problem when i try to lanch the following program :
EXEC SQL PREPARE MyStmt FROM
SELECT CHAMP1 FROM TAB1 WHERE CHAMP2="4" AND CHAMP3 = "C" FOR
UPDATE;

EXEC SQL DECLARE MyCursor CURSOR FOR MyStmt;

EXEC SQL OPEN MyCursor;

EXEC SQL DESCRIBE MyStmt into q_APP;
EXEC SQL FETCH MyCursor into :Var1;

EXEC SQL CLOSE MyCursor;

When I don't use the PREPARE Statement i don't have problem. But when
i add the PREPARE statement program crached when it try to Open Cursor
( EXEC SQL OPEN MyCursor)

Thank you for your help.


You don't need a prepare as u are not using any bind variables.
Also i wonder why u are using describe . its not needed.

Best Regards
J
Jul 19 '05 #3
r0***@insightbb.com (Wario) wrote in message news:<92**************************@posting.google. com>...
rb*******@hotmail.com (Oracle 9Ri2 AS 2.1 IA 64) wrote in message news:<7f**************************@posting.google. com>...
Hello,
I am working with Oracle 9Ri2 version on Linux AS 2.1 for IA64.

I have a problem when i try to lanch the following program :
EXEC SQL PREPARE MyStmt FROM
SELECT CHAMP1 FROM TAB1 WHERE CHAMP2="4" AND CHAMP3 = "C" FOR
UPDATE;

EXEC SQL DECLARE MyCursor CURSOR FOR MyStmt;

EXEC SQL OPEN MyCursor;

EXEC SQL DESCRIBE MyStmt into q_APP;
EXEC SQL FETCH MyCursor into :Var1;

EXEC SQL CLOSE MyCursor;

When I don't use the PREPARE Statement i don't have problem. But when
i add the PREPARE statement program crached when it try to Open Cursor
( EXEC SQL OPEN MyCursor)

Thank you for your help.


Try using PL/SQL

declare
cursor work_cur is
SELECT CHAMP1 FROM TAB1 WHERE CHAMP2="4" AND CHAMP3 = "C" FOR UPDATE;
begin
for x in work_cur loop
update tab1 set champ1 = 'test'
where current of work_cur;

end loop;

commit;
end;
/

Why use the declare?

begin
for x in (
SELECT CHAMP1
FROM TAB1
WHERE CHAMP2="4"
AND CHAMP3 = "C" FOR UPDATE
)
loop
update tab1 set champ1 = 'test'
where current of work_cur;

end loop;

commit;
end;
Jul 19 '05 #4
> >
Try using PL/SQL

declare
cursor work_cur is
SELECT CHAMP1 FROM TAB1 WHERE CHAMP2="4" AND CHAMP3 = "C" FOR UPDATE;
begin
for x in work_cur loop
update tab1 set champ1 = 'test'
where current of work_cur;

end loop;

commit;
end;
/

Why use the declare?

begin
for x in (
SELECT CHAMP1
FROM TAB1
WHERE CHAMP2="4"
AND CHAMP3 = "C" FOR UPDATE
)
loop
update tab1 set champ1 = 'test'
where current of work_cur;

end loop;

commit;
end;


Danes,

I like declares. In this case I use it to add readability, as long as
performance is not affected. Your suggestion works great though.

Wario
Jul 19 '05 #5

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

Similar topics

13
by: EmbersFire | last post by:
I'm using a stored proceedure which should update a number of rows in a table depending on a key value supplied (in this case 'JobID'). But what's happening is when I call the proc from within the...
6
by: CJM | last post by:
I've created a Stored Procedure which adds a new record and updates some more records and then returns the primary key for the added record. The SP seems to work OK, but I'm having problems...
4
by: CSDunn | last post by:
Hello, I have a combo box (Combo7) that needs to call a function during the After Update event of the combo box. The function resides in an Access 2000 ADP Module called MMAnswerData_code. The...
0
by: CSDunn | last post by:
Hello, In Access ADP's that connect to SQL Server databases, any time I have a situation where I have a combo box in a main form that looks up a record in a subform, the subform record source has...
14
by: Roy | last post by:
Apologies for the cross-post, but this truly is a two-sided question. Given the option of creating Looping statements within a stored proc of sql server or in the code-behind of an .net webpage,...
1
by: Phil Mc | last post by:
Trying to call a stored proc but some times don't want to have values inserted in some fields. Hi I am rewriting a VBS script which called a stored proc in a SQL server db. The proc takes a...
10
by: syntego | last post by:
I think I have discovered a bug in the handling of null values (vs NULL values) passed as parameters to a stored proc. I have always believed that the database handled NULL and null the same. ...
4
by: Trevor Bishop | last post by:
I'm having problems calling my second proc (MyProcedure2) from within an existing proc. MyProcedure2 does not seeem to fire this way. My code is below. Help appreciated. Thanks, Trevor ALTER...
3
by: ocmeng | last post by:
Dear All, I am kinda new to Oracle and need to work on a stored proc to update some data. However, I am getting compilation error for the following stored proc and got no idea on how to resolve...
2
by: JeffRoughgarden | last post by:
To minimize the very large number of stored procedures typically associated with an application, I have gotten in the habit of combining a select, insert, update, and delete all in one procedure,...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
Oralloy
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,...
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
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...
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.