select count into versus create table as in functions/procedures
I am working on a dynamic PL/SQL script that will count the number of records in a remote database
based on certain criteria and then if the number is "acceptable" will create a table in the connecting
database with those records.
My where clauses are supposed to be the same but I am presented with the problem, when I run the
first code ... select in to rowcount I get 122000 records, when I later do the create table as
with the same whereclause code, I get 77 records. So now I am attempting to validate that the two
where clauses are the same ... you'd think it would be obvious, but it's not.
My first operation does a select count(*) into rowcount with the where clause behind it.
The second operations creates a "sql command literal' that gets executed and returns the less value.
I build it like testscript := 'create table '||tablename ||'as select * from '||remotetablename||'@'||linkname;
testwhere := ' xxxxxxx'
then I do an execute immediate teststring ||' ' testwhere; which works but gives me 77 rows in the table.
Since I believe my where clause might be different, how can I run the first operation ... select count into rowcount
as a normal SQL statement in the script...
When I attempt to just run it I get -- PLS-00428: an into clause expected in this select statement......
I will provide the source code in my next posting. Working to get it moved to this system.. Once you see it you'll understand
why I don't think, it's the same, but I need a way to run them exactly as they are written to understand the different results.
so How can I make the select count (*) into rowcount from .... work just like a normal select