WItam,
Stworzyłem bardzo "upośledzony" generator danych losowych w SQL DEVELOPER. np. dla tabeli
create table klient(
ID_klienta INTEGER primary key,
imie varchar2(15),
nazwisko varchar2(15),
ulica varchar2(30),
miejscowosc varchar2(30),
pesel varchar2(11),
mail varchar2(30),
telefon_kontaktowy varchar2(20),
uwagi varchar2(100)
);
mam kodzik
BEGIN
FOR loop_counter IN 1..1000 LOOP
INSERT INTO "KLIENT" (ID_KLIENTA, IMIE, NAZWISKO, ULICA, miejscowosc, PESEL, mail, telefon_kontaktowy, uwagi)
VALUES (loop_counter, dbms_random.value(1,1000),dbms_random.value(1,1000),dbms_random.value(1,1000),dbms_random.value(1,1000),dbms_random.value(11111111111,9999999999),dbms_random.value(11111111111,9999999999)+'@gmail.com', dbms_random.value(555555555,799999999),'opis'
);
END LOOP;
COMMIT;
END;
A SQL DEVELOPER wyrzuca błąd
Error report -
ORA-12899: wartość zbyt duża dla kolumny "S91405"."KLIENT1"."IMIE" (obecna: 40, maksymalna: 15)
ORA-06512: przy linia 3
12899. 00000 - "value too large for column %s (actual: %s, maximum: %s)"
*Cause: An attempt was made to insert or update a column with a value
which is too wide for the width of the destination column.
The name of the column is given, along with the actual width
of the value, and the maximum allowed width of the column.
Note that widths are reported in characters if character length
semantics are in effect for the column, otherwise widths are
reported in bytes.
*Action: Examine the SQL statement for correctness. Check source
and destination column data types.
Either make the destination column wider, or use a subset
of the source column (i.e. use substring).
Zwiększyłem więc limity z do 40 i dostaję bład
Error report -
ORA-01536: przekroczenie limitu w przestrzeni tabel 'STUDTBS1'
ORA-06512: przy linia 3
01536. 00000 - "space quota exceeded for tablespace '%s'"
*Cause: The space quota for the segment owner in the tablespace has
been exhausted and the operation attempted the creation of a
new segment extent in the tablespace.
*Action: Either drop unnecessary objects in the tablespace to reclaim
space or have a privileged user increase the quota on this
tablespace for the segment owner.
Przy tabeli PRACOWNIK
create table pracownik(
ID_pracownika INTEGER primary key,
imie varchar2(50),
nazwisko varchar2(50),
stanowisko varchar2(15),
pesel varchar2(11),
ulica varchar2(30),
miejscowosc varchar2(30),
mail varchar2(30),
telefon_kontaktowy varchar(15),
pensja varchar2(10),
data_zatrudnienia date
);
i kodzie
BEGIN
FOR loop_counter IN 1..1000 LOOP
INSERT INTO "PRACOWNIK" (id_pracownika, imie, nazwisko, stanowisko, pesel, ulica, miejscowosc, mail, telefon_kontaktowy, pensja, data_zatrudnienia)
VALUES (loop_counter, DBMS_RANDOM.value(1,1000),DBMS_RANDOM.value(1,1000),DBMS_RANDOM.value(1,1000),DBMS_RANDOM.value(1,1000), DBMS_RANDOM.value(1,1000),DBMS_RANDOM.value(1,1000),DBMS_RANDOM.value(1,1000),DBMS_RANDOM.value(1,1000),DBMS_RANDOM.value(1,1000),DBMS_RANDOM.VALUE(TO_CHAR(DATE '2000-01-01','J') ,TO_CHAR(DATE '9999-12-31','J'))
);
END LOOP;
COMMIT;
END;
Dostaję za to taki błąd
Error report -
ORA-06550: linia 4, kolumna 704:
PL/SQL: ORA-00932: niespójne typy danych: oczekiwano DATE, uzyskano NUMBER
ORA-06550: linia 3, kolumna 1:
PL/SQL: SQL Statement ignored
06550. 00000 - "line %s, column %s:\n%s"
*Cause: Usually a PL/SQL compilation error.
*Action:
I o ile to zrozumiałem i sprawdziłem to wg mnie DBMS_RANDOM.VALUE(TO_CHAR(DATE '2000-01-01','J') ,TO_CHAR(DATE '9999-12-31','J')) dodaje wartość DATE która jest zadeklarowana a program twierdzi inaczej...
Czy ktoś może mnie nakierować jak to naprawić?