Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> Zmienne nie działają
czezz
post
Post #1





Grupa: Zarejestrowani
Postów: 141
Pomógł: 0
Dołączył: 24.07.2003

Ostrzeżenie: (10%)
X----


Wykonuje takiego select'a:
  1. variable x number;
  2. variable y number;
  3. variable a number;
  4.  
  5. define x = 2000;
  6. define y = 2*1000;
  7. define a = &x+&y;
  8. SELECT ener FROM adding WHERE ener = &a;


Jeżeli uruchomie to w SQL*Plus Worksheet (klient zainstalowany na moim PeCecie) to wynik jest taki:
  1. ENER
  2. ------
  3. 4000
  4. 1 row selected


ale jeżeli wykonam to samo pod sqlplus'em - command line'owym (tym dostępnym w shellu unixowym) to wynik jest taki:
  1. old 1: SELECT ener FROM adding WHERE ener = &a
  2. new 1: SELECT ener FROM adding WHERE ener = 2000+2*1000
  3.  
  4. no rows selected


Czy ktoś mi może wyjaśnić dlaczego ?

Ten post edytował czezz 19.06.2009, 12:47:01
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi (1 - 1)
IP!
post
Post #2





Grupa: Zarejestrowani
Postów: 21
Pomógł: 1
Dołączył: 21.10.2008

Ostrzeżenie: (0%)
-----


Użyj bind variables:

var x number;
var y number;
var a number;

execute :x := 2000;
execute :y := 2 * 1000;
execute :a := :x + :y;

select ener from adding where ener = :a;


(Prawie) wszędzie będzie działać jednakowo.
Go to the top of the page
+Quote Post

Reply to this topicStart new topic
1 Użytkowników czyta ten temat (1 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Aktualny czas: 20.08.2025 - 14:52