Forum » Programiranje » [DBeaver] Zakaj javlja "SQL semantic error foreground"? Procedura je sicer okey-iš.
[DBeaver] Zakaj javlja "SQL semantic error foreground"? Procedura je sicer okey-iš.
HotBurek ::
Dobro jutro.
Evo, nov večer, nov izziv.
V DBeaver software-u (Version 23.3.1.202312241705) v SQL Editor-ju sem naredil preprosto proceduro s parametrom.
Zanimivo je, da SQL Editor v zadnji vrstici "p_parameter1" označi kot "SQL semantic error foreground" (sem preveril z spremembo barve in je to ta prav error).
Zakaj javlja (oz. obarva) p_parameter1 kot napako?
p.s.: Isto je, če parameter poimenujem z @ na začetku (npr. @parameter1); v tem primeru z rdečo označi (in podrčrta) vse, kar sledi od afne naprej do podpičja.
Pa še to. Če se z miško gor postavim, ne dobim nobenega tool (ali cool) tip-a.
Evo, nov večer, nov izziv.
V DBeaver software-u (Version 23.3.1.202312241705) v SQL Editor-ju sem naredil preprosto proceduro s parametrom.
# set parameter SET p_parameter1 = 'test'; # select SELECT * FROM `table1` WHERE `column1` = p_parameter1;
Zanimivo je, da SQL Editor v zadnji vrstici "p_parameter1" označi kot "SQL semantic error foreground" (sem preveril z spremembo barve in je to ta prav error).
Zakaj javlja (oz. obarva) p_parameter1 kot napako?
p.s.: Isto je, če parameter poimenujem z @ na začetku (npr. @parameter1); v tem primeru z rdečo označi (in podrčrta) vse, kar sledi od afne naprej do podpičja.
Pa še to. Če se z miško gor postavim, ne dobim nobenega tool (ali cool) tip-a.
root@debian:/# iptraf-ng
fatal: This program requires a screen size of at least 80 columns by 24 lines
Please resize your window
fatal: This program requires a screen size of at least 80 columns by 24 lines
Please resize your window
Ahim ::
1: Tisti @ ni za hec.
2: Sintaksa pri deklaraciji procedure ni pravilna, glavnina problema je opisana tukaj: https://dev.mysql.com/doc/refman/8.0/en... - preberi in popravi, pa bo delalo.
2: Sintaksa pri deklaraciji procedure ni pravilna, glavnina problema je opisana tukaj: https://dev.mysql.com/doc/refman/8.0/en... - preberi in popravi, pa bo delalo.
HotBurek ::
Evo, našel sem še en primer.
CREATE PROCEDURE database1.test1() BEGIN SET @test1 = 'aaa'; SELECT @test1 AS 'something'; END
root@debian:/# iptraf-ng
fatal: This program requires a screen size of at least 80 columns by 24 lines
Please resize your window
fatal: This program requires a screen size of at least 80 columns by 24 lines
Please resize your window
Zgodovina sprememb…
- spremenilo: HotBurek ()
no comment ::
HotBurek ::
Primer tega, da za ukaz:
SELECT @parameter1 AS 'something';
DBeaver označi "test" (odebeljeno) z rdečo barvo, kar pomeni da gre za "SQL semantic error foreground" napako. To se vidi na priloženi sliki (zgoraj za oba dva primera).
In rad bi vedel, zakaj pride do te napake ter kako jo odpravit. Ker, danes je ta error soft, jutri po nadgradnji bo pa hard.
SELECT @parameter1 AS 'something';
DBeaver označi "test" (odebeljeno) z rdečo barvo, kar pomeni da gre za "SQL semantic error foreground" napako. To se vidi na priloženi sliki (zgoraj za oba dva primera).
In rad bi vedel, zakaj pride do te napake ter kako jo odpravit. Ker, danes je ta error soft, jutri po nadgradnji bo pa hard.
root@debian:/# iptraf-ng
fatal: This program requires a screen size of at least 80 columns by 24 lines
Please resize your window
fatal: This program requires a screen size of at least 80 columns by 24 lines
Please resize your window
Zgodovina sprememb…
- spremenilo: HotBurek ()
HotBurek ::
Mimo grede. Zanimivo je, da za iskalni niz:
DBeaver "SQL semantic error foreground"
Vsi štirje iskalniki (Google, Qwant, Yandex, Bing) najdejo samo en rezultat. In to je ta tema.
DBeaver "SQL semantic error foreground"
Vsi štirje iskalniki (Google, Qwant, Yandex, Bing) najdejo samo en rezultat. In to je ta tema.
root@debian:/# iptraf-ng
fatal: This program requires a screen size of at least 80 columns by 24 lines
Please resize your window
fatal: This program requires a screen size of at least 80 columns by 24 lines
Please resize your window
Zgodovina sprememb…
- spremenilo: HotBurek ()
HotBurek ::
Sem preveril in ne reši zadeve.
Za prvi del dodaja, da je dobro pravilo uporabit DECLARE.
ChatGPT
The SQL code you provided is a valid syntax for creating a stored procedure in MariaDB. However, there is a small issue that should be addressed:
Declare the Variable:
Before using the variable @parameter1, it's a good practice to declare it. You can add a DECLARE statement at the beginning of your stored procedure to declare the variable.
Primer kode, ki jo zgenerira:
Na vprašanje, kako pravilno prebrat variable, dogovori:
ChatGPT
In MariaDB, you can read the value of a variable using the SELECT statement. If you want to retrieve the value of a user-defined variable, you can use the SELECT statement with the @ symbol followed by the variable name.
Primer kode, ki jo zgenerira:
Če oba primera zgornje kode skopiram v DBeaver, mi za vsak parameter (parameter1, @example_variable), ki je po SELECT-u, le tega pobarva in podčrta z rdečo.
Zanimivo, da iskalnik google nikjer na internetih ne najde nič za iskalni niz "SQL semantic error foreground". Da bi si prebral, od kje ta error in kakšne semple, zakaj do tega pride.
Prav tako sem kodo dal v validator ( https://www.coderstool.com/sql-syntax-c... ), ki pravi "Great!. Valid syntax."
Za prvi del dodaja, da je dobro pravilo uporabit DECLARE.
ChatGPT
The SQL code you provided is a valid syntax for creating a stored procedure in MariaDB. However, there is a small issue that should be addressed:
Declare the Variable:
Before using the variable @parameter1, it's a good practice to declare it. You can add a DECLARE statement at the beginning of your stored procedure to declare the variable.
Primer kode, ki jo zgenerira:
CREATE PROCEDURE `database1`.`test1`() BEGIN DECLARE parameter1 INT; -- Declare the variable SET parameter1 = 5; SELECT parameter1 AS 'count'; END;
Na vprašanje, kako pravilno prebrat variable, dogovori:
ChatGPT
In MariaDB, you can read the value of a variable using the SELECT statement. If you want to retrieve the value of a user-defined variable, you can use the SELECT statement with the @ symbol followed by the variable name.
Primer kode, ki jo zgenerira:
DELIMITER // CREATE PROCEDURE `database1`.`test2`() BEGIN -- Declare and set a variable SET @example_variable = 10; -- Read the value of the variable SELECT @example_variable AS 'VariableValue'; END // DELIMITER ;
Če oba primera zgornje kode skopiram v DBeaver, mi za vsak parameter (parameter1, @example_variable), ki je po SELECT-u, le tega pobarva in podčrta z rdečo.
Zanimivo, da iskalnik google nikjer na internetih ne najde nič za iskalni niz "SQL semantic error foreground". Da bi si prebral, od kje ta error in kakšne semple, zakaj do tega pride.
Prav tako sem kodo dal v validator ( https://www.coderstool.com/sql-syntax-c... ), ki pravi "Great!. Valid syntax."
root@debian:/# iptraf-ng
fatal: This program requires a screen size of at least 80 columns by 24 lines
Please resize your window
fatal: This program requires a screen size of at least 80 columns by 24 lines
Please resize your window
Zgodovina sprememb…
- spremenilo: HotBurek ()
HotBurek ::
Prav tako tega teksta (SQL semantic error foreground) nisem našel na https://github.com/dbeaver/dbeaver
root@debian:/# iptraf-ng
fatal: This program requires a screen size of at least 80 columns by 24 lines
Please resize your window
fatal: This program requires a screen size of at least 80 columns by 24 lines
Please resize your window
Vredno ogleda ...
Tema | Ogledi | Zadnje sporočilo | |
---|---|---|---|
Tema | Ogledi | Zadnje sporočilo | |
» | [SQL] Referenca na parameter v proceduriOddelek: Programiranje | 1383 (1096) | Ahim |
» | Branje slik jpg iz MySQL z PHPOddelek: Izdelava spletišč | 2404 (2022) | a-ptuj1 |
» | [ORACLE][Novinec]Resitev napake PLS-00428Oddelek: Programiranje | 715 (625) | smejko |
» | [PHP]Zajem podatkov iz bazeOddelek: Programiranje | 4038 (3675) | cobrica |
» | sql-t stored procedureOddelek: Programiranje | 1058 (925) | detroit |