I’m trying to insert values id_team_FK and id_location_FK which both come from the same table. For example id_team_FK = 4 and id_location_FK = 150. The problem is, id_team_FK must be a randomly chosen …
Tag: oracle
oracle add column with value based on condition
I would like to add a column “tag” based on value of “LEASE_ID_count” with ORACLE. But i get this error : value too large for column “CUSTOM_LIFETIME_VALUE_TAG”.”tag” (actual: 7, maximum: 3) , caused by: OracleDatabaseException: ORA-12899: value too large for co…
query inside the exception and begin block in exception
Hello I want to ask what is the best practise to do. First example try to retrieve my data through exceptions I use this code in my main application and is working fine but I dont know if its good practise to code inside the exceptions blocks SECOND EXAMPLE TRY TO RETRIEVE DATA WITH CASES AND SELECT WITH COUN…
Is there anyway to test the function in SQL?
I have following problem. I’ve made an function which checks dates, warehouse if it’s full, etc.. Here is the code and I’ve added comments so it is more clear and understanble: So basically if I run only the function I don’t get any error. But when I run it with the test date I get fol…
Columns in SQLPlus report display longer than database column size
I have a number of sql reports that used to work fine. Recently however they have started to be outputted with the column widths being longer than they should. According to Oracle’s documentation if a column in an sql report has no explicit “COLUMN” definition at the start of the report, eg …
Convert foreign key constraint from SQL Server to Oracle
I want to convert the following script(SQL SERVER) to Oracle: I have tried to run the same script in Oracle: and I got this error: I believe that the “WITH CHECK ADD” is the problem! Answer See if this helps. A master table – its primary key column will be referenced from the tdistribucion t…
ORA-00907: missing right parenthesis, and nothing is working
I’ve been sitting and looking at this code for a few hours and I don’t understand where I went wrong, why it doesn’t work. ORA-00907: missing right parenthesis I saw that this is a topic that is discussed alot but for some reason none of the examples I have seen has helped me. I’m pret…
How to unite two SQL statements when referencing a few tables
I have the following TABLES and RECORDS. I need to answer the following query: Find the names of all the teachers that Ann Chin has, along with all her classes and midterm grades from each. So far, I have tried many SELECT combinations, but I keep getting duplicate values and returns. This is the closest I ha…
How to create teble 3 from data of table 1 and table 2
t1 (ordered descending): a comment 512 (ordered desc) 415 310 205 195 150 132 90 74 20 1 t2 (ordered ascending): b comment 10 (ordered asc) 11 12 13 I would like to create t3: a (desc) b comment 512 10 (b=asc) 415 11 310 12 205 13 195 13 (b=desc) 150 12 132 11 90 10 74 10 (b=asc)
Oracle hierarchical queries data
The link gives a good example for overview on how to use Oracle hierarchical queries. I was trying to generate the below combination of data with the example table tab1 given in the link but struck …