473,397 Members | 1,950 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,397 software developers and data experts.

PL SQL Cursor beginner

Hi
I'm beginning with PL SQL and try to learn cursors usage
I get ora 920 with this on line "WHERE WHERE_NORME "
What i'm trying to do is to fetch where conditions stored in a table,
and reuse it in dml order in my cursor.. but I must have missed
somethin ? any pl sql killer having one minute for me ? thank's

CREATE OR REPLACE PROCEDURE Feed_Anomalie AS
CURSOR NORMES IS
SELECT ID_NORME, TABLE_NORME, WHERE_NORME FROM QTE_NORMES ORDER BY
ID_NORME;
ID_NORME QTE_NORMES.ID_NORME%TYPE;
TABLE_NORME QTE_NORMES.TABLE_NORME%TYPE;
WHERE_NORME QTE_NORMES.WHERE_NORME%TYPE;

BEGIN
OPEN NORMES;

LOOP
FETCH NORMES INTO ID_NORME , TABLE_NORME , WHERE_NORME ;
EXIT WHEN NORMES%NOTFOUND;
INSERT INTO QTE_ENREGISTREMENT_NC
(NUM_DOSS, DATE_NC, LAST_DATE_NC, REF_NORME)
SELECT DISTINCT CLE_DOSS, SYSDATE, SYSDATE, ID_NORME
FROM (
SELECT
DOSSIER.CLE_DOSS, SYSDATE, SYSDATE, ID_NORME
FROM TABLE_NORME
WHERE WHERE_NORME
MINUS
SELECT QTE_ENREGISTREMENT_NC.NUM_DOSS , SYSDATE, SYSDATE, ID_NORME
FROM QTE_ENREGISTREMENT_NC );
END LOOP;
CLOSE NORMES;
END;
/
Jul 19 '05 #1
3 43111
mrique wrote:
Hi
I'm beginning with PL SQL and try to learn cursors usage
I get ora 920 with this on line "WHERE WHERE_NORME "
What i'm trying to do is to fetch where conditions stored in a table,
and reuse it in dml order in my cursor.. but I must have missed
somethin ? any pl sql killer having one minute for me ? thank's

CREATE OR REPLACE PROCEDURE Feed_Anomalie AS
CURSOR NORMES IS
SELECT ID_NORME, TABLE_NORME, WHERE_NORME FROM QTE_NORMES ORDER BY
ID_NORME;
ID_NORME QTE_NORMES.ID_NORME%TYPE;
TABLE_NORME QTE_NORMES.TABLE_NORME%TYPE;
WHERE_NORME QTE_NORMES.WHERE_NORME%TYPE;

BEGIN
OPEN NORMES;

LOOP
FETCH NORMES INTO ID_NORME , TABLE_NORME , WHERE_NORME ;
EXIT WHEN NORMES%NOTFOUND;
INSERT INTO QTE_ENREGISTREMENT_NC
(NUM_DOSS, DATE_NC, LAST_DATE_NC, REF_NORME)
SELECT DISTINCT CLE_DOSS, SYSDATE, SYSDATE, ID_NORME
FROM (
SELECT
DOSSIER.CLE_DOSS, SYSDATE, SYSDATE, ID_NORME
FROM TABLE_NORME
WHERE WHERE_NORME
MINUS
SELECT QTE_ENREGISTREMENT_NC.NUM_DOSS , SYSDATE, SYSDATE, ID_NORME
FROM QTE_ENREGISTREMENT_NC );
END LOOP;
CLOSE NORMES;
END;
/


You cannot build a where clause like this; you
need dynamic sql, e.g.
execute immediate ('QTE_ENREGISTREMENT_NC
(NUM_DOSS, DATE_NC, LAST_DATE_NC, REF_NORME)
SELECT DISTINCT CLE_DOSS, SYSDATE, SYSDATE, ID_NORME
FROM (
SELECT
DOSSIER.CLE_DOSS, SYSDATE, SYSDATE, ID_NORME
FROM TABLE_NORME
WHERE :W ' using where_norme;

Due to the overhead in parsing, etc, this is not
a way of coding I would advocate
--
Regards,
Frank van Bortel
Jul 19 '05 #2
thank you I did not know about dynamique sql so I found some tutorial and will learn
Jul 19 '05 #3
thank you I did not know about dynamique sql so I found some tutorial and will learn
Jun 27 '08 #4

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

Similar topics

15
by: Philip Mette | last post by:
I am begginner at best so I hope someone that is better can help. I have a stored procedure that updates a view that I wrote using 2 cursors.(Kind of a Inner Loop) I wrote it this way Because I...
2
by: Vitali Stolpner | last post by:
hi all, im trying to make a program in c++ (trying to make textris, im just a beginner so im not using anything fancy, just text) and the problem that i run into is the cursor flashing all over the...
2
by: dave | last post by:
In my form Ive got a SaveData() routine that saves changes to a DB. When I encounter an exception in the save operations, I am having trouble chaning the cursor back to the default cursor, it just...
5
by: Lespaul36 | last post by:
I have a mdi app. I need to change the cursor when I click on certain button on a form that I made into a toolbar. I tried to use cursor.current. But the cursor won't show. if I change the form...
10
by: Just Me | last post by:
Does Me.Cursor.Current=Cursors.WaitCursor set the current property of Me.Cursor to Cursors.WaitCursor And Me.Cursor.Current=Cursors.Default set the Me.Current property to something (default)...
3
by: IW2FIV | last post by:
I'm a really beginner about sql2000. During my test I have created the following query. It's works ok until I do't add the code included in section A, when I add it the i obtain the error: Cursor...
0
debasisdas
by: debasisdas | last post by:
RESTRICTIONS ON CURSOR VARIABLES ================================= Currently, cursor variables are subject to the following restrictions: Cannot declare cursor variables in a package spec. ...
7
by: everlast | last post by:
1) is there another way to move the cursor besides the escape sequences in win32 console applications? 2) i want to move my cursor up, or to be precise - backward. example: my code generates...
1
by: akscol | last post by:
I have created a panel in visual basics which has buttons.These buttons when clicked open respective applications to which its directed for eg microsoft word, internet explorer, etc.I have also...
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
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
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
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,...

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.