ORACLE select lacks row [closed] - database

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 9 years ago.
Improve this question
I use ORACLE setup RAC cluster.
My problem is when DB got problem (still dont know the reason ) my sql select lacks rows
example:
select *
from student_detail
where student_id = 1231
should return 10 row data of student have id 1231, but in this case just return 6 rows
can anybody help me to understand this problem!

As a general observation, an Oracle SELECT always returns the correct number of rows. If the result set does not match your expectation then there is a problem with your understanding.
For instance you may have miscounted the number of rows with student_id = 1231. If the query returns only six rows how do you know there are supposed to be ten? It might not be as simple as eyeballing ...
select * from student_detail
order by student_id
... if student_id has a varchar2 datatype and some IDs are suffixed with stray spaces. A query like this will diagnose that problem:
select student_id, count(*)
from student_detail
group by student_id
order by student_id
Other possible causes? A misleading view? Row Level Security restricting the result set? Some bizarre client-side configuration which only shows the first six rows instead of the entire set?
You mention RAC. RAC uses a mechanism called the Global Cache Service Process to transmit changed data to different nodes. It is possible you are experiencing a failure in this process. Talk to your DBA and get them to investigate.

Maybe, the data should be wrong.
for example, if the data of user_id is '1231', that's not wrong, but if the data is left gap
like ' 1231', you can't see the data.
' 1231 ' , '1231 ' also can not be printed out.
The solution is when you insert some data, use the function 'trim' or 'replace'...
trim is only remove left gap.

Related

using min value in where query sql server [closed]

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 8 years ago.
Improve this question
I have a data in table like this :
==============================================================================================
id idPaper Code Sequential
==============================================================================================
1A506D10-9306-495A-9E4E-7081E3D3ACDB F4CFE90D-0921-4FB7-A236-5420B0892379 0036 2
3DB0FEBF-FBDF-4768-B36A-83AF4FB53E4B F4CFE90D-0921-4FB7-A236-5420B0892379 0035 1
I want display data like this :
==============================================================================================
id idPaper Code Sequential
==============================================================================================
3DB0FEBF-FBDF-4768-B36A-83AF4FB53E4B F4CFE90D-0921-4FB7-A236-5420B0892379 0035 1
1A506D10-9306-495A-9E4E-7081E3D3ACDB F4CFE90D-0921-4FB7-A236-5420B0892379 0036 2
I run my query:
select *
from tablename
where idPaper = 'F4CFE90D-0921-4FB7-A236-5420B0892379'
and min(sequential)
but it does not work. Please help me...
Thanks...
I think you just want to sort the data. Perhaps you just want:
select *
rom tablename
where idPaper='F4CFE90D-0921-4FB7-A236-5420B0892379'
order by sequential;
You can use order by.
select *
from tablename
where idPaper='F4CFE90D-0921-4FB7-A236-5420B0892379'
order by sequential

Return Filter Quadrants for Search Results [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Closed 8 years ago.
This question appears to be off-topic because it lacks sufficient information to diagnose the problem. Describe your problem in more detail or include a minimal example in the question itself.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Improve this question
Working on a search page. My search results are working but I also need to provide filter choices. One of these choices are a set of price quadrants with product counts. So basically in the result set I have to grab the lowest price and the highest price, then equally break it into 4 groupings and then return those groupings with product counts for each.
So we returned back 49 products, the lowest priced product was $10 and the highest priced products was $110. I have to re-calculate this for every set of search results we're filtering so I can't hard code the floor and ceiling values.
So it would look like this with the number in parenthesis being the number of returned products with a value falling inside that quadrant.
$10.00 to $35.00 (2)
$35.01 to $60.00 (12)
$60.01 to $85.00 (0)
$85.01 to $110.00 (35)
I'm trying to do this in a single SELECT statement because we want to run it off the search results temporary table if the user asks for it.
I keep hitting brick walls trying to write this and can't seem to get very far.
I couldn't get it to work in a single statement, but I was able to get it to work. We created a Numbers table called [Numbers] that I'm using...
DECLARE #priceFloor money; DECLARE #priceCeiling money; DECLARE #priceRange int;
SELECT #PriceFloor = FLOOR(MIN(price)) , #PriceCeiling = CEILING(Max(price)),
#PriceRange = CEILING(Max(price))/4
FROM #TempSearchResults;
WITH priceFilterCTE AS
(
SELECT Number * #PriceRange AS FromPrice, (Number * #PriceRange) + #PriceRange -.01 AS ToPrice
FROM Numbers
WHERE Number BETWEEN 0 AND 3
)
SELECT CAST(FromPrice AS VARCHAR(20)) + ' to ' + CAST(ToPrice AS VARCHAR(20)) AS Price,
(
SELECT COUNT(1)
FROM #TempSearchResults
WHERE price BETWEEN priceFilterCTE.FromPrice AND priceFilterCTE.ToPrice
) AS [COUNT]
FROM priceFilterCTE
Return looks like....
PRICE COUNT
0 to 798.99 949
799 to 1597.99 162
1598 to 2396.99 32
2397 to 3195.99 7

Select particular text from a varying lenght of text value field [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Closed 8 years ago.
This question appears to be off-topic because it lacks sufficient information to diagnose the problem. Describe your problem in more detail or include a minimal example in the question itself.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Improve this question
I have a column with following rows in it
"XX - Make a determination from receipt of request within 15 calendar days"
"Make a determination from receipt of request or necessary info within 2 business days"
"YYYYYYY - Make a determination from receipt of request within 72 calendar hours"
"ZZZZZZZZZZZ - Make a determination from receipt of request within 30 calendar days"
and all types of different combinations with a similar pattern of
"XXXXXXXXXXXXXXXXXXXXX" from "text I want to get" within ZZZZZZZZZZZZZZZZZZZZ
The length of X and Z changes and so does the text between from and within but the from and within always exists in the text. How do I make a query to get the text I want to get into a table variable so that I compare it against other columns in the same table and see if they match or not?
I have the table variable and scalar variable in place to get the values. I just need the proper select statement.
This is really ugly. Fix the table and stop storing different data points inside a string you need to parse like this every time. If your supervisor doesn't understand why this is bad, ask him if he likes to re-program his remote control every time he turns the TV on.
SET NOCOUNT ON;
DECLARE #t TABLE(c VARCHAR(8000));
INSERT #t VALUES
('XX - Make...ion from receipt of request within 15 calendar days'),
('Make a de...ion from receipt of request or necessary info within 2 business days'),
('YYYYYYY - Make...ion from receipt of request within 72 calendar hours'),
('ZZZZZZZZZZZ - Make...ion from receipt of request within 30 calendar days');
SELECT SUBSTRING(c, 1, CHARINDEX('within', c)-1) FROM
(SELECT c = SUBSTRING(c, CHARINDEX('from', c) + 5, 8000) FROM #t) AS x;
Results:
receipt of request
receipt of request or necessary info
receipt of request
receipt of request

Counting Number of records in each row in SQL Server [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
Again I m sry fr that non-sense way of asking the question what i wanted to say that at the last column some rows have null values and some rows have a value which is not necessary.. So what i wanted to do to delete those rows which have not null values in last column and then deleting the whole last column...
The Table looks like this..:
Col1 Col2 Col3 Col4
A A A A
B B B
C C C
D D D D
So here i want to keep the row 2 and 3 and delete the row 1 and 4..Then deleting the whole column 4...
My answer is based on your comment:
Oopss!!! i am extremely sorry fr making a mess..:( what i wanted to
say that at the last column some rows have null values and some rows
have a value which is not necessary.. So what i wanted to do to delete
those rows which have not null values in last column and then deleting
the whole last column..
Here it is:
Delete from dbo.YourTable Where Last_Column IS NOT NULL
After that, dropping the column is easy if you go to table right click -> design
If it doesn't let you drop the column due to an error, you should do this:
Tools -> Options -> Designers-> Uncheck "Prevent saving changes that require table re-creation"
I'd suggest that you undo that change after you're done though.
Best of luck =)
What you're trying to do won't work because they'll all have the same number of columns.
So don't waste your time trying to implement it because it won't solve whatever problem you're trying to solve!
DELETE dbo.table WHERE Col4 IS NOT NULL;

Automatic generate a sales order line for every sales order [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 3 years ago.
Improve this question
Im experimenting with Dynamics Nav 2009.
Is there a way to automatically insert a sales line every time I make a new sales order?
I want postage to be included everytime Im making a new sales order.
There are two ways to solve this, one without programming, and one almost without programming.
If you postage line is a standard "charge" added to all orders then you can actually use the "Invoice Discount" functionality. Besides allowing you to assign an actual discount (typically being applied if the order is above a specific amount), then you can also use the functionality to add a "Service Charge". Either to be inserted on all orders, or only if the order total is below a certain "Minimum Amount".
You set it up by specifying the "Invoice Discount Code" field on the Customers and enable the automatic calculation in the "Calc. Inv. Disc." field in "Sales & Receivable Setup" table. The postage lines are not inserted as actual sales lines, but are calculated and applied when posting (or using the total / statistics button).
The other option is the use the "Standard Sales Codes". Here you can specify a number standard lines which are to be inserted whenever the standard sales code are selected. This is where I said a little programming is required, as the system doesn't automatically insert the lines. But you can insert a call to the function to insert the lines automatically when the customer no. has been entered.
This change would most likely require a modification from your NAV Partner.
The modification could add C/AL code to automatically insert a new Sales Line every time a new Sales Header record is created.
OnInsert()
SalesLine.INIT;
SalesLine."Document Type" := "Document Type";
SalesLine."Document No." := "No.";
SalesLine."Line No." := 0;
// Additional Code
SalesLine.INSERT(TRUE);

Resources