473,398 Members | 2,404 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,398 software developers and data experts.

Dynamic Pl/sql

2
hi,
i am trying to create a dynamic sql to compare the old and new values in a table by usind a procedure as follows
The g_o_rec and g_n_rec are global variables declared at the package level

When I execute this, it always goes into exeception with the following error
sqlerrm ORA-00904: "G_N_REC"."PHONE": invalid identifier
sqlerrm ORA-00904: "G_N_REC"."CONTACT_PHONE": invalid identifier
sqlerrm ORA-00904: "G_N_REC"."WEBPAGE_URL": invalid identifier
sqlerrm ORA-00904: "G_N_REC"."FAX": invalid identifier

Any help is appreciated here.
Thanks
---------------------------------------

Procedure comp_old_new_vendor(g_o_rec in out dw_new.dw_vendor%rowtype,
g_n_rec in dw_new.dw_vendor%rowtype, l_changed in out varchar2)
is

l_compare varchar2(4000);
l_data_type varchar2(50);
l_result number;
l_new_val varchar2(2000);


begin




for i in ( select data_type, 'g_o_rec.'|| column_name 'g_n_rec.'||column_name l_col2, column_name from user_tab_columns where table_name = 'DW_VENDOR' and column_name NOT IN ('LOADED', 'VENDOR_ID')

)
loop

begin

execute immediate('select nvl(max(1),0) from dual where ' || i.l_col1 || ' <> ' || i.l_col2 ) into l_result;

dbms_output.put_line('l_result ,,,,' || l_result);

exception
when others then
-- null;
dbms_output.put_line('sqlerrm ' || sqlerrm);

end;
end loop;
End comp_old_new_vendor;
Mar 8 '07 #1
3 4268
Dave44
153 100+
can you give us the DDL for the table dw_vender?

also i wouldn't have a variable at the package level with the same name as a parameter for a procedure within the package... needless confusion.
Mar 8 '07 #2
meeko
2
Thanks for the response

Initially the procedure call was
Procedure comp_old_new_vendor(l_o_rec in out dw_new.dw_vendor%rowtype,
l_n_rec in dw_new.dw_vendor%rowtype, l_changed in out varchar2)

begin

g_o_rec := l_o_rec;
g_n_rec := l_n_rec;
...
....
All the other statements are the same as in my initial posting

End comp_old_new_vendor;
This didn't work and hence tried it as in my intial posting




Here is the ddl for the dw_vendor.
create table dw_vendor
(VENDOR_ID NUMBER,
VENDOR_NAME VARCHAR2(1250),
BUSINESS_TYPE_CODE VARCHAR2(24),
CONTACT_FIRST_NAME VARCHAR2(300),
CONTACT_ID NUMBER,
CONTACT_LAST_NAME VARCHAR2(300),
CONTACT_MID_NAME VARCHAR2(300),
CONTACT_TITLE VARCHAR2(300),
STATE_CODE VARCHAR2(32),
ZIP_CODE VARCHAR2(24),
ADDRESS_TEXT VARCHAR2(1250),
CHANGE_DATE DATE,
CITY VARCHAR2(1250),
CONTACT_ADDRESS_TEXT VARCHAR2(1250),
CONTACT_EMAIL VARCHAR2(60),
CONTACT_PREFIX VARCHAR2(150),
CONTACT_STATE_CODE VARCHAR2(24),
CONTACT_SUFFIX VARCHAR2(150),
CONTACT_ZIP_CODE VARCHAR2(24),
PHONE VARCHAR2(30),
CONTACT_PHONE VARCHAR2(30),
WEBPAGE_URL VARCHAR2(256),
FAX VARCHAR2(30),
TOLL_FREE_PHONE VARCHAR2(30),
EMAIL VARCHAR2(100),
CONTACT_FAX VARCHAR2(30),
U_VENDOR_NAME VARCHAR2(1250),
MEMBERSHIP_LEVEL NUMBER(3),
constraint pk_dw_vendor primary key (vendor_id)
)
nologging
/
Mar 8 '07 #3
Dave44
153 100+
Ok we have some work to do here.

are you trying to compare table definitions? or the data within a table for a given row? if it is the data, is it from updated rows or for new information being inserted to be compared to existing information?

as for what you have given, the select statement in the for loop is missing the l_col1 alias and the comma after it.

the execute immediate string is always going to return 0. the two columns will never be the same because you are prefixing them with different strings. it would be the same as saying where 1=2 (which is impossible) therefore nothing is returned, except max() forces oracle to return something (in this case null) and nvl(null,0) is 0.

nvl(max(1),2) is the same as nvl(1,2) since max(1) is always 1 and 1 is never null

i need a better definition of what you are trying to acheive please.

the two global variables being passed in are not being used
Mar 8 '07 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Roel Wuyts | last post by:
CALL FOR CONTRIBUTIONS International Workshop on Revival of Dynamic Languages http://pico.vub.ac.be/~wdmeuter/RDL04/index.html (at OOPSLA2004, Vancouver, British Columbia, Canada, October...
1
by: Guinness Mann | last post by:
When you guys talk about "dynamic SQL," to what exactly are you referring? Is dynamic SQL anything that isn't a stored procedure? Specifically, I use ASP.NET to communicate with my SQL Server...
6
by: Materialised | last post by:
Hi Everyone, I apologise if this is covered in the FAQ, I did look, but nothing actually stood out to me as being relative to my subject. I want to create a 2 dimensional array, a 'array of...
3
by: Stephen Gennard | last post by:
Hello, I having a problem dynamically invoking a static method that takes a reference to a SByte*. If I do it directly it works just fine. Anyone any ideas why? I have include a example...
7
by: serge | last post by:
How can I run a single SP by asking multiple sales question either by using the logical operator AND for all the questions; or using the logical operator OR for all the questions. So it's always...
0
by: Pascal Costanza | last post by:
Dynamic Languages Day @ Vrije Universiteit Brussel ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Monday, February 13, 2006, VUB Campus Etterbeek The VUB (Programming Technology Lab,...
7
by: Mike Livenspargar | last post by:
We have an application converted from v1.1 Framework to v2.0. The executable references a class library which in turn has a web reference. The web reference 'URL Behavior' is set to dynamic. We...
1
by: Peterwkc | last post by:
Hello all expert, i have two program which make me desperate bu after i have noticed the forum, my future is become brightness back. By the way, my problem is like this i the first program was...
5
by: bearophileHUGS | last post by:
I often use Python to write small programs, in the range of 50-500 lines of code. For example to process some bioinformatics data, perform some data munging, to apply a randomized optimization...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.