How to view SQL_TEXT in V$SQL that are COMMITed in Oracle Database? - oracle11g

I am trying to look the SQL query that has Updated, Inserted, and Deleted rows in a table
SELECT
*
FROM V$SQL
WHERE
PARSING_SCHEMA_NAME = 'user_checking' and
SQL_TEXT like '%employees%'
order by FIRST_LOAD_TIME desc;
But this query also shows uncommitted queries. Is there a way to only show SQL_TEXT that has been commited?

Related

Teredata: create violatile table xxx on commit delete rows;begin transaction, end transaction, no return

create volatile table product (product_id integer , product_name varchar(10), category varchar(10)) on commit delete rows;
begin transaction ;
insert into product (product_id,product_name,category) values(122, 'chair', 'furniture');
sel * from product;
end transaction;
I'm wondering why output is nothing? How to modify the queries to get inserted values?
There may be several problems with starting a transaction:
check if you are using your connection configuration:
Session Mode: Teradata
add a database name before the product table name.
It is possible that your user has no free space for records.
in my Teradata SQL Assistant, the word product is highlighted, and check if the word "product" is not reserved in your Teradata database configuration.
SELECT * FROM SYSLIB.SQLRestrictedWords;

Is there a way to use the WITH Clause in Peoplesoft Query Manager?

I use the WITH clause in Oracle SQL lots of times and knowing that more than 90% of the time, it performs faster, but since I am working on the Peoplesoft application, so I just wonder is there a way to use the WITH Clause in Peoplesoft Query Manager, too?
Put your SQL inside a Record View. Grant Query Tree security to the record view. SELECT * from your view via PS Query.
From memory, I seem to have also had some success wrapping the query as an inline view inside the Record View.
e.g. Record View SQL:
SELECT * FROM
(
<INSERT Common Table Expression here>
)
Using example Common Table Expression
with MYCTE AS (SELECT 1 as fake FROM DUAL) SELECT fake FROM MYCTE WHERE fake = 1
That would then become
SELECT * FROM
(
with MYCTE AS (SELECT 1 as fake FROM DUAL) SELECT fake FROM MYCTE WHERE fake = 1
)
Naturally, PeopleTools Application Designer will reformat the SQL as it sees fit when you save the definition.

SQLite - Create Trigger for Insert or Update

Is this possible to create one trigger for Insert and Update operations in SQLite?
I mean, something like this:
CREATE TRIGGER dbo.TR_TableName_TriggerName
ON dbo.TableName
AFTER INSERT, UPDATE, DELETE
AS
BEGIN
SET NOCOUNT ON;
IF NOT EXISTS(SELECT * FROM INSERTED)
-- DELETE
PRINT 'DELETE';
ELSE
BEGIN
IF NOT EXISTS(SELECT * FROM DELETED)
-- INSERT
PRINT 'INSERT';
ELSE
-- UPDATE
PRINT 'UPDATE';
END
END;
It's for MS SQL i think, source: Insert Update trigger how to determine if insert or update
Edit:
Is it possible to create also one trigger for more than one table?
No, the syntax graph for CREATE TRIGGER clearly shows that only one of INSERT, UPDATE or DELETE can be given.
It also shows that only one table can be given as a table to trigger on.

OpenQuery for SQL Query

Kindly help me writing below query in openquery.Thanks in advance
INSERT INTO Tablename
SELECT * FROM tablename1 WHERE insertionorderid IN (
SELECT orderid FROM temp_table2)
If you are trying to insert into SQL Server the syntax would be
INSERT INTO dbo.[YOURTABLE] SELECT * FROM [MATCHING_TABLE] WHERE CLAUSE
The caveat here is that the two tables must have identical schemas or you will have to explicitly define the columns. Also this will not work properly for tables with identity columns

SELECT INTO statement in sqlite

Does sqlite support the SELECT INTO statement?
Actually I am trying to save the data in table1 into table2 as a backup of my database before modifying the data.
When I try using the SELECT INTO statement:
SELECT * INTO equipments_backup FROM equipments;
I get a syntax error:
"Last Error Message:near "INTO":syntax
error".
Instead of
SELECT * INTO equipments_backup FROM equipments
try
CREATE TABLE equipments_backup AS SELECT * FROM equipments
sqlite does not support SELECT INTO.
You can probably use this form instead:
INSERT INTO equipments_backup SELECT * FROM equipments;
SQlite didn't have INSERT INTO syntax.
In 2019, I use TEMPORARY keyword to create temporary table and INSERT data to temp table:
CREATE TEMPORARY TABLE equipments_backup(field1 TEXT, field2 REAL)
INSERT INTO equipments_backup SELECT field1, field2 FROM equipments

Resources