|
A case when clause can only return values, not conditions.
|
|
|
|
|
Quote: type Exception report
message
descriptionThe server encountered an internal error () that prevented it from fulfilling this request.
exception
javax.servlet.ServletException: java.sql.SQLException: [Microsoft][ODBC Driver Manager] The specified DSN contains an architecture mismatch between the Driver and Application
root cause
java.sql.SQLException: [Microsoft][ODBC Driver Manager] The specified DSN contains an architecture mismatch between the Driver and Application
|
|
|
|
|
Searching for the error message and ODBC with Google founds this MSDN article[^] as first result.
When using a 64-bit Java you must use the 64-bit driver.
|
|
|
|
|
|
I want to get a count of an ID where the ID is either = -999 or its not. So i have 2 counts in total. I used union all to get that but i think there would be better way to get the count from the same field. any help would be appreciated.
select count(ID) as Id_999 from table_A where ID='-999'
union all
select count(ID) from table_A where ID<>'-999'
there is no null values allowed so it either a number or -999 if null when table is loaded.
|
|
|
|
|
You could turn the counts into separate columns:
select SUM (
CASE
WHEN ID = '-999' THEN 1
ELSE 0
END)
AS ID999_count,
SUM (
CASE
WHEN ID <> '-999' THEN 1
ELSE 0
END)
AS nonID999_count
from table_A
Scott
|
|
|
|
|
Thanks Scott it works great. I was close to that but i was putting ID, then the sum(CASE statement). Thanks again.
|
|
|
|
|
Qazzy64 wrote: there is no null values allowed so it either a number or -999 if null when table is loaded.
Just curious; does that mean that you replace a null-test with a test for -999, and act according? Why was null disallowed anyway?
Bastard Programmer from Hell
if you can't read my code, try converting it here[^]
|
|
|
|
|
When they load the table it has a number(ID) or if its null they load -999 so they know to reprocess it later on when other matching data shows up. Hope that helps.
|
|
|
|
|
The reason I asked is because it does not make any sense to me; you'd still have to deal with the same type of checks. The only difference being that the new "strategy" will be alien to new developers, and will cause weirder and harder to debug-exceptions than a null-reference would.
I might be missing some obvious advantage of the approach. So, where is it? What's the 'added value' of using a marker-value above a null-value?
Bastard Programmer from Hell
if you can't read my code, try converting it here[^]
|
|
|
|
|
I agree with you that doing anything causes more problems eventually. Myself i would not have brought the data forward until all fields are present from source file. But i do not make that choice and i got involved after project was started. This is more of a transactional system then data warehouse like they said. Hate to say it but it goes back to the way it was architected and going forward from there has been to get it to work. Very complex data modeling which i would have simplified by bringing it in and leveling data types. They chose to bring it forward anyway and then leave just before the DW level. Makes no sense but i wasnt in on those meetings. I get to deal with it and figure out if the data is accurate. Fun times.
|
|
|
|
|
Hi Mr
i have a problem in ssis when i tried to use xml file to import to any data sources
i used Multicast to test no or rows returned but no returned rows
i can't attach xml file in the message
please save as GetGroups.xml and test it and send me the result
="1.0"="utf-16"
<DataSet>
<xs:schema id="NewDataSet" xmlns="" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xs:element name="NewDataSet" msdata:IsDataSet="true" msdata:UseCurrentLocale="true">
<xs:complexType>
<xs:choice minOccurs="0" maxOccurs="unbounded">
<xs:element name="T">
<xs:complexType>
<xs:sequence>
<xs:element name="ID" type="xs:int" minOccurs="0" />
<xs:element name="NodeGroup" type="xs:string" minOccurs="0" />
<xs:element name="NodeCount" type="xs:int" minOccurs="0" />
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:choice>
</xs:complexType>
</xs:element>
</xs:schema>
<diffgr:diffgram xmlns:msdata="urn:schemas-microsoft-com:xml-msdata" xmlns:diffgr="urn:schemas-microsoft-com:xml-diffgram-v1">
<NewDataSet>
<T diffgr:id="T1" msdata:rowOrder="0">
<ID>648</ID>
<NodeGroup>Moustord</NodeGroup>
<NodeCount>5</NodeCount>
</T>
<T diffgr:id="T2" msdata:rowOrder="1">
<ID>646</ID>
<NodeGroup>Shell</NodeGroup>
<NodeCount>9</NodeCount>
</T>
<T diffgr:id="T3" msdata:rowOrder="2">
<ID>647</ID>
<NodeGroup>Suze</NodeGroup>
<NodeCount>4</NodeCount>
</T>
</NewDataSet>
</diffgr:diffgram>
</DataSet>
modified 9-Oct-12 1:55am.
|
|
|
|
|
i tried to use OPENROWSET like that but it's not work can you modify it
DECLARE @xml XML
SET @xml = '<DataSet>
<xs:schema id="NewDataSet" xmlns="" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xs:element name="NewDataSet" msdata:IsDataSet="true" msdata:UseCurrentLocale="true">
<xs:complexType>
<xs:choice minOccurs="0" maxOccurs="unbounded">
<xs:element name="T">
<xs:complexType>
<xs:sequence>
<xs:element name="ID" type="xs:int" minOccurs="0" />
<xs:element name="NodeGroup" type="xs:string" minOccurs="0" />
<xs:element name="NodeCount" type="xs:int" minOccurs="0" />
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:choice>
</xs:complexType>
</xs:element>
</xs:schema>
<diffgr:diffgram xmlns:msdata="urn:schemas-microsoft-com:xml-msdata" xmlns:diffgr="urn:schemas-microsoft-com:xml-diffgram-v1">
<NewDataSet>
<T diffgr:id="T1" msdata:rowOrder="0">
<ID>648</ID>
<NodeGroup>Moustord</NodeGroup>
<NodeCount>5</NodeCount>
</T>
<T diffgr:id="T2" msdata:rowOrder="1">
<ID>646</ID>
<NodeGroup>Shell</NodeGroup>
<NodeCount>9</NodeCount>
</T>
<T diffgr:id="T3" msdata:rowOrder="2">
<ID>647</ID>
<NodeGroup>Suze</NodeGroup>
<NodeCount>4</NodeCount>
</T>
</NewDataSet>
</diffgr:diffgram>
</DataSet>'
;WITH XMLNAMESPACES(
'http://www.w3.org/2001/XMLSchema' AS ns,
'urn:schemas-microsoft-com:xml-diffgram-v1' AS diffgr )
SELECT
fd.c.value('(ID/text())[1]', 'INT') 'a',
fd.c.value('(NodeGroup/text())[1]', 'nvarchar(255)') 'b',
fd.c.value('(NodeCount/text())[1]', 'INT') 'c'
FROM @xml.nodes('ns:DataSet/diffgr:diffgram/NewDataSet/T') fd(c)
|
|
|
|
|
Hi,
What's the problem with this code?:
CREATE DEFINER=`root`@`localhost` PROCEDURE `sp_delete_channel`(IN param_channel_id int, IN param_volow_member_id int, OUT param_is_channel_created bit)
BEGIN
DELETE FROM member_posts WHERE member_channel_id = param_channel_id;
DELETE FROM member_channels WHERE member_channel_id = param_channel_id;
IF NOT EXISTS (SELECT member_channel_id FROM member_channels WHERE volow_member_id = param_volow_member_id) THEN
BEGIN
UPDATE volow_members SET is_channel_created = FALSE;
SET param_is_channel_created = FALSE;
END;
ELSE SET param_is_channel_created = TRUE;
END IF;
END
I am not getting any error on mysql neither on the .net application?!!
here is my .net code:
sql_connection = new MySqlConnection(ConfigurationManager.ConnectionStrings["SQLdb"].ConnectionString);
sql_command = new MySqlCommand("sp_delete_channel", sql_connection);
sql_command.CommandType = CommandType.StoredProcedure;
sql_connection.Open();
sql_command.Parameters.AddWithValue("param_channel_id", channel_id).MySqlDbType = MySqlDbType.Int32;
sql_command.Parameters.AddWithValue("param_volow_member_id", Convert.ToInt32(Session["volow_member_id"])).MySqlDbType = MySqlDbType.Int32;
sql_command.Parameters.AddWithValue("param_is_channel_created", MySqlDbType.Bit).Direction = ParameterDirection.Output;
int result_row = sql_command.ExecuteNonQuery();
if (Convert.ToBoolean(sql_command.Parameters["param_is_channel_created"].Value) != true)
{ Session["is_channel_created"] = false; }
|
|
|
|
|
Not getting any errors could sometimes be thought of as a good thing.
What's the problem?
|
|
|
|
|
that's what's making me crazy!
no error in Mysql nor C# code
but the MySQL code is not getting invoke. DELETE is not happening!
|
|
|
|
|
..
Try 'debugging'. What does the row-count return? What happens if you put a 'SELECT 1' in there, without any parameters, does that execute?
Bastard Programmer from Hell
if you can't read my code, try converting it here[^]
|
|
|
|
|
How do you know that the DELETE did not happen? Did you check in the database?
What do you expect to get at int result_row = sql_command.ExecuteNonQuery(); ?
|
|
|
|
|
yes i checked the database itself. records were not deleted and no error were thrown
|
|
|
|
|
This line
sql_command.Parameters.AddWithValue("param_is_channel_created", MySqlDbType.Bit).Direction = ParameterDirection.Output;
is wrong. AddWithValue expects a value as the second parameter but you are providing it a data type (did you mean to call Add method?). Anyway, you should not be providing a value to an output parameter.
I'm not sure if this is what is the cause of your problem.
|
|
|
|
|
how can i proivide an value?? it's an OUT parameter
|
|
|
|
|
I even tried this simple delete but still not working. No error and records not getting deleted!!!
sql_connection = new MySqlConnection(ConfigurationManager.ConnectionStrings["SQLdb"].ConnectionString);
sql_command = new MySqlCommand("sp_delete_channel", sql_connection);
sql_command.CommandType = CommandType.StoredProcedure;
sql_connection.Open();
sql_command.Parameters.AddWithValue("param_channel_id", channel_id).MySqlDbType = MySqlDbType.Int32;
int result_row = sql_command.ExecuteNonQuery();
and SQL:
CREATE DEFINER=`root`@`localhost` PROCEDURE `sp_delete_channel`(IN param_channel_id int, IN param_volow_member_id int, OUT param_is_channel_created bit)
BEGIN
DELETE FROM member_posts WHERE member_channel_id = param_channel_id;
DELETE FROM member_channels WHERE member_channel_id = param_channel_id;
IF NOT EXISTS (SELECT member_channel_id FROM member_channels WHERE volow_member_id = param_volow_member_id) THEN
BEGIN
UPDATE volow_members SET is_channel_created = FALSE;
SET param_is_channel_created = FALSE;
END;
ELSE SET param_is_channel_created = TRUE;
END IF;
END
|
|
|
|
|
Hi everyone. I'm trying open a connection to sql server database in a background thread while showing a progress dialogbox that has a Cancel button.
I would like to know how I can terminate the connection when the Cancel button is clicked and SqlConnection.Open call is still connecting. Thanks.
|
|
|
|
|
I'm afraid you cannot do that. SqlConnection.Open is a blocking call and control will not return to the calling code until the method completes. And I'm not aware of any asynchronous way of opening a database connection.
I stand corrected. Check Eddy's answer below for an asynchronous way of doing this.
modified 4-Oct-12 15:20pm.
|
|
|
|
|
Use OpenAsync[^], or it's overload[^].
--edit
For which version of Sql Server? Take note of the "supported platforms" in the documentation.
Bastard Programmer from Hell
if you can't read my code, try converting it here[^]
|
|
|
|