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.
Related
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;
This is my first time trying to execute function within Oracle 11g package from SQL Server. I begin with information that both databases sit on different servers.
Here goes. There are three functions to be executed that should return values from each function. I managed to run one function using SSIS returning value by way of debugging the SQL Execute Task.
Below is the SQL statement I wrote;
SELECT <Database_name>.<Package_name>.<Function_name>(?, ?, ?) FROM dual
I also specified 3 parameters for input.
Help me out to execute 2 more functions together. Thanks a lot.
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
Is there a way to parse code in SQL Developer (oracle) without actually touching tables/packages data like you can do with "parse" option in SQL Management studio?
There is no option to merely parse the SQL statement to validate the syntax.
You could choose the "Explain Plan" option (F10 in the Windows version of SQL Developer), that will validate the syntax as part of generating the query plan. If there is a syntax error, you'll get the error message when you attempt to generate the plan but you generally won't get the line and column of the error which makes debugging more challenging.
I was looking for this right now and couldn't find an option in Oracle SQL Developer.
I know a service called SQL Fiddle that can help in such situations where one needs to test/parse/validate an adhoc PL/SQL script. Using SQL Fiddle you can do this:
Select Oracle 11g R2 (as available right now) in the dropdown and type your script in the left text area. Press Build Schema button. If your script is valid then it'll show you Schema Ready message like this:
In Oracle SQL Developer, there's a "SQL" tab for each table. This tab contains most of the SQL code (CREATE TABLE, CREATE TRIGGER, etc) that's needed to recreate the table.
Is this information available programatically from the database system, or is this an application feature of SQL Developer? If the former, what commands/statements would I need to run to retrieve this information? If the later, are there any clever ways to get SQL Developer to export these statements?
If you are using Oracle 9i+ then you are looking for the DBMS_METADATA package. http://download.oracle.com/docs/cd/B10500_01/appdev.920/a96612/d_metada.htm. It will allow you to extract whatever DDL you want.
If you are looking for more specific information there is a whole host of views you can access for specific data elements similar to the ones given by #Quassnoi.
There are lots of information, but here are the main queries:
SELECT *
FROM dba_tables
SELECT *
FROM dba_tab_columns
SELECT *
FROM dba_ind_columns
To see what SQL Developer actually outputs, enable trace for all sessions with a LOGON TRIGGER and look into the trace file created by SQL Developer's internal session.
You are looking for the DDL of your database objects.
You can use the Oracle bundled DBMS_METADATA package to get it, from any PL/SQL prompt, with the GET_DDL function.
I use TOAD vs Oracle SQL Developer.
When I click on a "Script" tab when viewing an object (like a table) TOAD executes a whole host of queries and then compiles the "script" from the output of all of these queries.
dba_tables
dba_tab_columns
dba_ind_columns
...
I think replicating this functionality would be a tedious task.