plsql

How to move a text file using Oracle

Hi all I have two questions. (1) how to make move text file from folder: C:\Data\inbox\test.txt to target Folder? C:\Data\outbox\test.txt (2) how to make get list of directory files in Folder? C:\Data\inbox\ Thank you... ...

need to translate specific t-sql case in pl/sql

Can anyone tell me how to translate the following T-SQL statement: SELECT fileld1 = CASE WHEN T.option1 THEN -1 ELSE CASE WHEN T.option2 THEN 0 ELSE 1 END END FROM Table1 AS T The point is I need to validate two diff...

Difference between "IN" and "IN OUT" CURSOR parameter in Oracle

From Oracle: "When you declare a cursor variable as the formal parameter of a subprogram that fetches from the cursor variable, you must specify the IN or IN OUT mode. If the subprogram also opens the cursor variable, you must specify the IN OUT mode." But, I can code that (only OUT parameter): create or replace procedure mycur_out(mc ...

ORA-00907 while trying to create a table with automatic column

I'm attempting to create a table with an automatic column, the value of which is computed using a function I've defined. However, when I try to create the table I keep getting ora-00907: Missing right parenthesis. Can anyone help? Here is the CREATE code: CREATE TABLE NEW_EMP2 ( SSN CHAR(9), EMP_NUM2 CHAR(5) automatic as newemp2id(SSN...

Dynamic SQL within cursor

My dynamic sql below to alter a table & create columns based on the output of a query is giving error. Query : DECLARE CURSOR c1 is select distinct WP_NO from temp; cnum VARCHAR2(255); BEGIN FOR cnum in c1 LOOP EXECUTE IMMEDIATE 'Alter table temp_col add (:1 varchar2(255))' using cnum; END LOOP; COMMIT; END; ...

How do I UPDATE a large table in oracle pl/sql in batches to avoid running out of undospace?

I have a very large table (5mm records). I'm trying to obfuscate the table's VARCHAR2 columns with random alphanumerics for every record on the table. My procedure executes successfully on smaller datasets, but it will eventually be used on a remote db whose settings I can't control, so I'd like to EXECUTE the UPDATE statement in batches...

oracle pl/sql arrays

i have some numbers which i want to store in an array. how will i declare array and assign value to it in oracle pl/sql?? ...

display results in output parameter in toad

I have a stored procedure in Oracle and m using a out parameter in it.. I want to know whether how 2 display the output in toad.. ...

PLSQL JDBC: How to get last row ID?

What's PLSQL (Oracle) equivalent of this SQL server snippet? BEGIN TRAN INSERT INTO mytable(content) VALUES ("test") -- assume there's an ID column that is autoincrement SELECT @@IDENTITY COMMIT TRAN In C#, you can call myCommand.ExecuteScalar() to retrieve the ID of the new row. How can I insert a new row in Oracle, and have JDBC g...

Parsing a string into an table using oracle SQL

Hi, guys. Say I have the following table: ID | String ---+--------- 1 | <123><345> 2 | <1-2><45-67> 3 | <345-321><234> This is a legacy data format in my app which is currently impossible to avoid. What I need to acheive, is: ID | String ---+--------- 1 | <123> 1 | <345> 2 | <1-2> 2 | <45-67> 3 | <345-321> 3 ...

Static vs dynamic sql

In my database at several places developers have used dynamic sql instead of static. And they are saying reason for this is to improve the performance. Can someone tell me can if dynamic sql can really increase the performance in stored procedure or plsql block? Which will execute faster and why ? 1. begin execute immediate ...

Convert PLSQL Cursor FOR Loop Syntax to TSQL

I have some PLSQL code which loops through some logic: FOR I in cur1 LOOP SELECT value1, value2 FROM db1..table1 t1 END LOOP; Can anyone explain to me the syntax for doing this in TSQL? ...

translate from SQL Server to Oracle

I was hoping one of you Oracle experts would be able to give me a hand with this. I have the following SQL Server script, but I need to rewrite it for Oracle: USE mydb GO SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO CREATE trigger mydb . [CONNECTERTRIGGER] on mydb . [DtreeNotify] FOR INSERT AS BEGIN IF @@ROWCOUNT=0 RETURN SET I...

Source of sequence?

hi, I want to use source code of some sequences but i am unable to find it in ALL_SOURCE data dictionary. Please let me know where i can find source code for sequences used . ...

How to find if a sequence exits using PL/SQL

I need to find using PL/SQL if a specific sequence named e.g. MY_SEQ exits. If the sequence exists then drop it and create a new, or else to just create a new sequence. E.G. (pseudocode) IF EXISTS(MY_SEQ) THEN BEGIN DROP SEQUENCE MY_SEQ; CREATE SEQUENCE MY_SEQ... END; ELSE BEGIN CREATE SEQUENCE MY_SEQ; END; ...

PL/SQL Developer alternative

Hello! We have a lot of our business logic in an oracle database. So we use a lot of PL/SQL code. We build, test, and debug PL/SQL packages, procedures, triggers, and functions. Our current tool is the PL/SQL Developer (http://www.allroundautomations.com/). What are your tools for PL/SQL coding and why do you prefer it to the PL/SQL De...

Setting the 'Order By' Clause from plsql procedure parameters.

What is the best way to dynamically set the 'order by' column name and direction from parameters passed in to a plsql procedure? ...

How do I write this database comparison in Oracle PL/SQL?

Given databases x, y with matching schemas: //for all entries in x.MY_TABLE // if PRIMARY_KEY of entry exists in y.MY_TABLE // if {data of entry in x} doesn't match {data of matching entry in y} // print PRIMARY_KEY // else // print PRIMARY_KEY Assume that the table is a simple system...

why both the sql query on rownum are giving different result

>SELECT instmax FROM (SELECT instmax, rownum r FROM ( SELECT * FROM pswlinstmax ORDER BY instmax DESC NULLS LAST ) ) WHERE r = 2; INSTMAX ------- 1049 >SELECT instmax FROM (SELECT instmax, rownum FROM (SELECT * FROM pswlinstmax ORDER BY instmax DESC ) ) WHERE...

PK constraint violated with INSERT/UPDATE

Hello, i have a Dimension Table like this : my_Table pk1 Primary key pk2 Primary key pk3 Primary key col1 col2 col3 ... and using a procedure to fill this table with the MERGE INTO statement : MERGE INTO my_Table dest USING ( SELECT <columns> FROM <tables> WHERE <conditions> ) src ON (dest.pk1 = src....