.Net Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsProgramming Languages - More.Net Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old February 24th, 2012, 04:40 AM
pepeto1975 pepeto1975 is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2012
Posts: 1 pepeto1975 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 9 m 44 sec
Reputation Power: 0
C# Problem ODBC output parameter from postgresql funtion

Hi

How i get the output parameter from the function,
is always nothing in console.
What is wrong?

Here in c#

string connstring = "DSN=PostgreSQL35W";
string procedure = "{CALL f1001.fn_check_insert_mission02(?,?)}";

OdbcConnection connection = new OdbcConnection(connstring);

OdbcCommand cmd = new OdbcCommand(procedure, connection);

cmd.CommandType = CommandType.StoredProcedure;

OdbcParameter themissionNameParam = new OdbcParameter( "@p_mission_name", OdbcType.NVarChar, 256 );
themissionNameParam.Value = "mission1";
themissionNameParam.Direction = ParameterDirection.Input;
cmd.Parameters.Add( themissionNameParam );

OdbcParameter themissionIdParam = new OdbcParameter( "@p_mission_id", OdbcType.Int);
themissionIdParam.Direction = ParameterDirection.Output;
cmd.Parameters.Add( themissionIdParam );


// Add the output parameter.

// Execute the command.
connection.Open();
cmd.ExecuteNonQuery();
connection.Close();

Console.WriteLine("New Mission has ID of " + themissionIdParam.Value);

Console.WriteLine();
Console.ReadKey();

here is the function

CREATE OR REPLACE FUNCTION f1001.fn_check_insert_mission02
(
IN p_mission_name varchar,
OUT p_mission_id integer
)
RETURNS integer AS
$$
DECLARE
v_mission_id int;

BEGIN
select mission_id into v_mission_id from f1001.mission where mission_name = p_mission_name;
if not found then
insert into f1001.mission (mission_name) values (p_mission_name) returning mission_id into v_mission_id;
end if;
p_mission_id = v_mission_id;
END;
$$
LANGUAGE 'plpgsql'
VOLATILE
CALLED ON NULL INPUT
SECURITY INVOKER
COST 100;

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - More.Net Development > C# Problem ODBC output parameter from postgresql funtion

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap