Showing posts with label beginner. Show all posts
Showing posts with label beginner. Show all posts

Friday, March 30, 2012

Please Help me

I have to learn VS2005 with SQL Express What should I do? Where are beginner's guides and tutorials?

try here:

http://msdn.microsoft.com/vstudio/express/vb/learning/

http://www.learnvisualstudio.net/

|||

Thank you very much Lepaca

I have error message

SQL Exception error

An error has occurred while establishing a connection to server. When connecting to SQL Server 2005, this failure may be caused by the fact that under the defualt setting SQL Server does not allow remote connections (provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server)

|||

Maybe, this thread can help you:

http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=147346&SiteID=1&PageID=1

sql

Friday, March 9, 2012

PL/SQL Problem

I'm having problems with the one homework problem, i'm a beginner and i'm pretty much trying to teach myself PL/SQL...can someone please help me out?...

scrore is a column of table students and its datatype is NUMBER. Assume that all values in this column score are distinct and that there are more than 3 values in this column. Write a piece of PL/SQL code that will find out the third largest score and the third smallest score. (You can print out the values or return the values.)

O~Originally posted by oflowers
I'm having problems with the one homework problem, i'm a beginner and i'm pretty much trying to teach myself PL/SQL...can someone please help me out?...

scrore is a column of table students and its datatype is NUMBER. Assume that all values in this column score are distinct and that there are more than 3 values in this column. Write a piece of PL/SQL code that will find out the third largest score and the third smallest score. (You can print out the values or return the values.)

O~
You could consider using RANK or DENSE_RANK:

SQL> select ename, sal,
2 rank() over (order by sal) rank_asc,
3 rank() over (order by sal desc) rank_desc,
4 dense_rank() over (order by sal) dense_rank_asc,
5 dense_rank() over (order by sal desc) dense_rank_desc
6 from emp
7* order by sal;

ENAME SAL RANK_ASC RANK_DESC DENSE_RANK_ASC DENSE_RANK_DESC
---- ---- ---- ---- ----- -----
SMITH 800 1 14 1 12
JAMES 950 2 13 2 11
ADAMS 1100 3 12 3 10
WARD 1250 4 10 4 9
MARTIN 1250 4 10 4 9
MILLER 1300 6 9 5 8
TURNER 1500 7 8 6 7
ALLEN 1600 8 7 7 6
CLARK 2450 9 6 8 5
BLAKE 2850 10 5 9 4
JONES 2975 11 4 10 3
SCOTT 3000 12 2 11 2
FORD 3000 12 2 11 2
KING 5000 14 1 12 1

14 rows selected.

Note there is no RANK_DESC=3, so probably DENSE_RANK suits you better:

SQL> select ename, sal
2 from
3 (
4 select ename, sal,
5 dense_rank() over (order by sal) dense_rank_asc,
6 dense_rank() over (order by sal desc) dense_rank_desc
7 from emp
9 )
10 where dense_rank_asc=3
11* or dense_rank_desc=3;

ENAME SAL
---- ----
JONES 2975
ADAMS 1100

Either print out or return those values as you prefer.|||Hi,
It is a good solution using the dense_rank, but i presume if you need to have more sorting on the same, you could do some sorting in the embedded query, like sorting on the ename itself.

I wish i saw this posting two weeks back, I could have saved quite a bit of time in a query, which wanted to look for the second orderid for a person out of around 10000 records.
:)

PL/SQL for searching

hi all..

i'm a beginner in using oracle9i form for web dev and ..i have problem to create searching button (pl/sql code) where the record that i tried to find using the text item..can somebody help me

example:
textitem10 is value that will be keyin in the form
----
declare
textitem10 number(2);

begin
select empno,ename,edept from emp
into :textitem1,
:textitem2,
:textitem3
where empno = 'textitem10'
end;
execute_query;

but my coding is doesn't work..
found error "FRM-40735: WHEN-BUTTON-PRESSED trigger araised unhandled exception ORA-01403"..any body know help me..pleaze
thanks
flyguysOriginally posted by flyguys
hi all..

i'm a beginner in using oracle9i form for web dev and ..i have problem to create searching button (pl/sql code) where the record that i tried to find using the text item..can somebody help me

example:
textitem10 is value that will be keyin in the form
----
declare
textitem10 number(2);

begin
select empno,ename,edept from emp
into :textitem1,
:textitem2,
:textitem3
where empno = 'textitem10'
end;
execute_query;

but my coding is doesn't work..
found error "FRM-40735: WHEN-BUTTON-PRESSED trigger araised unhandled exception ORA-01403"..any body know help me..pleaze
thanks
flyguys
ORA-01403 means "No data found" - i.e. the select returned no rows.

This is probably because you should have written it like this:

select empno,ename,edept from emp
into :textitem1, :textitem2, :textitem3
where empno = :textitem10;

As written, it was looking for an emp record with an empno value of 'textitem10', which of course does not exist.

Pl/SQL Beginner Problem, Selecting all records?

SET SERVEROUTPUT ON;

DECLARE
student_rec student%ROWTYPE;
BEGIN
SELECT *
INTO student_rec
FROM student
WHERE student_id = 156 ;
DBMS_OUTPUT.PUT_LINE ('Last Name : '|| student_rec.last_name || chr(10)||
'First Name : '|| student_rec.first_name || chr(10)||
'Phone Number : '|| student_rec.phone || chr(10)||
'Reg Date : '|| student_rec.registration_date);
EXCEPTION
WHEN no_data_found THEN
RAISE_APPLICATION_ERROR(-20001, 'Student with id = 156 is not in the Database');
WHEN others THEN
DBMS_OUTPUT.PUT_LINE(SQLCODE || ' '|| substr(SQLERRM,1,80));
END;
.

In the above code it selects the information for the student with the id of 156, how do I change it so that it selects all students from the table instead of just the one?

Any help appreciated.just remove the condition tht where student id = 156:

SELECT *
INTO student_rec
FROM student

above script will select all the student in student and store it into the sudent_rec .

RAISE_APPLICATION_ERROR(-20001, 'Student with id = 156 is not in the Database');

when you want to raise the exeception just write it ther is no record in the table instad of student with id= 156 is not in the database.|||Hi,

Use a cursor & remove the Hard coded value 156 in the query.

Originally posted by iknownothing
SET SERVEROUTPUT ON;

DECLARE
student_rec student%ROWTYPE;
BEGIN
SELECT *
INTO student_rec
FROM student
WHERE student_id = 156 ;
DBMS_OUTPUT.PUT_LINE ('Last Name : '|| student_rec.last_name || chr(10)||
'First Name : '|| student_rec.first_name || chr(10)||
'Phone Number : '|| student_rec.phone || chr(10)||
'Reg Date : '|| student_rec.registration_date);
EXCEPTION
WHEN no_data_found THEN
RAISE_APPLICATION_ERROR(-20001, 'Student with id = 156 is not in the Database');
WHEN others THEN
DBMS_OUTPUT.PUT_LINE(SQLCODE || ' '|| substr(SQLERRM,1,80));
END;
.

In the above code it selects the information for the student with the id of 156, how do I change it so that it selects all students from the table instead of just the one?

Any help appreciated.|||When I remove the WHERE statement, I get an error when I run it saying
"-1422 ORA-01422: exact fetch returns more than requested number of rows"|||Hi,

Use CURSOR to avoid this error. Because you can fetch only one row into the record type student_rec . When the value 156 is harcoded in the query , exactly one row is fetched into student_rec . So it works fine. But once you remove the hard coded value 156 from the query, all the records are fetched . Since the record type student_rec can accept only one value, it displays the error ORA-01422: exact fetch returns more than requested number of rows. To avoid this error & fetch all the records into student_rec, use a CURSOR.

Originally posted by iknownothing
When I remove the WHERE statement, I get an error when I run it saying
"-1422 ORA-01422: exact fetch returns more than requested number of rows"|||Its ok, fixed it! Thanks.|||As an aside from your question, you should get out of the habit of doing this:

EXCEPTION
WHEN no_data_found THEN
RAISE_APPLICATION_ERROR(-20001, 'Student with id = 156 is not in the Database');
WHEN others THEN
DBMS_OUTPUT.PUT_LINE(SQLCODE || ' '|| substr(SQLERRM,1,80));
END;

All that does is potentially hide errors from the user and allow inconsistent partial transactions to be committed. It should be simply:

EXCEPTION
WHEN no_data_found THEN
RAISE_APPLICATION_ERROR(-20001, 'Student with id = 156 is not in the Database');
END;