If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > MySQL > how to use a 'view' created by 'create view' in my C/C++ program

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 10-07-08, 05:38
cy163 cy163 is offline
Registered User
 
Join Date: Apr 2007
Posts: 127
how to use a 'view' created by 'create view' in my C/C++ program

Hello ALL,

I would like to create and use a view in my C/C++ program. How to create and access the view.

Can I directly use the following statement in my c/c++ program

Code:
create view myview (x, y, ...) as select ......'.,
but how to declare the variable myview in the C/C++ program?

Thanks,

Last edited by cy163; 10-07-08 at 05:41.
Reply With Quote
  #2 (permalink)  
Old 10-07-08, 05:47
healdem healdem is offline
Jaded Developer
 
Join Date: Nov 2004
Location: out on a limb
Posts: 9,250
the view is MySQL specific
its SQL not any thirdparty language like C/C++ or whatever
so you need to send it to the server as you woudl any other SQL statements

its a two step process..
first off create the view (can be done in C++, remember to use drop if exists)
then use the view as you would in any valid SQL statement
__________________
I'd rather be riding my Versys or my Tiger 800 let alone the Norton
Reply With Quote
  #3 (permalink)  
Old 10-07-08, 18:26
cy163 cy163 is offline
Registered User
 
Join Date: Apr 2007
Posts: 127
Quote:
Originally Posted by healdem
the view is MySQL specific
its SQL not any thirdparty language like C/C++ or whatever
so you need to send it to the server as you woudl any other SQL statements

its a two step process..
first off create the view (can be done in C++, remember to use drop if exists)
then use the view as you would in any valid SQL statement
healdem, thanks.

I am new to MySQL. so I am not very clear about your solution.

When I queried a MySQL database, I had to use the following MySQL C API function
Code:
mysql_query("SELECT my_col FROM my_tbl") ;
in my C/C++ program. I wonder if there is any MySQL C API function to take
Code:
"create view viewname (x, y, ....) as select......." as argument.
Or, I can directly put the above create statement in my C/C++ program.

Thanks
Reply With Quote
  #4 (permalink)  
Old 10-08-08, 01:12
healdem healdem is offline
Jaded Developer
 
Join Date: Nov 2004
Location: out on a limb
Posts: 9,250
as siad before its a two stage process
first off you create the view, whetehr tyou do that in C++ or say a query program like MySQL Query browser is up to you.

havign created the view it then becimes avaialble to you, and any other developer.

I'd suggest you create the view in MySQL Query Browser.
you can modify views, by dropping the earlier version and replacing have a look at the doecumentation on views and the drop/create syntax on the MySQL manual

I don't know C++ but as the create syntax is MySQL SQL thesame function that you sue to SELECT data shoudl also work for view creation. Effectively its exactly the same as other DDL sattements that create or modify tables
__________________
I'd rather be riding my Versys or my Tiger 800 let alone the Norton
Reply With Quote
  #5 (permalink)  
Old 10-09-08, 07:14
cy163 cy163 is offline
Registered User
 
Join Date: Apr 2007
Posts: 127
the solution is
in C/C++ program,
mysql_query(create view myview as select ....)
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On