|
Thanks for looking at it. I did check that. I went ahead and edited my post and added that table to it for inspection. I'll probably need to add all the tables.
|
|
|
|
|
What I can see is a mixture of ANSI joins and an implicit join. And I can understand if the optimizer pukes on that.
Try using all ANSI Joins:
SELECT DISTINCT p.prod_id, p.model, p.showpricing, p.image_file, p.image_width, p.image_height, p.image_border, p.name, m.manufacturer,
CASE WHEN sp.price IS NULL THEN 0 ELSE sp.price END AS list_price,
CASE WHEN sp.price IS NULL OR ssp.discount IS NULL THEN 0 ELSE sp.price - ssp.discount END AS sale_price,
CASE WHEN NOW() BETWEEN p.mfgrebatestart AND p.mfgrebateend THEN p.mfgrebate ELSE 0 END AS mfgrebate
FROM comm_product p
INNER JOIN comm_manufacturer m ON p.mfg_id = m.mfg_id
INNER JOIN comm_dept_prod dp ON p.prod_id = dp.prod_id
INNER JOIN comm_partners_products pa ON p.prod_id = pa.prod_id
LEFT JOIN comm_sku_price sp ON p.default_sku_id = sp.sku_id AND NOW()
BETWEEN sp.date_start AND sp.date_end
LEFT JOIN comm_sku_sale_price ssp ON p.default_sku_id = ssp.sku_id AND NOW()
BETWEEN ssp.date_start AND ssp.date_end
WHERE pa.p_id = :partnerID
AND p.avail_type < 3 AND p.image_file > ''
AND p.model NOT LIKE 'EBAY-%'
AND p.dept_ad = 1
AND dp.dept_id = :deptID
ORDER BY rand() LIMIT 4
Politicians are always realistically manoeuvering for the next election. They are obsolete as fundamental problem-solvers.
Buckminster Fuller
|
|
|
|
|
Wow thanks.
I ran it in the mysql workbence. it didn't produce an error and ran clean, but it didn't product any rows on :partner = 1000 and :dept = 52.
But it's a step closer.
Oh wait, changed the dept to 54, and got rows!
Cool.
Let me give it a test run in the code, should work fine. I may have another one today
This was way over my head here. It's hard to be a programmer, art guy, HTML and CSS all at once. The SQL stuff seems to be an expertise on a higher level.
Thanks Jorgen, your the best!
I don't understand the ANSI JOIN versus the implicit, guess I can Google that to learn exactly what was wrong.
|
|
|
|
|
jkirkerx wrote: Wow thanks
My pleasure.
jkirkerx wrote: I don't understand the ANSI JOIN versus the implicit, guess I can Google that to
learn exactly what was wrong.
Yes, or even better, in this case, Wikipedia[^].
Politicians are always realistically manoeuvering for the next election. They are obsolete as fundamental problem-solvers.
Buckminster Fuller
|
|
|
|
|
I plugged it in, pretty sure I got the translation right because I don't get a SQL error and the SQL Query matches when I print it out on the screen.
It's really close, but I guess it's suppose to produce a result set of 4 rows on almost every dept ID
This is out of my league here. oh well.
Thanks for help, At least I know my code changes work, and I can do testing with it.
|
|
|
|
|
hi.i want write insert procedure in access.
|
|
|
|
|
And your QUESTION is!
I think Access has a macro function so step through the insert while recording a macro and inspect the SQL code generated.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Hi guys,
PLZ help me!
Scenario - My client has 2 server machine. one is database server with oracle 10g database 64-bit. Another server(new one) is windows 2008 server which has an .net 2.0+3.5 website hosted. This website make use of System.data.oracleClient dll . Problem is that this app is not able to connect to oracle 10g database server though it is able to connect to some other 11g R2 database server. On this app server we have also tried to install oracle 10g 32-bit client but still can't access. Tnsping and sqlplus is working fine. Pls. suggest.
Solution that we tried :-
- Gave permission and added various users to oracle directory and sub-directory like IIS_Iuser,network service, anonymous etc.
Possible culprit:-
- Earlier on this app server oracle 11g 32-bit client was installed. So my client has although worked on to remove it by manually deleting folder , deleting registeries , extra home directories. but it looks like a possible reason to me..
Note - we use some internal ddl for dataaccess , so im not able to see actual error just some OLEDB exception.
Pls help
|
|
|
|
|
abhi17_6 wrote: Problem is that this app is not able to connect to oracle 10g database server
though it is able to connect to some other 11g R2 database server.
A connectivity issue is not normally a code issue. Causes
- There is in fact no way to connect from server A to B. Perhaps because of firewall or IP routing.
- The host and/or port used on the client is wrong.
Simple test...
- Log in to the client box.
- Telnet to the Oracle box using the exact same host and port of the connection data.
If telnet connects then you probably have connectivity. If not then it is one of the above - don't look at code until the telnet test works.
It might work for you and not work for a server depending on the user the server runs under and how you logged in.
|
|
|
|
|
@jshell - we have installed oracle client 10g 32 bit also on web app server machine. and my client is able to do tnsping and use sqlplus here.
Questions-
- do i need to use telnet utility from my App server or from my oracle server machine? u mentioned client box, which one is it?
|
|
|
|
|
The "web app" would be the client machine.
|
|
|
|
|
Hello,
I am able to create a directory by using sql as
Exec master.dbo.xp_cmdshell 'C:\MyTest\<<date>>'
but when I tried to create director name with space as
Exec master.dbo.xp_cmdshell 'C:\My Test'\<<date>> then its throwing error.
can anybody please help me how to create directory with space in SQL
Samar
|
|
|
|
|
Surround the directory string with double quotes
=========================================================
I'm an optoholic - my glass is always half full of vodka.
=========================================================
|
|
|
|
|
Thank you very much for your reply
but I already did as
Exec master.dbo.xp_cmdshell '"C:\Temp\My Test "'
but still getting facing problem
Samar
|
|
|
|
|
Samarjeet Singh@india wrote: Exec master.dbo.xp_cmdshell 'C:\My Test'\<<DATE>> then its throwing
error.
What's that? always include those details in your question.
|
|
|
|
|
For example if I tried to run in sql
Exec master.dbo.xp_cmdshell '"C:\Temp\My Test"'
Then I am getting following 3 rows of messages
1- 'C:\Temp\My' is not recognized as an internal or external command
2-operable program or batch file.
3- NULL
Thanks
|
|
|
|
|
|
Thank u very much !!!!!
its working in sql2008 but client is running in older version(Sql2000) and in older version its unable to find the reference and producing following msg
Server: Msg 2812, Level 16, State 62, Line 1
Could not find stored procedure
is any other method so that its working in SQL2000 as well
Thanks in advance
|
|
|
|
|
For SQL 2000, you'll need to stick with xp_cmdshell , but you need to put mkdir in front of the path you want to create:
Exec master.dbo.xp_cmdshell 'mkdir "C:\My Test\<<DATE>>"'
http://www.sqlservercentral.com/Forums/Topic604168-8-1.aspx[^]
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Thank you very much it working for me
|
|
|
|
|
|
below procedure should be the solution
create procedure sp_create_directory
(
@full_path varchar(500)
)
as
set nocount on
declare @command varchar(1000)
set @command = 'mkdir ' + @full_path
exec master..xp_cmdshell @command , no_output
set nocount off
GO
|
|
|
|
|
Thanks for your great help
|
|
|
|
|
Hi !
Here is the snip of code in question:
.......
sql = "select " + picField + " from " + table + " where " + where;
conn = new SqlConnection(connectionstring);
byte[] picture = (byte[])ExecuteScalar(sql);
Image source = Image.FromStream(new MemoryStream(picture));
Image th = source.GetThumbnailImage(w, h, null, IntPtr.Zero);
.......
public object ExecuteScalar(string strCommand)
{
object res=null;
conn.Open();
SqlCommand cmd = new SqlCommand(strCommand, conn);
try
{
res = cmd.ExecuteScalar();
}
catch(Exception e)
{ res = e.Message; }
finally
{
conn.Close();
}
return res;
}
It worked like a sharm some time ago.
Code was not changed. The table definition also was not changed and field declaration is as follows:
[Picture_Image] [image] NOT NULL
But now I get error:
unable to cast object of type 'system.string' to type 'system.byte '
I suppose that something may be changed in the server and/or DB settings. But what ??
Can somebody please shed a light on this issue?
Thanks in advance.
Regards,
Gennady
My English is permanently under construction. Be patient !!
|
|
|
|
|
Gennady Oster wrote: catch(Exception e){ res = e.Message; }
return res;
There is an error in your query which is causing the ExecuteScalar method to throw an exception. Due to the incredibly poor decision to return the exception message as a valid result from your ExecuteScalar method, the calling code is trying to cast the string containing the error message to a byte[] , which will never work. Remove the catch clause from your method to allow the exception to propagate to the calling code.
The fact that you're specifying a WHERE clause but not passing any parameters suggests that your code is susceptible to SQL Injection[^]. Update your code to use parameterized queries before you get a visit from little Bobby Tables[^].
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|