Skip to content

Tag: oracle

How to get address by user’s id oracle

In my project, front end needs, following JSON data with this format. So I Created two table for user and their addresses, So I plan to going with this table structure, USER_TABLE USER_ADDRESS Address table I created this way because, each user have two addresses, one is permanent and other one is corresponde…

Checking the Oracle SQL DECODE function result against 0

I’m looking at some old PL/SQL code and I have dozen of DECODE functions written like this: DECODE(value_1, value_2, 1, 0) = 0 Now, I know these DECODEs make comparison between value_1 and value_2 and they return true or false based on the outcome of comparison. But, for the love of coding, could someon…

How compare dates that are equal when one has time as well

I’m trying to compare dates and it looks like I’m doing it like examples online, but I only see the rows of dates returned when I do >= for the comparison. When I just use = it doesn’t return anything. This is my query with >= for the date comparison: I see a lot of this sort of thing …

Oracle procedure saving SYSDATE

As part of a larger procedure I’m trying to write some code, which saves SYSDATE into a variable but I’m running into a problem. I narrowed it down to the following. Can someone please help me out. Answer In PLSQL you can just assign: if you insist on sql all you have to do is to add into after se…

How can i store results of a query in an array?

I have to store last 5 employees_id’s from employees table into an array. I made the query correct and i have the array, but i can’t understand the syntax to store the results in that array. Here’s my code and here’s my query How can i store the results from the query in the array? As …

Can “value in list or list is empty” be written shorter?

Given this SQL: Is there a way to write the “in list or list is empty” part shorter? Preferably in a way that contains the list only once (see the Don’t_repeat_yourself principle ) I’m interested for Oracle SQL or PL/SQL, but other information is also welcome. As requested, a MRE that …