UPDATE: How to fix SQL error in procedure statement : NEW ERROR

108 views Asked by At

Im creating sql database and i have many different tables connectdd with different entity relationships.

Im currently working on 1:N relationship and im population data to tables using procedures.

I've made a little progress but i keep stumbling on tiny erros and i have problems fixing them.

I just got into one which i just cannot fix. I've been looking at a cold for like an hour now and im guess it might be right there but i just can't see it.

Anyway...

This is the code

Table

CREATE TABLE CENIK (
ID_CENIK INTEGER NOT NULL,
CENA NUMBER(10) NOT NULL,
DATUM_OD DATE NOT NULL,
DATUM_DO DATE NOT NULL,
TK_ID_ARTIKEL NUMBER(10) NOT NULL
);

ALTER TABLE CENIK
ADD (CONSTRAINT PK_CENIK PRIMARY KEY (ID_CENIK));

ALTER TABLE CENIK
ADD (CONSTRAINT TK_CENIK_ID_ARTIKEL FOREIGN KEY
(TK_ID_ARTIKEL) REFERENCES ARTIKEL(ID_ARTIKEL));

Procedure code

--polnjenje tabele cenik
PROCEDURE polni_cenik(stevilo_cenikov NUMBER) IS
cena_artikla NUMBER(10);
datum_od DATE;
datum_do DATE;
c_tk_id_artikel NUMBER(10);
c_stevilo_artiklov int;
BEGIN
    SELECT MAX(ID_ARTIKEL) INTO c_stevilo_artiklov FROM ARTIKEL;
    FOR st14 IN 1..stevilo_cenikov LOOP
        cena_artikla := dbms_random.value(1,9999);
        datum_od := SYSDATE();
        datum_do := SYSDATE();
        datum_od := datum_od - dbms_random.value(0,1000);
        datum_do := datum_do + dbms_random.value(0,1000);
        c_tk_id_artikel := round(dbms_random.value(1,c_stevilo_artiklov));
        INSERT INTO CENIK(ID_CENIK, DATUM_OD, DATUM_DO, TK_ID_ARTIKEL)
        VALUES (st14, datum_od, datum_do, c_tk_id_artikel);
        dbms_output.put_line (st14);
    END LOOP;
COMMIT;
END;

And this is the error

enter image description here

1

There are 1 answers

4
Sebas On BEST ANSWER

ime_kraja := ||' '|| TO_CHAR(st); should be ime_kraja := TO_CHAR(st); or you forgot something before the first ||.