I’m trying to put my select statement inside a for loop and after looping I want to insert the result on a table but upon my execution I bump in to this error. ORA-06550: line 5, column 7: PLS-…
Tag: oracle
Oracle: When are constraints checked?
In my understanding constraints should generally be checked at the end of a transaction. So, in a simple example where we have one table A with the only column P, which is its primary key, and a table B with the primary key P and the foreign key F on A.P, the following should work (on empty tables): However, …
Oracle SQL Extract Year from VARCHAR2
Please don’t roast me for not being able to figure this out. I’m a beginner with SQL and I’ve been trying to find a solution and make it work for at least a couple hours in total. I know the date fields should be stored as dates, not varchar2, but I have no control over that. I feel like I&#…
Oracle SQL – Assign number to distinct tech_spec
In Oracle SQL, I’m trying to assign a unique number to each distinct tech_spec. Output: I’m trying to get assign each distinct tech_spec a number. I have been searching for a way to do this but can’t come up with anything. Output desired: Thanks in advance. Answer Use dense_rank(): You shoul…
Select row of data to be the output header
I have a very large set of data that is formed similar to this: I want to produce report output that drops the table headers (field1, field2, field3) and instead use data row1 as headers in output. I am able to do this nicely in SQLPlus and SPOOL to CSV, but I want to do everything in PLSQL so that
Oracle GROUP BY clause is having issue
SQL Query in oracle database is: SELECT max(employee_id) from bank_data group by job_type having job in (‘Engineer’,’Artist’); My table data is: I get below error: ORA-00979: not a GROUP BY …
In oracle SQL , how to count the no of records based on conditions
I have table with below structure : I wanted the SQL query to output me the following : Logic : If the values in the Col2 are A,B then it should be summed up as Internal , If E then it should be summed up as External. Answer To map your column values use DECODE, simple providing the list of
What is the difference in select with alias, and without- oracle 11g
I have a table, let’s name it table1. The table consists of many columns, and one of the columns is an object, which consist of 3 subcolumns, let’s call them value1, value2, value3. Let’s say that …
SELECT list is not in GROUP BY error but I got a result cleary
here is a code that I made. SELECT substr(to_char(birthday, ‘YYYY’), 1, 3) || ‘0’, emp_type, AVG(pay) FROM emp2 WHERE substr(to_char(birthday, ‘YYYY’), 1, 3) IN ( ‘196’, …
sqlalchemy concat with more than 2 elements on Oracle DB
considering the following table definition I create a select-statement using the sqlalchemy.sql.functions.concat with 3 statements using the query is generated. However, when I run this, the exception ORA-00909: invalid number of arguments is thrown. This is because CONCAT (https://docs.oracle.com/cd/B19306_0…