Eliminating null from result set
Hi,
How can i set some value (say 0) for fields having null value using ejbql?
Anybody please help me....
Thanks in Advance,
Anish.
what is the best way to get from a jdbc Result Set to
a Swing Table Model?I think I would iterate over all the elements in my result set and add them to a hashmap / hashtable where the key is their spot in the table, represented by a Point object. One thing I'm not sure of is if 2 points with equal coordinates have the same hash value, but you could always just create your own point class where such is the case and use that.
Result Sets are no random access structures. You have
to navigate through them to reach a certain row.Yes. Not only that, but the resultset is part of your transaction with the DB. It's not good style to keep that open any longer than necessary.
JTable Models want you to implement something like
getValueAt(int i, int j) to access a row (and even a
column) at random.Would be easy using my suggestion above
- your are in fact interducing another cashKind of. But you don't have a choice. You gotta copy the data.
- big Result Sets could be a problemThat's always going to be true, and I don't see how you can get around it.
Similar Messages
-
Problem in Retrive values from result set
I have a class where i do all database operation .First i fire select query and take values from result set and based on that value i fire update query.
Problem is that i am not getting all values from result set . i get only last value and when i fire update query i get error as :Resultset is closed.
I am using acess and java.You probably are using the same Statement object for both queries? Try creating separate Statement objects for each query. (My guess is this a problem with the way you're using JDBC, not a Servlet issue.)
-
Getting every odd-numbered row from result set
select *
from mytable
where MOD(rownum,2) = 1;
Why does this not give me every odd-numbered row from result set? It returns just 1 row....
Thank uWhen you say MOD(ROWNUM,2)=1 it will list only the first row with rowid which is devisible by 2 and gives a reminder 1.
Just tweak your query with a GROUP BY:
SQL> select rownum from your_table group by rownum having mod(rownum,2) =1;
ROWNUM
1
3
5
7
9
11
13
15
17
19
21
ROWNUM
23
25
27
29
31
33
35
37
39
41
43
etc...
[pre]
Jithendra -
Transfer data from Result Set (Execute SQL Task) into Flat File
Hi to all,
My problem is this:
-) I have a stored procedure which use a temporary table in join with another "real" table in select statement. In particular the stored procedure look like this:
create table #tmp
col1 varchar(20),
col2 varchar(50)
--PUT SOME VALUE IN #TMP
insert into #tmp
values ('abc','xyz')
--SELECT SOME VALUE
select rt.*
from realTable rt, #tmp
where rt.col1 = #tmp.col1
-) I cannot modify the stored procedure because I'm not admin of database.
-) I HAVE THE REQUIREMENT OF TRANSFER DATA OF SELECT STATEMENT OF SOTRED PROCEDURE INTO FLAT FILE
-) THE PROBLEM is that if I use an OLEDB source Task within a Data Flow Task I'm not be able of mapping column from OLEDB source to flat file destination. The reason for this, is that in the "Column page" of OLEDB source task, SSIS do not retrieves
any column when we using a temporary table. The reason for this, is that SSIS is not be able to retrieve metadata related to temporary table.
-) One possible solution to this problem is to use an Execute SQL Task to invoke the stored procedure, store the result returned from stored procedure in a Result Set through a Object type user variable.
-) The problem now is: How to transfer data from result set to flat file?
-) Reading here on this forum the solution look be like to use a Script task to transfer data from result set to flat file.
QUESTIONS: How to transfer data from result set to flat file using a script task?? (I'm not an expert of vb .net) Is it really possible?? P.S.: The number of row returned of stored procedure is very high!
thanks in advance.Hi Visakh16<abbr
class="affil"></abbr>
thanks for the response.
Your is a good Idea, but I do not have permission to use DDL statement on the database in production environment. -
Getting the record count from result set
i'm retreiving the result set using the executeQuery method, now i want to know how many records are there in the result set, that is the record count of the result set.
one solution to that is to first use the executeUpdate and then use the executeQuery but i think that is not the right way.
so please tell me is there any method in jdbc to get that thing done
TanxHi
Do you know if your DB supports "insensitive scrolling"?
SQL generally do, but some don't - I had the same problem with the
open source version of Interbase from Phoenix...
Anyway - try creating your statement this way:
public Statement createStatement(int resultSetType, int resultSetConcurrency)
throws SQLException
...where resultset type should be:
ResultSet.TYPE_SCROLL_INSENSITIVE
Then you can do this:
ResultSet rs = stm.executeQuery(q);
int size = rs.last(); //this what you looking for?
rs.beforeFirst();
while(rs.next()){
} -
How urgent:how can we know the size of a record from result set
hi proffesionals i attend on problum with arrangment,for that what i am doing is i am fetching datas from database and printing in a row vertically.it is not looking good.i want to print it horizontaly like
ae00023 as3333 a6556 a457864 a6576
ae00025 as3336 a6556 a457866 a6578
i wrote the coding like
<%while(resultsetdisplay.next())
{%>
// try to print the datas in horizontal way
<tr>
for (int i=index;i<resultsetdisplay.getFetchSize()-10;i--)
<td class=display><%=resultsetdisplay.getObject(4)%></td>
int i=index;
</tr>
<%}%>
is it prints horizontaly.
help me soonHi
You can the Meta Data for the result set and then get the getColumnCount() from the MataData to get the number of columns in the resultset.
Bye -
EA1/EA2/RC1/2.1.1 - copy from result set does not work as expected
When I highlight a field in the result set and press "command+c" (I am on Mac) or use "Copy" from the menu, then content of the field is not copied to clipboard. You have to go to edit mode, mark the whole content of the field and then use "Copy".
By the way, should I describe all the bugs that I have found so far in this forum or is there any other "official" bug reporting?
Regards,
SvenWe have picked up keyboard mapping issues with the Mac, so I'll check on this one.
For all early adopter bugs and queries, yes please used this forum. If you can mark you query with EA1 and you have done, then that's great.
Sue -
If a database operation using 8.0.5 JDBC drivers accessing 8.0.5 instance results in the exception: null Exhausted ResultSet, what is really happening?
Any help would be appreciated.
nullHai,
The packet size is already only 1000. When I clicked F1 on the packet size, the documentation said that if I want to pull a large amount of transaction data, the value can be changed from 1000 to upto 50000 for Oracle. I tried changing it to 50000 and tried pulling data from RSA3. Still it shows the same error.
Regards,
Neha Solanki
Edited by: Neha Solanki on Dec 27, 2007 5:25 AM -
Reading a string containing special character from a result set
My Code....
PrintStream p = new PrintStream(fout);
if (connection == null)
connection = getConnection();
CallableStatement proc = connection.prepareCall("{call testing_read()}");
rs = proc.executeQuery();
while ( rs.next() )
String page2 = rs.getString(1);
System.out.println(page2);
rs.getString(1); is a string value eg. 'Rebekah \n Govender' that is being set in a stored procedure.
The output of my program is :'Rebekah \n Govender' , i need for it to read the special characters, and produce this output :
Rebekah
Govender
Without using a result set , it works fine.
eg.
String page2 = 'Rebekah \n Govender'
System.out.println(page2);
Will give an output of :
Rebekah
Govender
I need to read values from the results set, pls help me someone....
Please help....String page2 = rs.getString(1).replace("\\n", "\n"); When you include source code in your posts, please enclose it in CODE tags. There's a button for that above the input textarea.
ThE-MaRaC wrote:
Hi,
you can try something like this:
import java.io.UnsupportedEncodingException;;
* Main class, manages the complete game
public class Main {
public static void main(String[] args) {
String page2 = "Rebekah \n Govender";
try {
page2 = new String(page2.getBytes("ISO-8859-1"), "ETF-8");
} catch (UnsupportedEncodingException e) {}
System.out.println(page2);
}Regards,
Hercog MarioThat is a disgusting hack which you shouldn't be recommending to anyone, and it's totally irrelevant here anyway. Also, as written, it does absolutely nothing because you misspelled "UTF-8" and you swallowed the exception that would have told you so. -
Need help in restricting a result set from a UNION in MERGE
Hello,
Would really appreciate if anybody could help me out with the issue I am facing with the below statements (I am new to Oracle ):
merge into table_name_1 p
using
select p_key, value_1, value_2
from some_tables
UNION
select p_key, value_1, value_2
from some_tables
UNION
)t
on (p.p_key = t.p_key)
when matched then
update table_name_1 with value_1 and value_2
when not matched then
insert table_name_1 with p_key, value_1, value_2;
Now, the union of all those selects gives me distinct values and it works most of the times but when I get values like below, the merge fails:
p_key-----value_1-----value_2
100-----25-----50
100-----NULL-----50
I browsed the net and understood the reason behind this: the result set becomes ambiguous and merge doesn't know which row to insert first and which one to update.
Now, my requirement is: I could have any of the below scenario/result sets from the union and I need only 1 row per p_key -
result_set_1
p_key-----value_1-----value_2
100-----25-----50 ***************need this row
100-----NULL-----50
100-----NULL-----NULL
result_set_2
p_key-----value_1-----value_2
100-----25-----NULL ***************need this row
100-----NULL-----NULL
result_set_3
p_key-----value_1-----value_2
100-----25-----NULL ***************need this row (p_key = 100)
100-----NULL-----NULL
200-----NULL-----75 ***************need this row (p_key = 200)
200-----NULL-----NULL
300-----90-----95 ***************need this row (p_key = 300)
So, I basically need a way to restrict the values that I will get from the UNION of all those selects to fit the requirement above, hope I was able to explain the issue I am facing.
Any help would be greatly appreciated.
Thanks,
DpunkIn all cases the goal is to find an order by value that will make the row you want be first.
The query I gave is calculating a priority for each row by adding up values showing whether each column is null or not null. The case statements check whether each column is null and need to be added up to give a total priority value.
Value_1 Value_2 Priority
Not Null Not Null 2 + 1 = 3
Not Null Null 2 + 0 = 2
Null Not Null 0 + 1 = 1
Null Null 0 + 0 = 0
The priority value ends up being a bitmap showing whether each value is null or not null. I think that reflects my mathematics background.
Another way of getting the same result (suggested to me by your asking why it needs the "+") would be to use two CASE expressions as separate order by items:
select p_key, value_1, value_2 from
(select p_key, value_1, value_2, row_number() over
(partition by p_key
order by case when value_1 is null then 0 else 1 end DESC,
case when value_2 is null then 0 else 1 end DESC
) as rn
from (your UNION query here)
where rn = 1
A third way is to use a more complex case statement:
select p_key, value_1, value_2 from
(select p_key, value_1, value_2, row_number() over
(partition by p_key
order by case when value_1 is NOT null and value_2 is NOT null then 1
when value_1 is NOT null and value_2 is null then 2
when value_1 is null and value_2 is NOT null then 3
when value_1 is null and value_2 is null then 4
end ASC
) as rn
from (your UNION query here)
where rn = 1 -
Hello techies,
I am doing simple program, which is connecting to mysql server and retreiving the results from my database using servlets.
I want to do if the result set is returning zero rows i.e if there is no matching rows is available in the table, which i had specified in my query.
Here is my code
String url = "jdbc:odbc:testDSN";
Properties p = new Properties();
p.put("user", "root");
p.put("password", "kkkk");
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
conn = DriverManager.getConnection(url, p);
System.out.println("connection established");
Statement stmt = conn.createStatement();
ResultSet rs = stmt.executeQuery("select *from test.emp where empNumber =15");
System.out.println("resultset is null" + rs.wasNull());
if (rs.getRow() == 0) {
System.out.println("nomatching subject is found");
out.println("No Matching subject is found");
else {
out.println("<TABLE CELLSPACING=\"0\" CELLPADDING=\"3\" BORDER=\"1\">");
out.println("<TR><TH>eno</TH><TH>ename</TH><TH>date</TH></TR>");
// Loop through results of query.
while (rs.next() == true)
out.println("<TR>");
out.println("<TD>" + rs.getString("eno")+ "</TD>");
out.println("<TD>" + rs.getString("ename") + "</TD>");
out.println("<TD>" + rs.getString("date") + "</TD>");
out.println("</TR>");
Here if there are no employe record matching eno =15 in my table then i want to print no matching record is found.
where i am making mistake??
plz help me .
It is very urgent.
Thanks (inadvance)
regards,
ramuGood Lord, you have database and HTML generation code in the same method?
This is not the way to do JDBC code. Start with a tutorial.
Ever read about object-oriented programming? How 'bout starting with an Employee class that has id, name, and date (what date? birth date? employment date? termination date?) as attributes. Then write a data access object that can do all the database stuff on Employee's behalf, without any consideration for UI. Test that on the command line until you have it working perfectly. THEN worry about how you'll display results to the user.
Your JDBC code isn't right. wasNull() checks to see if the column result is null, not the result set itself. (ResultSet can never be null; read the javadocs). You'd be getting a NullPointerException if ResultSet was null, wouldn't you?
Your code deserves a SERIOUS rewrite, which I'm not inclined to do for you. But I would recommend something more along these lines:
// hardwired url, driver, and query? oh, my - that's bad.
String url = "jdbc:odbc:testDSN";
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
conn = DriverManager.getConnection(url);
Statement stmt = conn.createStatement();
ResultSet rs = stmt.executeQuery("select * from emp where empNumber =15");
// you're obviously putting this in a servlet - bad idea.
// ever heard of JSPs?
out.println("<TABLE CELLSPACING=\"0\" CELLPADDING=\"3\" BORDER=\"1\">");
out.println("<TR><TH>eno</TH><TH>ename</TH><TH >date</TH></TR>");
// Loop through results of query.
while (rs.next())
out.println("<TR>");
out.println("<TD>" + rs.getString("eno")+ "</TD>");
out.println("<TD>" + rs.getString("ename") + "</TD>");
out.println("<TD>" + rs.getString("date") + "</TD>");
out.println("</TR>");
}% -
Performance to fetch result set from stored procedure.
I read some of related threads, but couldn't find any good suggestions about the performance issue to fetch the result set from a stored procedure.
Here is my case:
I have a stored procedure which will return 2,030,000 rows. When I run the select part only in the dbartisan, it takes about 3 minutes, so I know it's not query problem. But when I call the stored procedure in DBArtisan in following way:
declare cr SYS_REFCURSOR;
firstname char(20);
lastname char(20);
street char(40);
city char(20);
STATE varchar2(2);
begin DISPLAY_ADDRESS(cr);
DBMS_OUTPUT.ENABLE(null);
LOOP
FETCH cr INTO firstname,lastname,street, city, state;
EXIT WHEN cr%NOTFOUND;
DBMS_OUTPUT.PUT_LINE( firstname||','|| lastname||','|| street||',' ||city||',' ||STATE);
END LOOP;
CLOSE cr;
end;
It will take about 100 minutes. When I used DBI fetchrow_array in perl code, it took about same amount of time. However, same stored procedure in sybase without using cursor, and same perl code, it only takes 12 minutes to display all results. We assume oracle has better performance. So what could be the problem here?
The perl code:
my $dbh = DBI->connect($databaseserver, $dbuser, $dbpassword,
{ 'AutoCommit' => 0,'RaiseError' => 1, 'PrintError' => 0 })
or die "couldn't connect to database: " . DBI->errstr;
open OUTPUTFILE, ">$temp_output_path";
my $rc;
my $sql="BEGIN DISPLAY_ADDRESS(:rc); END;";
my $sth = $dbh->prepare($sql) or die "Couldn't prepare statement: " . $dbh->errstr;
$sth->bind_param_inout(':rc', \$rc, 0, { ora_type=> ORA_RSET });
$sth->execute() or die "Couldn't execute statement: " . $sth->errstr;
while($address_info=$rc->fetchrow_arrayref()){
my ($firstname, $lastname, $street, $city, $STATE) = @$address_info;
print OUTPUTFILE $firstname."|".$lastname."|".$street."|".$city."|".$STATE;
$dbh->commit();
$dbh->disconnect();
close OUTPUTFILE;
Thanks!
rulinThanks for you reply!
1) The stored procedure has head
CREATE OR REPLACE PROCEDURE X_OWNER.DISPLAY_ADDRESS
cv_1 IN OUT SYS_REFCURSOR
AS
err_msg VARCHAR2(100);
BEGIN
--Adaptive Server has expanded all '*' elements in the following statement
OPEN cv_1 FOR
Select ...
commit;
EXCEPTION
WHEN OTHERS THEN
err_msg := SQLERRM;
dbms_output.put_line (err_msg);
ROLLBACK;
END;
If I only run select .. in DBArtisan, it display all 2030,000 rows in 3:44 minutes
2) But when call stored procedure, it will take 80-100 minutes .
3) The stored procedure is translated from sybase using migration tools, it's very simple, in sybase it just
CREATE PROCEDURE X_OWNER.DISPLAY_ADDRESS
AS
BEGIN
select ..
The select part is exact same.
4) The perl code is almost exact same, except the query sql:
sybase verson: my $sql ="exec DISPLAY_ADDRESS";
and no need bind the cursor parameter.
This is batch job, we create a file with all information, and ftp to clients everynight.
Thanks!
Rulin -
Returning result set from procedure out parameter, display with anon block
I'm trying to do something pretty simple (I think it should be simple at least). I want to use a pl/sql procedure to return a result set in an OUT parameter. If I run this code by itself (in the given anonymous block at the end, without trying to display any results), toad says that the PL/SQL procedure successfully completed.
How can I display the results from this procedure? I am assuming that the result set should be stored in the O_RETURN_REDEEM_DTL, but how can I get anything out of it?
I have this package with the following procedure:
/* FUNCTION - REDEEM_DTL_READ */
PROCEDURE REDEEM_DTL_READ(
ZL_DIVN_NBR_IN IN REDEEM_DTL.ZL_DIVN_NBR%TYPE,
GREG_DATE_IN IN REDEEM_DTL.GREG_DATE%TYPE,
ZL_STORE_NBR_IN IN REDEEM_DTL.ZL_STORE_NBR%TYPE,
REGISTER_NBR_IN IN REDEEM_DTL.REGISTER_NBR%TYPE,
TRANS_NBR_IN IN REDEEM_DTL.TRANS_NBR%TYPE,
O_RETURN_REDEEM_DTL OUT REDEEM_DTL_TYPE,
o_rtrn_cd OUT NUMBER,
o_err_cd OUT NUMBER,
o_err_msg OUT VARCHAR2
IS
BEGIN
o_rtrn_cd := 0;
o_err_msg := ' ';
o_err_cd := 0;
--OPEN REDEEM_DTL_READ_CUR(ZL_DIVN_NBR_IN, GREG_DATE_IN, ZL_STORE_NBR_IN, REGISTER_NBR_IN, TRANS_NBR_IN);
OPEN O_RETURN_REDEEM_DTL FOR SELECT * FROM REDEEM_DTL;
-- LOOP
-- FETCH REDEEM_DTL_READ_CUR INTO O_RETURN_REDEEM_DTL;
-- EXIT WHEN REDEEM_DTL_READ_CUR%NOTFOUND;
-- END LOOP;
-- CLOSE REDEEM_DTL_READ_CUR;
EXCEPTION
WHEN OTHERS
THEN
o_rtrn_cd := 7;
o_err_msg := SUBSTR (SQLERRM, 1, 100);
o_err_cd := SQLCODE;
END REDEEM_DTL_READ;and call it in an anonymous block with:
DECLARE
ZL_DIVN_NBR_IN NUMBER;
GREG_DATE_IN DATE;
ZL_STORE_NBR_IN NUMBER;
REGISTER_NBR_IN NUMBER;
TRANS_NBR_IN NUMBER;
O_RETURN_REDEEM_DTL PSAPP.CY_SALESPOSTING.REDEEM_DTL_TYPE;
O_RETURN_REDEEM_DTL_OUT PSAPP.CY_SALESPOSTING.REDEEM_DTL_READ_CUR%rowtype;
O_RTRN_CD NUMBER;
O_ERR_CD NUMBER;
O_ERR_MSG VARCHAR2(200);
BEGIN
ZL_DIVN_NBR_IN := 71;
GREG_DATE_IN := TO_DATE('07/21/2008', 'MM/DD/YYYY');
ZL_STORE_NBR_IN := 39;
REGISTER_NBR_IN := 1;
TRANS_NBR_IN := 129;
-- O_RETURN_REDEEM_DTL := NULL; Modify the code to initialize this parameter
O_RTRN_CD := NULL;
O_ERR_CD := NULL;
O_ERR_MSG := NULL;
PSAPP.CY_SALESPOSTING.REDEEM_DTL_READ ( ZL_DIVN_NBR_IN, GREG_DATE_IN, ZL_STORE_NBR_IN,
REGISTER_NBR_IN, TRANS_NBR_IN, O_RETURN_REDEEM_DTL, O_RTRN_CD, O_ERR_CD, O_ERR_MSG );
FOR item IN O_RETURN_REDEEM_DTL
LOOP
DBMS_OUTPUT.PUT_LINE('ZL_DIVN_NBR = ' || item.ZL_DIVN_NBR);
END LOOP;
END; And end up with an error:
ORA-06550: line 25, column 15:
PLS-00221: 'O_RETURN_REDEEM_DTL' is not a procedure or is undefined
ORA-06550: line 25, column 3:
PL/SQL: Statement ignoredMessage was edited by:
user607908Aha, I knew I forgot something!
I actually had it defined as a REF CURSOR in PSAPP.CY_SALESPOSTING package spec:
TYPE REDEEM_DTL_TYPE IS REF CURSOR;since I wasn't sure what to make it.
Cursor used in procedure:
CURSOR REDEEM_DTL_READ_CUR (
zl_divn_nbr_in IN NUMBER,
greg_date_in IN DATE,
zl_store_nbr_in IN NUMBER,
register_nbr_in IN NUMBER,
trans_nbr_in IN NUMBER)
IS
SELECT ZL_DIVN_NBR, GREG_DATE, ZL_STORE_NBR, REGISTER_NBR, TRANS_NBR, PAYMENT_TYP_NBR
FROM REDEEM_DTL
WHERE ZL_DIVN_NBR = zl_divn_nbr_in AND GREG_DATE = greg_date_in AND
ZL_STORE_NBR = zl_store_nbr_in AND REGISTER_NBR = register_nbr_in AND
TRANS_NBR = trans_nbr_in;Updated code:
/* PROCEDURE - REDEEM_DTL_READ */
PROCEDURE REDEEM_DTL_READ(
ZL_DIVN_NBR_IN IN REDEEM_DTL.ZL_DIVN_NBR%TYPE,
GREG_DATE_IN IN REDEEM_DTL.GREG_DATE%TYPE,
ZL_STORE_NBR_IN IN REDEEM_DTL.ZL_STORE_NBR%TYPE,
REGISTER_NBR_IN IN REDEEM_DTL.REGISTER_NBR%TYPE,
TRANS_NBR_IN IN REDEEM_DTL.TRANS_NBR%TYPE,
O_RETURN_REDEEM_DTL OUT REDEEM_DTL_TYPE,
o_rtrn_cd OUT NUMBER,
o_err_cd OUT NUMBER,
o_err_msg OUT VARCHAR2
IS
BEGIN
o_rtrn_cd := 0;
o_err_msg := ' ';
o_err_cd := 0;
OPEN REDEEM_DTL_READ_CUR(ZL_DIVN_NBR_IN, GREG_DATE_IN, ZL_STORE_NBR_IN,
REGISTER_NBR_IN, TRANS_NBR_IN);
--OPEN O_RETURN_REDEEM_DTL FOR SELECT * FROM REDEEM_DTL;
LOOP
FETCH REDEEM_DTL_READ_CUR INTO O_RETURN_REDEEM_DTL;
EXIT WHEN REDEEM_DTL_READ_CUR%NOTFOUND;
DBMS_OUTPUT.PUT_LINE('ZL_DIVN_NBR = ' || O_RETURN_REDEEM_DTL.ZL_DIVN_NBR);
END LOOP;
CLOSE REDEEM_DTL_READ_CUR;
-- LOOP
-- FETCH REDEEM_DTL_READ_CUR INTO O_RETURN_REDEEM_DTL;
-- EXIT WHEN REDEEM_DTL_READ_CUR%NOTFOUND;
-- END LOOP;
-- CLOSE REDEEM_DTL_READ_CUR;
EXCEPTION
WHEN OTHERS
THEN
o_rtrn_cd := 7;
o_err_msg := SUBSTR (SQLERRM, 1, 100);
o_err_cd := SQLCODE;
END REDEEM_DTL_READ;the updated anon block:
DECLARE
ZL_DIVN_NBR_IN NUMBER;
GREG_DATE_IN DATE;
ZL_STORE_NBR_IN NUMBER;
REGISTER_NBR_IN NUMBER;
TRANS_NBR_IN NUMBER;
O_RETURN_REDEEM_DTL PSAPP.CY_SALESPOSTING.REDEEM_DTL_TYPE;
O_RTRN_CD NUMBER;
O_ERR_CD NUMBER;
O_ERR_MSG VARCHAR2(200);
BEGIN
ZL_DIVN_NBR_IN := 71;
GREG_DATE_IN := TO_DATE('07/21/2008', 'MM/DD/YYYY');
ZL_STORE_NBR_IN := 39;
REGISTER_NBR_IN := 1;
TRANS_NBR_IN := 129;
-- O_RETURN_REDEEM_DTL := NULL; Modify the code to initialize this parameter
O_RTRN_CD := NULL;
O_ERR_CD := NULL;
O_ERR_MSG := NULL;
PSAPP.CY_SALESPOSTING.REDEEM_DTL_READ ( ZL_DIVN_NBR_IN, GREG_DATE_IN, ZL_STORE_NBR_IN,
REGISTER_NBR_IN, TRANS_NBR_IN, O_RETURN_REDEEM_DTL, O_RTRN_CD, O_ERR_CD, O_ERR_MSG );
FOR item IN 1..O_RETURN_REDEEM_DTL.COUNT
LOOP
DBMS_OUTPUT.PUT_LINE('ZL_DIVN_NBR = ' || O_RETURN_REDEEM_DTL(item).ZL_DIVN_NBR);
END LOOP;
END;and the new error:
ORA-06550: line 25, column 38:
PLS-00487: Invalid reference to variable 'O_RETURN_REDEEM_DTL'
ORA-06550: line 25, column 3:
PL/SQL: Statement ignoredAlso, it would be nice if the forums would put a box around code so that it would be easy to
distinguish between what is supposed to be code and what should be regular text...
Message was edited by:
user607908 -
I am trying to do a test for a null result set. Basically if the result set returns a value I want to display a table, otherwise I want to display an error message. The following code does not produce the error message. Either the test for null is incorrect, or for some reason I am not getting a null result set even when I don't enter any text into the following text boxes (this is for a login screen, these text boxes come a login screen):
<input type="text" name="username">
<input type="text" name="password">
This is the code for the action page:
<HTML>
<%@page import="java.sql.*"%>
<%
//define connection
Connection con = null;
String user1 = request.getParameter("username");
String pass1 = request.getParameter("password");
String test = "good";
try{
//get the class
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
//get the connection
con = DriverManager.getConnection("jdbc:odbc:errorlog", "admin", "");
//catch your exceptions!
catch(Exception e){
out.println(e.getMessage());
%>
<title>Error Application - Logged Errors</title>
<link href="style/errorstyle.css" rel="stylesheet" type="text/css">
<BODY>
<%
//define resultset and statement
ResultSet rs=null;
Statement stmt=null;
try {
//Using the current database connection create a statement
stmt=con.createStatement();
%>
<%
String sql="SELECT* FROM tblUsers" + " WHERE Username = '"+user1+"' AND Password ='"+pass1+"'";
rs = stmt.executeQuery(sql);
%>
<% //Fetch all the records and print in table
while(rs.next()){
String user2 = rs.getString("FirstName");
String pass2 = rs.getString("LastName");
%>
<table width="100%" border="0" cellspacing="1" cellpadding="6">
<tr >
<td width="67" height="27" bgcolor="#999999"><strong><font size="- 1">First Name</font></strong>
</td>
<td width="89" bgcolor="#999999"><strong><font size="-1">Last
Name</font></strong>
</td>
</tr>
<tr>
<td>
<%out.println(user2);%>
</td>
<td><%out.println(pass2);%></td>
</table>
<%}
if (rs == null)
out.println("Incorrect Username or Password");
//close all your open resultsets, statements, and connection when you are done with them!
rs.close();
stmt.close();
con.close();
//catch all your exceptions
catch (SQLException e) {
out.println(e.getMessage());
%>You simply test the rs.next().
if ( rs.next() )
//spit out the rs row and
//continue processing the resultset 'til empty
else
msg = "invalid username or password
} -
How to Create a new column from two different result sets
How to Create a new column from two different result sets, both the result set uses the different date dimensions.
i got solutions for this is apply filters in column formula it self, based on the requirement.
Maybe you are looking for
-
Hi, I have to upload a text file which has 12 fields seperated by commas and each of the character field is enclosed by quotes(" ").I tried uploading using GUI_UPLOAD but it is going for short dump. First row of the file is as below: 1,"ALU",0,"7","
-
Hi I have a VPS with Windows Server 2012 R2 at a hosting company. It is from the start deployed with 2 virtual disks: DISK 1 (32 GB) with "system reserved" and the C drive with the OS - and DISK 0 (70 GB). Can I somehow transfer some of the space for
-
The Ipod cannot be synced. An unknown error occured (-48)
This message keeps appearing when sycing my Ipod. Has anyone else had this problem? & does anyone know how i can resolve this? Any info appreciated, thanks.
-
Using Xellerate User as trusted Resource Object - 11G Release 2
Hi all, I want you use Xellerate User as trusted Resource Object for trusted reconciliation. From design console I try to add my custom attributes to this RO, but when I try to save I get error that it is not permmited.Is this a kinda bug or in Relea
-
How can I get orange to STOP sending me unwanted text messages!!!!!!!!!!