Report that only displays employees directly reporting to the manager running the report - sql

Hello I'm running Obi 11g and I'm creating a dashboard for managers and I'm having difficulty finding a way to create a report for the dashboard that shows only the employees directly reporting to the manager running the dashboard / report.
I've done a little research and I'm guessing this is going to be done by session variables? but i'm not sure how. If there was a way I can pull the executing user's username I could just say employee.username = session.username and then run the query accordingly but is there a way to this?
Any help would be appreciated greatly. Thanks.

This is Oracle. It offers a function named USER that returns ... well, current user. So, your query might utilize it as
where employee.username = user

Since this may be an Oracle product but not and Oracle database query, you will need sth more OBI-specific:
VALUEOF(NQ_SESSION.USER)

I found what I was looking for
SELECT fnd_global.user_name FROM DUAL
This posts the username instead of the schema.

Related

How to generate the DDL for all the Users in a Snowflake Account?

Is there a way to get the DDL for all the users in a Snowflake Account ?
I see the following URL says there are about 10 items that the get_ddl supports currently :
https://docs.snowflake.net/manuals/sql-reference/functions/get_ddl.html
If there's nothing out there, then I'll use the traditional Concatenation of data and strings to generate the commands like select 'create user ' || username || ... from...
Please let me know.
Thanks
Jitz
At this time, I don't believe there's built-in Snowflake functionality for this. A script, like you mentioned, would work to fill the need in the meantime.
There is a feature request called "Expand GET_DDL" on the Ideas page and that you could upvote (and add a comment that you are particularly interested in Users): https://community.snowflake.com/s/ideas
As Suzy has explained there isn't an option that exists natively at the moment. So your best bet is probably to take the approach you have outlined:
do a show users in account
cycle through that with something like: table(result_scan(last_query_id()))
If you're going to use the traditional concatenation technique, I wrote a stored procedure to automate running all of the resulting rows from that approach. You can find it here:
How to drop temp tables created in snowflake
You can feed it your select as the only parameter...
select 'create user ' || username || ... from...
Make sure that the column is called "SQL_COMMAND", and the stored procedure in the link above will run all the resulting SQL statements one at a time.

How to move table data from one environment to another environment in Oracle

I am a novice Oracle User.
I want to move a table records from QA to Test environment. The table already exists in Test. Would it be something like this ?
insert into wKTest01.MyTableIWantToMove select * from wkQA01.MyTableIWantToMove ;
Any help is greatly appreciated.
Both the tables in both environments have same number of columns with same data types.
You can use database links in Oracle to do this.Create a database link in your test database called myQADBLink which points to your QA DB.
The code would look something like this
CREATE DATABASE LINK myQADBLink CONNECT TO <username> identified by
<password> USING
'<QA DBconnect string>';
SELECT 1 FROM dual#myQADBLink; -- This is to test if your dblink is created properly.
Now you can copy from QA to test by saying
INSERT INTO wKTest01.MyTableIWantToMove select * from wkQA01.MyTableIWantToMove#myQADBLink;
Yes, it actually exists, right like you put it.
Here is the full syntax guide for this: http://docs.oracle.com/cd/E17952_01/refman-5.1-en/insert-select.html.
Later, when you might place your tables at the different Oracle instances, google 'Orace DBLink' for the good ;)

SQL Reporting 2008 and Excel as Data Source

I am working on a project were we need to develop SQL Reports based on some excel files.
I was able to create the ODBC for the Excel file and I was able to connect to it successfully using the Report Services.
My question is:
How can I used paramaters in the query ? When I try to use #CIF or #StartDate I get all kinds of errors and I don't know how to use parameters with SQL query for Excel.
Sample:
SELECT * FROM [Loans$] Where [CIF] = #CIF
Can anyone tell me how?
If you are successfully extracting information without trying to filter at the query level, as a workaround you can add the filtering at the DataSet level, something like:
This will extract data from the DataSet then apply any filter, not try to do it at the same time.
It's might not be addressing your root cause, but will hopefully get you up and running in the meantime.
Since you don't actually list the errors you're getting, it's hard to offer more specific advice.

SQL query to get the source of a Stored Procedure

I'm using a DB2 database and I'm hoping for a query which will iterate over all stored procedures in a single database and print out the source code of each. No fancy formatting or performance requirements.
The reason for this (in case there's a better way of doing it) is I'm trying to track down usages of a particular table in our stored procs, so I want to be able to do a simple text search through all of them.
Also, I've got access to SQuirreL SQL client if anyone knows of a way via that.
Ah, figured it out. For other's reference:
select ROUTINENAME, TEXT from syscat.routines
where definer not in ('SYSIBM') AND ROUTINESCHEMA='databaseName'
I know this is old, but your answer started me on the right track. We are also using DB2, but don't have syscat.routines visible to us. However we do have SYSIBM.SYSROUTINES and that allows similar by doing
SELECT SCHEMA,
NAME,
TEXT
FROM SYSIBM.SYSROUTINES
WHERE SCHEMA = '<SCHEMA>'
and NAME = '<NAME>'
FOR FETCH ONLY WITH UR;

MSQL auditing with CLR integration

I'm dot.net developer, and i'm working a lot with MSQL. My current task is when some user executes select query on database, i should "catch" the query data. What do i mean is if select query is "select * from UsersTbl where UserID = 5", i have to get '5'. Does somebody have any idea where to start???
Thanks a lot.
Dmitry
You could extract each value that starts with an =
But you might find a solution using MySQL Proxy... I've never used it so don't hold me to that :)