Tech Rocks

Coldfusion
Java
JQuery

An online resource for latest web technologies like Coldfusion, JRun, Pro*C, JQuery, HTML5, PHP, W3C, Java, J2EE, C, C++, ORACLE, PL/SQL, MySql, Ajax, Coldbox, Fusebox, UNIX, JavaScript, NodeJS and much more...

Saturday, February 7, 2009

Calling a stored procedure in Pro*C

#include
#include

EXEC SQL INCLUDE sqlca.h;


typedef char asciz[20];
typedef char vc2_arr[11];

EXEC SQL BEGIN DECLARE SECTION;
/* User-defined type for null-terminated strings */
EXEC SQL TYPE asciz IS STRING(20) REFERENCE;

/* User-defined type for a VARCHAR array element. */
EXEC SQL TYPE vc2_arr IS VARCHAR2(11) REFERENCE;

asciz username;
asciz password;
int dept_no; /* which department to query? */
vc2_arr emp_name[10]; /* array of returned names */
vc2_arr job[10];
float salary[10];
int done_flag;
int array_size;
int num_ret; /* number of rows returned */
EXEC SQL END DECLARE SECTION;

long SQLCODE;



void print_rows(); /* produces program output */
void sql_error(); /* handles unrecoverable errors */



main()
{
int i;
char temp_buf[32];

/* Connect to ORACLE. */
EXEC SQL WHENEVER SQLERROR DO sql_error();
strcpy(username, "scott");
strcpy(password, "tiger");
EXEC SQL CONNECT :username IDENTIFIED BY :password;
printf("\nConnected to ORACLE as user: %s\n\n", username);
printf("Enter department number: ");
gets(temp_buf);
dept_no = atoi(temp_buf);/* Print column headers. */
printf("\n\n");
printf("%-10.10s%-10.10s%s\n", "Employee", "Job", "Salary");
printf("%-10.10s%-10.10s%s\n", "--------", "---", "------");

/* Set the array size. */
array_size = 10;

done_flag = 0;
num_ret = 0;

/* Array fetch loop.
* The loop continues until the OUT parameter done_flag is set.
* Pass in the department number, and the array size--
* get names, jobs, and salaries back.
*/
for (;;)
{
EXEC SQL EXECUTE
BEGIN calldemo.get_employees
(:dept_no, :array_size, :num_ret, :done_flag,
:emp_name, :job, :salary);
END;
END-EXEC;

print_rows(num_ret);

if (done_flag)
break;
}

/* Disconnect from the database. */
EXEC SQL COMMIT WORK RELEASE;
exit(0);
}
void
print_rows(n)
int n;
{
int i;

if (n == 0)
{
printf("No rows retrieved.\n");
return;
}

for (i = 0; i < n; i++)
printf("%10.10s%10.10s%6.2f\n",
emp_name[i], job[i], salary[i]);
}

/* Handle errors. Exit on any error. */
void
sql_error()
{
char msg[512];
int buf_len, msg_len;


EXEC SQL WHENEVER SQLERROR CONTINUE;

buf_len = sizeof(msg);
sqlglm(msg, &buf_len, &msg_len);

printf("\nORACLE error detected:");
printf("\n%.*s \n", msg_len, msg);

EXEC SQL ROLLBACK WORK RELEASE;
exit(1);
}

68 comments :

Unknown said...

understandable code,thanks for giving this.
Oracle Training in Chennai

Unknown said...

Oracle is a relational database management system produced by oracle corporation. Nowadays most of the multinational companies used this oracle database for storing and managing their data's and programs. So learning Oracle Training is one of the best idea to make a bright career.

Unknown said...

Nice post. PHP is one of the server side scripting language mainly used for designing website. So learning PHP Training in Chennai is really useful to make a better career.
Regards..
Html5 Training in Chennai

Unknown said...

Nice information. Android is one of the most popular mobile operating system developed by Google. Learning Android Training Chennai is useful to make a wonderful future in mobile application development field.

Unknown said...

Nice information. Salesforce is a most powerful CRM tool used for manage all customers including potential customers. Salesforce Training in Chennai offering this course with experienced professionals.

Anonymous said...

Really nice post. Unix is a multiuser and multi tasking operating system at the same time. Unix Training in Chennai offering real time Unix course at reasonable cost.

Unknown said...

Pretty article! I found some useful information in your blog, it was awesome to read, thanks for sharing this great content to my vision, keep sharing.
Regards,
Oracle DBA Training in Chennai|Oracle Training Institute in Chennai|Best Oracle Training Institute in Chennai

Unknown said...

We are some sort of fond of image designing along with always keep seeking the revolutionary tips concerning this. thank you regarding discussing concerning this theme. Hold discussing.Buzz For Android

Nandhini said...

The strategy you have posted on the oracle hepled me to get into the next level of this technology and had lot of informations in it.
oracle training in chennai | oracle training institutes in chennai

Luckperson said...

Hi, I am initial learn of sql query. Your post is informative for me. Keep updating.
Oracle courses | DBA course

for ict 99 said...

great

Unknown said...

Thank you a lot for providing individuals with a very spectacular possibility to read critical reviews from this site.
Hadoop Training Institute In chennai

Unknown said...

Well done! Pleasant post! This truly helps me to discover the solutions for my inquiry. Trusting, that you will keep posting articles having heaps of valuable data. You're the best! 


python training in omr

python training in annanagar | python training in chennai

python training in marathahalli | python training in btm layout

python training in rajaji nagar | python training in jayanagar

simbu said...

This is a terrific article, and that I would really like additional info if you have got any. I’m fascinated with this subject and your post has been one among the simplest I actually have read.

java training in omr

java training in annanagar | java training in chennai

java training in marathahalli | java training in btm layout

java training in rajaji nagar | java training in jayanagar

Unknown said...

Thanks for the good words! Really appreciated. Great post. I’ve been commenting a lot on a few blogs recently, but I hadn’t thought about my approach until you brought it up. 
Data Science training in chennai
Data science training in velachery
Data science training in tambaram
Data Science training in OMR
Data Science training in anna nagar
Data Science training in chennai
Data science training in Bangalore

Unknown said...

Nice post. By reading your blog, i get inspired and this provides some useful information. Thank you for posting this exclusive post for our vision. 


rpa training in Chennai

rpa training in pune

rpa online training

rpa training in bangalore

rpa training in Chennai

rpa training in Chennai

rpa training in velachery

rpa training in tambaram

sai said...

I found this informative and interesting blog so i think so its very useful and knowledge able.I would like to thank you for the efforts you have made in writing this article.
python training in rajajinagar
Python training in btm
Python training in usa

Unknown said...

Great post! I am actually getting ready to across this information, It’s very helpful for this blog.Also great with all of the valuable information you have Keep up the good work you are doing well.
DevOps online Training

prabha said...

This is good site and nice point of view.I learnt lots of useful information.

angularjs Training in chennai
angularjs Training in chennai

angularjs-Training in tambaram

angularjs-Training in sholinganallur

angularjs-Training in velachery

angularjs Training in chennai
angularjs Training in chennai

angularjs-Training in tambaram

angularjs-Training in sholinganallur

angularjs-Training in velachery

shethal said...

At this time, it seems like Word Press is the preferred blogging platform available right now. (from what I’ve read) Is that what you’re using on your blog? Great post, however, I was wondering if you could write a little more on this subject?
Best AWS Training in Marathahalli | AWS Training in Marathahalli
Amazon Web Services Training in Anna Nagar, Chennai |Best AWS Training in Anna Nagar, Chennai

Unknown said...


Howdy, would you mind letting me know which web host you’re utilizing? I’ve loaded your blog in 3 completely different web browsers, and I must say this blog loads a lot quicker than most. Can you suggest a good internet hosting provider at a reasonable price?
Amazon Web Services Training in OMR , Chennai | Best AWS Training in OMR,Chennai
Amazon Web Services Training in Tambaram, Chennai|Best AWS Training in Tambaram, Chennai

ajay prakash said...

Very nice blog, Thank you for providing good information.
Aviation Academy in Chennai
Air hostess training in Chennai
Airport management courses in Chennai
Ground staff training in Chennai
aviation training in chennai
cabin crew training institute in chennai
airlines training chennai
airport ground staff training in chennai

anusha said...


Full Stack Development Training in Chennai Searching for Full Stack Development training in chennai ? Bita Academy is the No 1 Training Institute in Chennai. Call for more details.

William Damian said...

Thankfulness to my dad who informed me relating to this blog, this website is really amazing.
www.telephonecodes.org

rose said...

Your good knowledge and kindness in playing with all the pieces were very useful. I don’t know what I would have done if I had not encountered such a step like this.

Microsoft Azure online training
Selenium online training
Java online training
Java Script online training
Share Point online training


sasitamil said...

This is an awesome post.Really very informative and creative contents. These concept is a good way to enhance the knowledge.I like it and help me to development very well.Thank you for this brief explanation and very nice information.Well, got a good knowledge.
angularjs online training

apache spark online training

informatica mdm online training

devops online training

aws online training

kiruthika said...

Thank you so much for providing information on this. It was very useful.
Aviation Courses in Chennai
air hostess course in Chennai
airport courses in Chennai
Ground staff training in Chennai
Aviation Academy in Chennai
air hostess training in Chennai
airport management courses in Chennai
ground staff training in Chennai

Eleanor Eiland said...

Thankfulness to my dad who informed me relating to this blog, this website is really amazing.
www.telephonecodes.org

Thomson said...

I'd like to take the power of thanking you for that specialized guidance I've constantly enjoyed viewing your blog.
www.telephonecodes.org

Vale Co Xenia said...

Great Article
B.Tech Final Year Projects for CSE in Angular


Angular Training in Chennai


Project Centers in Chennai


JavaScript Training in Chennai

vijay said...

I am really happy with your blog because your article is very unique and powerful for new reader.

aws Training in Bangalore
python Training in Bangalore
hadoop Training in Bangalore
angular js Training in Bangalore
bigdata analytics Training in Bangalore
python Training in Bangalore
aws Training in Bangalore

vijay said...

I am really happy with your blog because your article is very unique and powerful for new reader.

aws Training in Bangalore
python Training in Bangalore
hadoop Training in Bangalore
angular js Training in Bangalore
bigdata analytics Training in Bangalore
python Training in Bangalore
aws Training in Bangalore

vijay said...

I am really happy with your blog because your article is very unique and powerful for new reader.

aws Training in Bangalore
python Training in Bangalore
hadoop Training in Bangalore
angular js Training in Bangalore
bigdata analytics Training in Bangalore
python Training in Bangalore
aws Training in Bangalore

sasi said...

Superb! Your blog is incredible. I am delighted with it. Thanks for sharing with me more information.
Hadoop Training in Chennai
Hadoop Training in Bangalore
Big Data Course in Coimbatore
Big data training in chennai
bigdata and hadoop training in coimbatore
Hadoop Training in Coimbatore
DOT NET Training in Chennai
Python Training in Bangalore

sindhuvarun said...

Thanks for taking time to share this useful blog...
spoken english classes in bangalore
Spoken English Classes in Chennai
spoken english class in coimbatore
spoken english class in madurai
DOT NET Training in Bangalore
PHP Training in bangalore
aws training in bangalore
Data Science Courses in Bangalore
spoken english classes near marathahalli
spoken english marathahalli

dras said...

very nice information..
inplant training in chennai
inplant training in chennai
inplant training in chennai for it.php
Australia hosting
mexico web hosting
moldova web hosting
albania web hosting
andorra hosting
australia web hosting
denmark web hosting

Reshma said...


Thanks for this wonderful blog it is really informative to all.keep update more information about this
Software Testing Training in Chennai
Software Testing Training in Bangalore
Software Testing Course in Coimbatore
Software Testing Training in Madurai
Software Testing Training Institute in Bangalore
Software Testing Course in Bangalore
Testing Course in Bangalore
Ethical hacking course in bangalore

raju said...

very nice blogger.......................!!!
inplant training in chennai
inplant training in chennai for it
panama web hosting
syria hosting
services hosting
afghanistan shared web hosting
andorra web hosting
belarus web hosting
brunei darussalam hosting
inplant training in chennai

ammu said...

nice information....!
inplant training in chennai
inplant training in chennai
inplant training in chennai for it
brunei darussalam web hosting
costa rica web hosting
costa rica web hosting
hong kong web hosting
jordan web hosting
turkey web hosting
gibraltar web hosting

preethi minion said...

very nice.....!
inplant training in chennai
inplant training in chennai
inplant training in chennai for it
italy web hosting
afghanistan hosting
angola hosting
afghanistan web hosting
bahrain web hosting
belize web hosting
india shared web hosting

kani said...

nice..
inplant training in chennai
inplant training in chennai
inplant training in chennai for it
hosting
india hosting
india web hosting
iran web hosting
technology 11 great image sites like imgur hosting
final year project dotnet server hacking what is web hosting
macao web hosting

sugan said...

very nice...and useful
r programming training in chennai
internship in bangalore for ece students
inplant training for mechanical engineering students
summer internships in hyderabad for cse students 2019
final year project ideas for information technology
bba internship certificate
internship in bangalore for ece
internship for cse students in hyderabad
summer training for ece students after second year
robotics courses in chennai


shri said...

very nice.....
internship in chennai for ece students
internships in chennai for cse students 2019
Inplant training in chennai
internship for eee students
free internship in chennai
eee internship in chennai
internship for ece students in chennai
inplant training in bangalore for cse
inplant training in bangalore
ccna training in chennai


shree said...

very nice....
inplant training in chennai for it
namibia web hosting
norway web hosting
rwanda web hosting
spain hosting
turkey web hosting
venezuela hosting
vietnam shared web hosting

rajan said...

inplant training in chennai
inplant training in chennai
inplant training in chennai for it.php
chile web hosting
colombia web hosting
croatia web hosting
cyprus web hosting
bahrain web hosting
india web hosting
iran web hosting

rajan said...

inplant training in chennai
inplant training in chennai
inplant training in chennai for it.php
chile web hosting
colombia web hosting
croatia web hosting
cyprus web hosting
bahrain web hosting
india web hosting
iran web hosting

shiv said...

nice...................
inplant training in chennai
inplant training in chennai
inplant training in chennai for it
algeeria hosting
angola hostig
shared hosting
bangladesh hosting
botswana hosting
central african republi hosting
shared hosting

Muthu said...

Very Nice...
internship in chennai for ece students with stipend
internship for mechanical engineering students in chennai
inplant training in chennai
free internship in pune for computer engineering students
internship in chennai for mca
iot internships
internships for cse students in
implant training in chennai
internship for aeronautical engineering students in bangalore
inplant training certificate


hari said...

nice........
inplant training in chennai
inplant training in chennai
online python internship
online web design
online machine learning internship
online internet of things internship
online cloud computing internship
online Robotics
online penetration testing

Muthu said...

Very Nice...
internship in chennai for ece students with stipend
internship for mechanical engineering students in chennai
inplant training in chennai
free internship in pune for computer engineering students
internship in chennai for mca
iot internships
internships for cse students in
implant training in chennai
internship for aeronautical engineering students in bangalore
inplant training certificate


shri said...

very good post...!
internship in chennai for ece students
internships in chennai for cse students 2019
Inplant training in chennai
internship for eee students
free internship in chennai
eee internship in chennai
internship for ece students in chennai
inplant training in bangalore for cse
inplant training in bangalore
ccna training in chennai


sugan said...

very nice post thanks blog.........
r programming training in chennai
internship in bangalore for ece students
inplant training for mechanical engineering students
summer internships in hyderabad for cse students 2019
final year project ideas for information technology
bba internship certificate
internship in bangalore for ece
internship for cse students in hyderabad
summer training for ece students after second year
robotics courses in chennai


sibiselvan said...

it is excellent blogs...!!
inplant training for diploma students
mechanical internship in chennai
civil engineering internship in chennai
internship for b.arch students in chennai
internship for ece students in core companies in chennai
internship in chandigarh for ece
industrial training report for computer science engineering on python
internship for automobile engineering students in chennai
big data training in chennai
ethical hacking internship in chennai

Durai Moorthy said...

Really it was an awesome article… very interesting to read…Thanks for sharing.........
aws Training in Bangalore
python Training in Bangalore
hadoop Training in Bangalore
angular js Training in Bangalore
bigdata analytics Training in Bangalore
python Training in Bangalore
aws Training in Bangalore

Durai Moorthy said...

Really it was an awesome article… very interesting to read…Thanks for sharing.........
aws Training in Bangalore
python Training in Bangalore
hadoop Training in Bangalore
angular js Training in Bangalore
bigdata analytics Training in Bangalore
python Training in Bangalore
aws Training in Bangalore

Durai Moorthy said...

Really it was an awesome article… very interesting to read…Thanks for sharing.........
aws Training in Bangalore
python Training in Bangalore
hadoop Training in Bangalore
angular js Training in Bangalore
bigdata analytics Training in Bangalore
python Training in Bangalore
aws Training in Bangalore

anuarun said...

nice information......
ree internship in bangalore for computer science students
internship for aeronautical engineering
internship for eee students in hyderabad
internship in pune for computer engineering students 2018
kaashiv infotech internship fees
industrial training certificate format for mechanical engineering students
internship report on machine learning with python
internship for biomedical engineering students in chennai
internships in bangalore for cse
internship in coimbatore for ece

raju said...

very nice blogger thanks for sharing......!!!
poland web hosting
russian federation web hosting
slovakia web hosting
spain web hosting
suriname
syria web hosting
united kingdom
united kingdom shared web hosting
zambia web hosting

ammu said...

excellent information.....!!!
chile web hosting
colombia web hosting
croatia web hosting
cyprus web hosting
bahrain web hosting
india web hosting
iran web hosting
kazakhstan web hosting
korea web hosting
moldova web hosting

ammu said...

very good information....!!!
text animation css
animation css background
sliding menu
hover css
css text animation
css loaders
dropdown menu
buttons with css

kani said...

nice...
slovakia web hosting
timor lestes hosting
egypt hosting
egypt web hosting
ghana hosting
iceland hosting
italy shared web hosting
jamaica web hosting
kenya hosting
kuwait web hosting

hari said...

very good.....
internship in bangalore for cse students
internship for aerospace engineering students in india
core companies in coimbatore for ece internship
paid internship in pune for computer engineering students
automobile internship in chennai
internship in chennai for eee with stipend
internship for bca students
dotnet training in chennai
aeronautical engineering internship
inplant training for ece students

sasi said...

The blog you shared is very good. I expect more information from you like this blog. Thankyou.
Artificial Intelligence Course in Chennai
ai courses in chennai
artificial intelligence training in chennai
ai classes in chennai
best artificial intelligence training in chennai
Hadoop Training in Bangalore
salesforce training in bangalore
Python Training in Bangalore

reena said...

nice.....it is use full...
aeronautical internship in india
free internship in chennai for mechanical engineering student
architectural firms in chennai for internship
internship in coimbatore for eee
online internships for cse students
mechanical internship certificate
inplant training report
internships in hyderabad for cse
internship for mba students in chennai
internship in trichy for cse

shalini said...


good.....
kaashiv infotech pune
industrial training report for electronics and communication
internships for cse
internship for automobile engineering students in bangalore
internships in bangalore for eee students
internship for civil engineering students in chennai 2019
internship in automobile companies in chennai
robotics chennai
final year projects for information technology

Praisy Margret said...

good..nice..
internships in bangalore for ece students 2019
internship for aeronautical engineering students in bangalore
kaashiv infotech chennai
internship for ece students in bangalore 2018
internship in chennai for eee with stipend
internship in chennai for mechanical engineering students
kaashiv infotech hyderabad
kaashiv infotech internship
internship in chennai for cse 2019
internship in aeronautical engineering

Rajesh Anbu said...

Nice Post...I have learn some new information.thanks for sharing.
aws Training in Bangalore
python Training in Bangalore
hadoop Training in Bangalore
angular js Training in Bangalore
bigdata analytics Training in Bangalore
python Training in Bangalore
aws Training in Bangalore

sushmi reddy said...

Hey Nice Blog!! Thanks For Sharing!!!Wonderful blog & good post.Its really helpful for me, waiting for a more new post. Keep Blogging!
Oracle Training | Online Course | Certification in chennai | Oracle Training | Online Course | Certification in bangalore | Oracle Training | Online Course | Certification in hyderabad | Oracle Training | Online Course | Certification in pune | Oracle Training | Online Course | Certification in coimbatore

Post a Comment