Skip to content

Tag: oracle

Print a custom message when no rows are returned by a SELECT statement

I am trying to create a report of INVALID objects in Oracle. The requirement is to print a custom message when no rows are returned (This is because the output will be redirected to an HTML report). I tried the following query: Error am seeing: While the individual queries work without an issue, it fails to e…

trim function not working on result of to_char

The query gives the result 3 as expected but the query: gives 003 I need the result to be as the first query (‘3’) but I also need the ‘TO_CHAR’ (I’m using it to create a virtual column from a NUMBER column). I can not figure why and how to fix it. Also, I can not use regex_repla…

Use a macro in SAS ‘to_date’ conversion

Being forced to pass my code in explicit pass though, the date conversion no longer works. I would like to use the &aaaa macro in the convert function. My code example : I got an error : “The (full) year must be between -4713 and +9999 and be different from 0”. Does anyone have a solution? Ans…

How do i transpose and grouping in PL/SQL [ORACLE]

I have this table: USER DEP USER1 DEP1 USER2 DEP2 USER3 DEP2 USER4 DEP3 But i want to transpose it and group user under DEP. DEP1 DEP2 DEP3 USER1 USER2 USER4 USER3 NULL NULL What i have tried following pivot query. The output is: 00933. 00000 – “SQL command not properly ended”. How do i use …

how to rollback tran when error occur in oracle

i try to solve 2 requests below but i only code for the first one,, can any one help to solve the second one Write SQL statements using cursor to update salary of all employees base on update conditionals Make sure all update records have been updated completely. The database transaction will be rolled back i…