How to use substitution operator in Oracle Application Express Edition? - sql

I want to get user input and using substitution operator but getting this error:
As this is working in SQL Developer but doesn't working on Oracle Application Express
Query-->
select * from emp
where emp = '&emp_name';
Facing this problem:
ORA-00904: "EMP": invalid identifier
Query and Output

Substitution variables are a SQL PLus concept that is also implemented in SQL Developer and SQLcl. It only works in those oracle clients. APEX connects directly to the database, not through a client.
To prompt for user input in the APEX SQL Workshop, use the bind variable syntax. For example:
select * from emp where ename = :emp_name;

Related

Jetbrains Pycharm SQL vs Oracle SQL Developer

I'm running a complicated SQL script in Oracle SQL Developer. The query starts with
DEFINE custom_date = "'22-JUL-2016'"
While this works fine in Oracle SQL Developer I get an error in jetbrains:
<statement> expected got DEFINE
Also when I run the query it says:
ORA-00919: invalid function
even though it all works fine in Orace SQl Developer.
Is there anything specific I need to configure in Jetbrains Pycharm to be able to execute Oracle SQL queries correctly?
DEFINE isn't a core feature of the database, instead it's a command in SQL*Plus.
SQL Developer has as script engine which supports all of the SQL*Plus commands, including DEFINE, which is why it works when you run it there.
DEFINE just creates a variable and assigns a text value to it. You'll need to re-write your code to declare the variable and assign values to it instead.
Docs for DEFINE

How to select a different schema in Oracle SQL Developer?

I am using Oracle SQL Developer 4.1.3 and I have connected to MySQL database.
I want to select a different schema in Oracle SQL Developer but it is giving an error.
Here is my syntax:
ALTER SESSION SET CURRENT_SCHEMA = classicmodels;
I found this syntax on Docs.Oracle but still wondering why it is not working!
Thanks in advance!

Execute valid Oracle DB query in Microsoft Query

I've written an oracle query which executes fine against Oracle 11g DB (I wrote it in PL/SQL developer). But when I try to copy/paste it into Microsoft Query as SQL, it fails with ORA-00900: invalid SQL statement.
Is there a list of what can be included in query for Microsoft Query to be treated as valid? In my query I use a lot of SQL modelling - is it not supported?
I don't believe any of the MODEL features of Oracle are supported by any MS SQL variant.
But as that is an ORA message you are still executing against Oracle, I have to assume that the connection is messing with the SQL. Why do you need to issue the sql through MS Query?
(Perhaps you could define a view/function/proc in Oracle with your model syntax, and then use that object through MS Query)

Ora-01008 with substitution variables

I have an Oracle query which works fine when I use the command window but does not in an SQL window.
I use Pl/SQL Developer so the command window is like the DOS window.
The query is as follows:
SELECT EMPLOYEE_ID, FIRST_NAME, &&COLS
FROM EMPLOYEE
ORDER BY &COLS;
So is the error prompted by PL/SQL Developer? Should I use another tool rather than PL/SQL Developer?
The variable substition using the ampersand is a mechanism that's neither part of SQL nor of PL/SQL. It's an extension of SQLplus. The same extension are implemented by Oracle's SQL Developer.
As far as I know, these extension are not implemented by Allround Automations' PL/SQL Developer.

Firebird ado.net dynamic sql: multiple select statements possible?

I'm refactoring a c# application and optimizing some queries. The app supports Microsoft SQL server and Firebird.
I can't seem to find any information regarding issuing multiple select statements in Dynamic SQL on Firebird.
For example this is valid for Microsoft SQL server:
"SELECT * FROM ATABLE; SELECT * FROM ANOTHERTABLE;"
However Firebird calls invalid token on the semicolon.
Note this is called from c# code using the ADO.NET Firebird driver.
Firebird does not support multipel select within the same command