Details Query in pg_stat_statements - postgresql

In pg_stat_statements output ("query" field):
SELECT * FROM users WHERE id = ?
How can I get the details of "?" from query in pg_stat_statements?
Can anybody tell me about this, because I want to track if anyone execute some query.
Can we also know which ip address this query execute from? so I can monitor if anyone make some modification data in database.
Thanks for the help.

You can use pg_stat_monitor, it has that feature.

Related

See why an Amazon Redshift scheduled query fails

I have a scheduled query in Redshift that simply will not run. It works when I execute the query manually in the query editor, just not when scheduled. I can't seem to find any feedback about why it's failing, though. I can see the schedule history, a unique Id, and the status of "Failed", but no more info.
Is there a system table/view that I can dig into and find out what's going on with my query? The SQL consists of basic select, update, insert style code - nothing fancy, just long.
You can look for any errors using:
select
process,
errcode,
linenum as line,
trim(error) as err
from
stl_error;
Also: Retrieve Redshift error messages
Ref.: STL_ERROR
It says in the description that it doesn't record SQL errors which would likely be the problem of the failed query.
I'm trying to sort this one as well and it seems it's limited as I only see the
Any idea how to get the associated query ID, PID, or EID so I can check maybe against the query history?

Attachments to a Purchase Requisition

I need to download attachments for over 300 purchase requisitions in the Oracle e-Business suite. Instead of opening the requisitions one-by-one and then going to the "Manage Attachments" section, I would like to do this through a query, where I would enter the PR numbers and then get the attachments. Does anybody know if this would be possible through a query in SQL developer (or Ms Access)? If yes, which tables should I consider to design the query?
Thank you in advance for any help you might be able to give me.
You can use this SQL https://www.enginatics.com/reports/fnd-attached-documents/ as a basis and add a restriction to the req headers you need to see like this
fad.entity_name='REQ_HEADERS' and
fad.pk1_value in (select to_char(prha.requisition_header_id) from po_requisition_headers_all prha where ...) and
note that the to_char() is required to use the fnd_attached_documents_n1 index as fad.pk1_value is varchar2 whereas prha.requisition_header_id is a number
These are stored in the FND_DOCUMENTS and information about which application entity / key it is attached to is in FND_ATTACHED_DOCUMENTS - this blog article does a good job of describing the tables involved.

Talend- get results from tdb2Row component and insert into another table

I'm running a select count query in a tDB2Row component. I need to get the value found and insert it into another table.
I've tried using the propagate query's recordset, but it doesn't make sense to me.
Also what component would i use next?
Thanks in advance!
Please use tDB2Input component for select query and give schema to it and add tLogRow to it to see the result.
tDB2Row is for dml query like update and delete.
Hope this helps...

how to get info about whether a query got benefit from a particular index? postgresql9.6

I want to set log_statement for only select statements if possible, otherwise i will use all statement.
After that i want to list queries to get information about whether a particular query hasnt used a particular index. Because when i drop and recreate that particular index, i want to check later if a query hasnt got benefit from this particular index.
I guess SELECT * FROM pg_stat_activity wouldnt help.
Is it possible to list queries to get this information?
You can use auto-explain to save execution plan to logs.
Also take a look at pg_stat_statements to select (rank) slow statements right in db catalog...

Does Group by with order by work ion Dql?

I am trying to execute a DQL (Doctrine) query that retrieve the latest answers of different doctors.
we have table answer, member, Location (doctor table) and many other table connected to the doctor information. However I want to get the latest answer but the condition is one answer for a doctor. I do some search and know something about group by and order by dont work together !
Here is the query in DQL:
$query = Doctrine_Query::create()
->select("a.answer_id as answer_id,m.member_is as member_id,a.member_id")
->from('Answer a')
->leftJoin('a.Member m on m.member_id = a.member_id')
->orderBy('a.date_added DESC')
->groupBy('m.member_id')
->limit(5);
but this query return undesirable results. Can anyone tell me where is the mistake?
Unfortunately you need to perform a subquery for that, which according to this question, DQL does not support. However in that question it's suggested that you send a native query.