Regular expression – example 1

To match a word that starts with an alphabet and can be followed by any combination of alphabets and numbers in Perl, you can use the regular expression pattern ^[a-zA-Z][a-zA-Z0-9]*$.

Here’s a brief explanation of the pattern:

  • The ^ at the beginning of the pattern matches the start of the string.
  • The [a-zA-Z] part matches any single character that is an uppercase or lowercase alphabet.
  • The [a-zA-Z0-9]* part matches zero or more characters that are either an uppercase or lowercase alphabet, or a digit.
  • The $ at the end of the pattern matches the end of the string.

So, the complete regular expression ^[a-zA-Z][a-zA-Z0-9]*$ will match any word that starts with an alphabet and can be followed by any combination of alphabets and numbers in Perl.


To match a word that starts with an alphabet and can be followed by any combination of alphabets, numbers, #, _, and $ in Perl, you can use the regular expression pattern ^[a-zA-Z][a-zA-Z0-9#_\$]*$.

Here’s a brief explanation of the pattern:

  • The ^ at the beginning of the pattern matches the start of the string.
  • The [a-zA-Z] part matches any single character that is an uppercase or lowercase alphabet.
  • The [a-zA-Z0-9#_\$]* part matches zero or more characters that are either an uppercase or lowercase alphabet, a digit, #, _, or $.
  • The $ at the end of the pattern matches the end of the string.

So, the complete regular expression ^[a-zA-Z][a-zA-Z0-9#_\$]*$ will match any word that starts with an alphabet and can be followed by any combination of alphabets, numbers, #, _, and $ in Perl.


To match a word that starts with an alphabet and can be followed by any combination of alphabets, numbers, #, _, and $ in Oracle JET, you can use the regular expression pattern ^[a-zA-Z][a-zA-Z0-9#_$]*$.

Here’s a brief explanation of the pattern:

  • The ^ at the beginning of the pattern matches the start of the string.
  • The [a-zA-Z] part matches any single character that is an uppercase or lowercase alphabet.
  • The [a-zA-Z0-9#_\$]* part matches zero or more characters that are either an uppercase or lowercase alphabet, a digit, #, _, or $.
  • The $ at the end of the pattern matches the end of the string.

So, the complete regular expression ^[a-zA-Z][a-zA-Z0-9#_$]*$ will match any word that starts with an alphabet and can be followed by any combination of alphabets, numbers, #, _, and $ in Oracle JET.

Get locks in Oracle database

How to get what are the locks held in oracle database ?

You can use the Oracle database query below to get lock handles for a specific session or for all sessions in the database:

-- For a specific session
SELECT sid, type, id1, id2, lmode, request, ctime, block FROM v$lock WHERE sid = <session_id>;

-- For all sessions
SELECT sid, type, id1, id2, lmode, request, ctime, block FROM v$lock;

In these queries, v$lock is a dynamic performance view that shows information about locks currently held in the database. The columns in the view provide details about the type of lock, the object being locked, the mode of the lock, and other metadata.

To get the lock handles for a specific session, replace [session_id] with the session ID of the desired session. This will return a list of all locks held by that session.

To get the lock handles for all sessions, simply execute the second query without any modifications. This will return a list of all locks held by all sessions in the database.

It’s important to note that the v$lock view only shows information about currently held locks. If a lock has been released or timed out, it will not appear in the view. Additionally, the information in the view may not be completely up to date, as there may be a delay in the collection of lock information.

Display triggers on a table in Oracle Database

You have a table in Oracle database, and there are some triggers defined on that table. You want to know what all triggers are defined for that table.

Query to display triggers

To display all the triggers on a table in an Oracle database, you can use the following SQL query:

SELECT trigger_name, trigger_type, triggering_event, table_name
FROM user_triggers
WHERE table_name = 'your_table_name';

This query selects information about all triggers owned by the current user that are defined on the specified table, “your_table_name”.

If you want to see triggers from all users, you can replace “user_triggers” with “all_triggers” or “dba_triggers” and add a condition for the owner.

Here’s a brief explanation of the columns in the output:

  • trigger_name: the name of the trigger.
  • trigger_type: the type of trigger (e.g. “BEFORE INSERT”).
  • triggering_event: the event that triggers the trigger (e.g. “INSERT”).
  • table_name: the name of the table the trigger is defined on.

This query should help you to see all the triggers defined on a table in your Oracle database.

Example

Here, we are trying to display triggers on FND_NODES table

-- show all triggers on a table
select trigger_name, trigger_type, table_name from dba_triggers where table_name like 'FND_NODES%';

Output :

TRIGGER_NAME       TRIGGER_TYPE      TABLE_NAME
FNDSM              AFTER EACH ROW    FND_NODES#
UPNAME             BEFORE EACH ROW   FND_NODES#

Show Trigger definition

You can use the following query to display the definition of a trigger in an Oracle database:

SELECT dbms_metadata.get_ddl('TRIGGER', 'trigger_name', 'trigger_owner') FROM dual;

In this query, replace trigger_name with the name of the trigger you want to view, and replace trigger_owner with the schema that owns the trigger. The query will return the SQL statement used to create the trigger, including any trigger actions or conditions.

example :

-- query to show trigger definition
select dbms_metadata.get_ddl('TRIGGER', 'FNDSM', 'APPS') from dual;

this query will display the trigger definition.