SQL & PL/SQL :: How Does DBMS_SQL Differ From Native Dynamic Code

Aug 13, 2012

Let me the difference between the DBMS_SQL and Execute immediate .

*) Which one is faster ?
*) Where to use DBMS_SQL and Execute immediate (correct usage of both)?

View 4 Replies


ADVERTISEMENT

PL/SQL :: Native Dynamic Sql

Jan 8, 2013

find the below scripts .

drop table test_arp;

create table test_arp
(
first_name varchar2(1000),
last_name varchar2(1000)
);

[Code]....

when i select the above table ,i will be getting the result as shown

first_name , last_name
CONTROL    PANEL
ORACLE       SEA
                 WILLIAMS
RAHUL        KUMAR

I need  to make a table which will be having the following data and structure

col1            col2          col3
CONTROL    ORACLE    RAHUL

.i.e , depending on the number of not null values in the first column (first_name), i will be creating a table dynamically ,which is going to have as many columns as the number of values and the naming convention is col1,col2,col...........

I designed the below procedure to CREATE OR REPLACE PROCEDURE ARP
AS
C NUMBER:=1;

BEGIN
FOR I IN (SELECT FIRST_NAME FROM TEST_ARP WHERE FIRST_NAME IS NOT NULL)
LOOP
IF C=1 THEN

[Code]...

But when i execute this code , i get the below error

ORA-00984: column not allowed here
ORA-06512: at "ARP", line 17
ORA-06512: at line 1

View 9 Replies View Related

SQL & PL/SQL :: Querying Through Dynamic Database Links Using DBMS_SQL

Nov 14, 2011

I am using SQL Developer.I am self-teaching myself PL/SQL. What I am trying accomplish is to run a select query across many database links at runtime and to insert that query onto a local table. So far, I have only gotten as far as querying the database link names. I am stuck at where my variable calls the database link name. It does not recognize the database link name, and I can't quite grasp the reason why. Below is the first part of my script which does retrieves the column values no problem:

001 SET SERVEROUTPUT ON
002 DECLARE
003 db_link_varVARCHAR2(30);
004 source_cursorINTEGER;
005 destination_cursorINTEGER;
006 src_csrINTEGER;
007 dst_csrINTEGER;
008 rundate_varDATE;
009 instance_name_var VARCHAR2(30);
[code]....

If I break the script down to the bare select query, it will query absolutely fine.If I run the script in its entirety, it will not pick up the variable dbl as a dynamic database link. 02019. 00000 - "connection description for remote database not found"

If I comment out line 031 and prevent the looping of querying of database links (which will only fetch the first value of db_link from dba_db_links), the script will complete and I will have a row inserted into my local table.

I am suspecting it's the looping that is incorrect but I understand it is not going to do anything beyond line 059.

View 8 Replies View Related

SQL & PL/SQL :: Execute Large (clob) Dynamic Sql By DBMS_SQL?

Aug 2, 2011

is it possible to execute large(clob) dynamic sql by DBMS_SQL .Is there any restriction like length ...

View 4 Replies View Related

SQL & PL/SQL :: Find Final Text Of Dynamic Query Created By Dbms_sql?

Jul 4, 2012

I am using dbms_sql for creation and execution of dynamic query. But after execution,the results returned are not correct. Just wanted to know is there some way by which I can find the final text of dynamic query created by dbms_sql?

View 14 Replies View Related

SQL & PL/SQL :: Using Dbms_sql.execute To Build / Execute Dynamic Sql?

Oct 23, 2013

I'm working with old code that uses dbms_sql.execute to build/execute dynamic sql. In our case, the user can select varying columns(I think up to 20) with different where conditions as needed.

After building the sql, here's an example

WITH ph AS
(SELECT ph.* FROM po_header ph WHERE 1 = 2),
pf AS
(SELECT DISTINCT pf.order_id, pf.fund
FROM po_fau pf, ph
WHERE 1 = 1
AND ph.order_id = pf.order_id

[code]....

Where table records for

po_header = ~567746
po_fau = ~2153570

and PK "order_id" is a NUMBER(10) not null and a snippet of the code looks like

nDDL_Cursor := dbms_sql.open_cursor;
dbms_sql.parse(nDDL_Cursor, sSQLStr, 2);
FOR x IN 1 .. nCols LOOP
sCols(x) := '';
dbms_sql.define_column(nDDL_Cursor, x, sCols(x), 100);
END LOOP;
nError := dbms_sql.execute(nDDL_cursor);

why when the "execute" statement is fired off the elapsed time takes ~4.5 seconds but If I change "1 = 1" above to "1 = 2" it takes ~.2 seconds. If I run the above query interactively it takes ~.2 seconds. Shouldn't the above query when joining

ph.order_id = pf.order_id

return zero rows back instantly or does the "dbms_sql_execute" do some other type of parsing internally that takes cpu time.

View 14 Replies View Related

Ora-06502 - Create Generate Procedure That Create Dynamic Procedure Through DBMS_SQL

Mar 31, 2004

ORA-06502...I have database on oracle 9i on Solaris 9. I create a generate procedure that create dynamic procedure through DBMS_SQL. On this database I got the ORA-06502 error. When I tried to run the same procedure on the same database on oracle 8i on NT this work fine.

View 3 Replies View Related

Dynamic Wrapping Of Source Code In Oracle

Feb 3, 2008

I want to wrap the source code in oracle, i am able to do it using wrapping utility (through DOS prompt command i.e wrap iname= inputfilename.sql oname=outputfilename.plb).

Other option is using DBMS_DDL package as follows
*********************************************
DECLARE
l_source DBMS_SQL.VARCHAR2A;
l_wrap DBMS_SQL.VARCHAR2A;

[Code]....

This above will replaces the original function source code with wrapped code, but here they are concatinating the code manually.

My requirement is i will get the source code (text) from user_source view in a cursor and line by line code will get in a loop. I am sending that output to above function dynamically , but it raising this error.

ORA-24230: input to DBMS_DDL.WRAP is not a legal PL/SQL unit.

View 2 Replies View Related

Translating PL/SQL Into SQL 2000 Native Language?

Sep 14, 2007

I would need to translate the Oracle PL/SQL procedure to SQL Server 2000 SP4.

This is a package (body) that needs to be translated into a form that SQL server 2000 can unserstand it.

AS
FUNCTION object_name_fix (sobjectstring IN VARCHAR2)
RETURN VARCHAR2
AS

[Code].....

View 1 Replies View Related

SQL & PL/SQL :: How To Use DBMS_SQL Package

Apr 27, 2010

How to use DBMS_SQL package. I tried with the following procedure.

CREATE OR replace PROCEDURE Crt_tab_inst(tab_name VARCHAR2,
col1_name VARCHAR2,
col1_value VARCHAR2)
IS
cur BINARY_INTEGER := dbms_sql.open_cursor;
fdbk BINARY_INTEGER;
[code]........

But when Iam executing the procedure, it is throwing the below error. This is the error Iam getting:

SQL> EXEC crt_tab_inst('MYTAB','MYCOL','NAME1');
BEGIN crt_tab_inst('MYTAB','MYCOL','NAME1'); END;
*
ERROR at line 1:
ORA-00984: column not allowed here
ORA-06512: at "SYS.DBMS_SYS_SQL", line 909
ORA-06512: at "SYS.DBMS_SQL", line 39
ORA-06512: at "SCOTT.CRT_TAB_INST", line 21
ORA-06512: at line 1

View 10 Replies View Related

Server Administration :: Setting Up ASM Using ASMLib On Native Linux Multipath Mapper?

Nov 8, 2010

I've been trying to setup ASM disks for two node cluster using ASMLib. It's a multipath environment

Quote:multipath -ll
mpath2 (36842b2b000528f8d0000029b4ccead44) dm-1 DELL,MD32xx
[size=280M][features=3 queue_if_no_path pg_init_retries 50][hwhandler=1 rdac][rw]
\_ round-robin 0 [prio=100][active]
\_ 1:0:0:1 sdc 8:32 [active][ready]
\_ round-robin 0 [prio=0][enabled]
\_ 1:0:1:1 sdl 8:176 [active][ghost]

[code]....

I've been following Metalink note 602952.1, 309815.1 and 605828.1

metalink note 602952.1 states Quote:Note: Keep in mind for ASMLIB disks you will need to use the /dev/dm-* disks instead of the /dev/mapper/mpath* devices since they are present in the partition table ==)> /proc/partitions and ASMLIB will look at that file during the disk discovering phase. If you do not use the disks located at /dev/dm-* then ASM will not be able to discover them. and to create ASM disks with Quote:/etc/init.d/oracleasm createdisk DISK1 /dev/dm-<disk><partition> Also further stating Quote:NOTE: When scanning, only the device names known by the kernel are scanned. With device-mapper, the kernel sees the devices as /dev/dm-XX. The /dev/mapper/XXX names are created by udev for human readability. Any configuration of ORACLEASM_SCANORDER or ORACLEASM_SCANEXCLUDE must use the dm prefix.My environment is RHEL5 and towards the end of the note it says Quote:Note: On release RH 5 the /dev/dm-N devices are not persistent, starting, these devices are no longer created by udev. So release RedHat 5 you can create the ASMLIB disks on the /dev/mpath/<partition> or /dev/mapper/<partition>

Example:

# /etc/init.d/oracleasm createdisk VOL1 /dev/mpath/sata01p1

Or

# /etc/init.d/oracleasm createdisk VOL1 /dev/mapper/mpath2p1

Therefore I created a ASM disk using /dev/mapper path and it is only visible on the node it was created. Even after scandisks on other node it is still not visible when listdisks/oracleasm-discover

I've also tried creating the asm disks with dm-12 option and the same, disk get created but not visible on the other node.

Moreover if I restart the oracleasm restart the disk disappears from the node that it was visible Quote:

[root@db2 ~]# /etc/init.d/oracleasm createdisk vol1 /dev/mapper/mpath6p1
Marking disk "vol1" as an ASM disk: [ OK ]
[root@db2 ~]# ls -l /dev/oracleasm/disks/*
brw-rw---- 1 oracle dba 253, 12 Nov 8 10:22 /dev/oracleasm/disks/VOL1
[root@db2 ~]# /etc/init.d/oracleasm scandisks
Scanning the system for Oracle ASMLib disks: [ OK ]

[code]....

But disk lable is there and could be seen from both nodes on the same partition Quote:

head /dev/mapper/mpath6p1
VOL1ORCLDISKVOL1

My suspicion is on multipath configuration. I've tried both (not at the same time) combinations given below.

Quote:ORACLEASM_SCANORDER="dm"
ORACLEASM_SCANEXCLUDE="mpath mapper sd sda sdb"

and

Quote:ORACLEASM_SCANORDER="mapper"
ORACLEASM_SCANEXCLUDE="mpath dm sd sda sdb"

But still the problem is there, (disks disappears when asm is restarted and never visible on the "other" node).

View 8 Replies View Related

Impdp Speed Differ From Location To Location

Oct 4, 2013

We have taken export expdp backup from prod database (primary database- Data Guard).

1.) Import impdp is very slow 10GB/Hrs on staging database (Data Guard MAXIMUM AVAILBILITY)Since Server configuration, database version and configuration, operating system everything are same as production. No blocking, locking or waiting sessions

2.)import impdp is fast 90GB/Hrs on Test standalone database and this test database is running in NOARCHIVE LOG mode with oracle standard version after that no more difference.

CPU,Memory,network and disk I/O are look normal while importing on both databases.why that much difference on import.

View 1 Replies View Related

Reports & Discoverer :: Bar Code Reader Will Readout Code

Feb 12, 2009

I have no knowledge about Barcode. The problem is an issue of Loyalty Cards of a Hotel and Restaurant to various customers and then these cards will be presented by the customers time to time in the Hotel as well as Restaurant. The Owner of the Hotel and Restaurant wants to generate separate barcode for each card and when this card will be presented then the bar code reader will readout the code and the system will calculate the amount of discount/rebate. Because if the data entry operator enter the code of the card through key board the it will be a chance of leakage or misuse of that card.

View 8 Replies View Related

SQL & PL/SQL :: Compare SVN Source Code With Production Code In Database

May 30, 2012

I have to compare my SVN source code (packages, views etc) with the production code in the database like views etc (actually we are not sure that what we have in the svn is the final version of production code, we have objects created in the production database, but we don't have latest scripts for that. we have to deploy the svn code in the UNIX box).

So here the comparison is between the OS files and the database objects.

I thought I would get scripts of all the packages, views etc from the production database by using DBMS_METADATA or some utility and save the code in OS files then compare one svn file with OS file manually by using some comparison tools e.g toad provide one comparison tool.

View 5 Replies View Related

SQL & PL/SQL :: Type In Code To Make Few Tables Then Run Code

Feb 13, 2012

I downloaded oracle sql developer, i type my code into a worksheet but if i use the run statement option, it asks me to make a connection. I dont want to make a connection, just test the data locally.However, even if I do try and make a connection, i get ora-12560 error (local connection).

I just want to type up some data to make some table and test to retrieve or manipulate the data. I'll use any program, command line or gui.

View 7 Replies View Related

JDeveloper, Java & XML :: Native Java In Oracle Versus PL/SQL?

Aug 26, 2011

we can you java code natively with Oracle. But I didn't get how to decide when to use native java in oracle and when to use pl/sql.

View 5 Replies View Related

PL/SQL :: Dynamic Ref Cursor With Dynamic Fetch

Apr 8, 2013

I'm using dynamic sql (DBMS_SQL) to define columns of ref cursor. It works Ok but the problem is when i'm using PL/SQL CURSOR in the REF CURSOR. Then,I'm getting :

Error at line 3
ORA-00932: inconsistent datatypes: expected NUMBER got CURSER
ORA-06512: at "SYS.DBMS_SQL", line 1830
ORA-06512: at "TW.PRINT_REF_CURSOR", line 28
ORA-06512: at line 9

Here is my code:
set serveroutput on
exec DBMS_OUTPUT.ENABLE(1000000);
declare
l_cursor sys_refcursor;
begin
[code]....

Is there a solution or bypass?

View 3 Replies View Related

SQL & PL/SQL :: How To Debug A Code

Nov 2, 2011

how to debug PL/SQL code.

I mean if
procedure1 --calls---> procedure2
procedure2 --calls---> procedure3
procedure3 --calls---> procedure4

If procedure1 is my main procedure how do we know in procedure there is an unhandled exception or bug.

View 2 Replies View Related

SQL & PL/SQL :: How To Unwrap A Code

May 9, 2011

how to unwrap a PL/SQL Code???

View 2 Replies View Related

Retrieve Records - Using Code?

May 28, 2008

I need to retrieve the records where the involvement is either a person or an organization. Using the code below i receive an error stating that the outer join operator is not allowed in the operand OR:

(( INVOL1.PERSON_IDENTIFIER(+)=ALL_PERSONS.IDENTIFIER )
OR ( INVOL1.OUNIT_IDENTIFIER_INV=INVOL1_ORG.IDENTIFIER(+) ))

If I change it to an and query it will only retrieve the records where there is a person and an organisation as the involvement but I need this option as well as one or the other.

View 7 Replies View Related

Backup Of Source Code?

Oct 15, 2009

I would like to backup all source code (packages, procedures, functions, etc) every day automatically. Is there a built-in feature of Oracle to do this, I've been going through the Toad IDE and its getting to be too time consuming.

I assume I could use the export command, but not entirely sure what to specify.

I would like to backup a few tables along all code and set something in place (trigger maybe?) to send me an email when a modification is made to the production code environment.

View 2 Replies View Related

Code Works In Firefox But Not IE7?

Jan 29, 2008

I am fighting with some code to work in IE7. It is currently working in Firefox.

A little bit more on the context of the situation is that I am entering the code as a personalization on an Oracle Self Service Page. I am entering in as a raw text personalization.

[Code]
<html>
<head>
<style>
</style>
</head>
<body lang=EN-US style='tab-interval:.5in'>

[code].....

View 3 Replies View Related

How To Catch Null Value With C# Code

Jan 5, 2010

how to catch a null value with C# code?

My Asp.Net/C# application is connected to an Oracle database where it retrieves database values and also values calculated/returned from Oracle functions. My problem is that sometimes an Oracle function I calling returns a null value because of not correct input parameters which will cause Oracle function to (I think) return an null value. My problem and question is how to catch/obtain if he Oracle function returns a null value? Oracle function should return a decimal value if correct input parameters. Below is my row of code that crashes when Oracle function returns a null value in case of incorrect input parameters.

decGrossFreightRevenue = (decimal)(OracleNumber)cmdCalculateRevenueCall.ExecuteOracleScalar();

how to change my code to catch a null value and avoid a crash. I have tried several checks (if statements) without success.

View 2 Replies View Related

SQL & PL/SQL :: Code For RESULT Column?

Aug 4, 2011

I have the following data (columns IDx, STARTx and DURATION) and want to create the column RESULT. Example:

create table zTEST
( IDx number,
STARTx number,
DURATION number,
RESULT number );
insert into zTEST (IDx, STARTx, DURATION, RESULT) values ( 1 , null , null , null );

[code]...

The logic behind the table is like this: when there is a Start-ID and a Duration, the field Result shall show the Start-ID for the next records (Duration period). Even if there is a new Start-ID in row 9, it is ignored since threre is already a current signal from row 6 which is still running.

What is the sql code for the RESULT-column?

View 3 Replies View Related

SQL & PL/SQL :: How To Select Last Code From A Column

Jun 27, 2012

i have a table name item.

itemid itemdate Amt
200 17/06/2012 2000
201 18/06/2012 3000
202 19/06/2012 1000
203 20/06/2012 6000
204 21/06/2012 9000
205 22/06/2012 1000
205 24/06/2012 2000
203 26/06/2012 1000

this is the table i have in which repeated itemids for different dates,for example itemid 205 and 203 comes 2 times because that item was consumed again and again in a different date. like this the table data has more than a 20 thousand records;

In which i need to select the last updated dates itemid from this table, because same item id could be consumed 'n' number of times so i need to select it as per the last date or latest dates itemid from this table for each and every item, so how can i select it?

View 6 Replies View Related

SQL & PL/SQL :: Writing A Code For When Condition

Feb 5, 2013

I have a problem in running a sql query.I have a dataset with the following details. Product name,product status,approval date in table product_details. I have a code as follows

select Product_name,
Product_status,
approval_date,
case
when product_status ='Cancelled' or product_status ='Stopped' then approval_date='N/A'
when product_status='Active' then NVL2(approval_date,cast(appoval_date as nvarchar2(30)),'Null')
when product_status='Completed' then NVL2(approval_date,cast(appoval_date as nvarchar2(30)),'Null1')
when product_status='Planned' then NVL2(approval_date,cast(appoval_date as nvarchar2(30)),'Null2')
end as DER_approval_date

from product_details

but i have a error in running this code saying character mismatch.

View 6 Replies View Related

SQL & PL/SQL :: Generating Unique Code

Jun 27, 2011

I have data like this:

a1 a2 a3 a4
ABC ABC xx zz
ABC xx mm mm
fg ui ok pl

I want to give them unique codes like :

Code for column
a1 Code1
ABCC-1
ABCC-1
fg C-2

then column
a2 Code2
ABC C-1
xxC-3
uiC-4

then column
a3 Code3
xxC-3
mmC-5
okC-6

then column
a4 Code4
zzC-7
mmC-5
plC-8

I can add these `columns in the table Code1 , Code2 etc columns to update.

View 1 Replies View Related

Forms :: Generate Bar Code In 6i?

Nov 2, 2011

i want to generate bar code in forms 6i but i don't know the code.

View 3 Replies View Related

SQL & PL/SQL :: Code Not Running After IF Statement?

Feb 6, 2012

with the code below i have created 2 varaibles v_start_date and v_finish_date, i have inputs for them, thats fine the problem is when the inputs are empty, i have put a ELSIF statement in the begin section of the code, now if the variables have input from the textbox's then it works fine but if they are empty, the programme reads into the if statement executes that bit of code but doesn't seem to open the cursor up and execute that bit of code.

DECLARE
v_start_date enrollments.enrollment_date%TYPE:= :START_DATE;
v_finish_date enrollments.enrollment_date%TYPE := :FINISH_DATE;
CURSOR no_grades_cur IS
SELECT class_id,stu_id, status
FROM enrollments

[code].....

View 13 Replies View Related

Forms :: List Box Code

Apr 1, 2010

View the attached form image.

There are two List boxes namely :list_all (All) and :list_sel(Selected). :list_all show some data. What I want is to insert / delete records from the list_all to list_sel or vice versa using the buttons ( e.g.For one record using > and for all >>). The next step is to call a report to show data from the :list_sel.

I have populated the list_all with using the following query.

"select distinct all_ded,to_char(all_ded_id) from salary_temp order by all_ded"

Forms:6i
Database: Oracle9i

View 1 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved