I am porting code from SQL Server to Oracle.
DECLARE @DispatchCount int,
@HeadCount int;
SELECT @DispatchCount = (
select 200 -- business query would replace sample
);
select @HeadCount = (
select 50 -- business query would replace sample
);
select @DispatchCount / @HeadCount;
I tried oracle declare syntax.
DECLARE
head_count INTEGER;
BEGIN
select 100 as DUMMY into head_count from dual;
dbms_output.put_line(head_count);
END;
I am querying a read only oracle 11g database in python from cx_oracle:
cursor.execute(sql)
rows = cursor.fetchall()
This throws the error: 'not a query' on the fetchall statement. Is there a way to declare variables in oracle that will work in a SQL query?
dbms_output.put_line(head_count);line won't directly do anything in cx_Oracle unless you do some extra steps like shown in the cx_Oracle example DbmsOutput.py. The other comment is that 11g is very old. If you are using the "XE" edition, then you should think about installing XE 18c.