PRO*C [message #305348] |
Mon, 10 March 2008 08:54 |
user71408
Messages: 585 Registered: November 2007 Location: NE
|
Senior Member |
|
|
Hi All,
I have 2 sql queries as follows. using those two queries I want to write a PRO*C program. I am new to PRO*C. So can you please help me to write this Program
queries
delete
from detail d1
where d1.c_change in (select h.c_change
from support isc,
detail cpd,
head h
where h.actdate = to_date('12-dec-2008 00:00:00','DD-MON-YYYY HH24:MI:SS')
and h.c_change = d.cost_change
and cpd.item = isc.item
and cpd.supplier = isc.supplier
and cpd.country = isc.id
and cpd.cost = isc.cost)
delete
from head h
where h.act = to_date('12-dec-2008 00:00:00','DD-MON-YYYY HH24:MI:SS')
and not exists (select 1
from detail cpd
where cpd.cost_change = h.cost_change)
Please tell me how to write pro*c program for this...
Thank you.
|
|
|
Re: PRO*C [message #305349 is a reply to message #305348] |
Mon, 10 March 2008 08:57 |
ThomasG
Messages: 3212 Registered: April 2005 Location: Heilbronn, Germany
|
Senior Member |
|
|
Hi all,
I have just purchased a parachute from ebay. I'm about to jump now. Any last minute advice I should be aware off?
Thank you.
Hint : Take some sort of course before jumping, or at least read a tutorial and then come back when you have a specific question.
|
|
|
Re: PRO*C [message #305350 is a reply to message #305349] |
Mon, 10 March 2008 08:59 |
user71408
Messages: 585 Registered: November 2007 Location: NE
|
Senior Member |
|
|
Hi am in learning stage...
Please help me... I have tried these two queries in ORACLE.Now I want ot put these two queries in PRO*C. That's why I need your help..
Thank you...
|
|
|
|
|
Re: PRO*C [message #305358 is a reply to message #305356] |
Mon, 10 March 2008 09:14 |
Frank Naude
Messages: 4587 Registered: April 1998
|
Senior Member |
|
|
EXEC SQL DELETE FROM head h
WHERE h.act = to_date('12-dec-2008 00:00:00','DD-MON-YYYY HH24:MI:SS')
AND not exists (select 1
from detail cpd
where cpd.cost_change = h.cost_change);
|
|
|
Re: PRO*C [message #305362 is a reply to message #305358] |
Mon, 10 March 2008 09:22 |
user71408
Messages: 585 Registered: November 2007 Location: NE
|
Senior Member |
|
|
Hi if u don't mind I have already written the program as follows as u mentioned....
for those 2 queries i wrote
#include <stdio.h>
#include <sqlca.h>
void main()
EXEC SQL < 1st queries>
exec sql <2nd query>
in this in 1st query I have 2 pass two parameters. If parameter="COST" first query will be execute..
if parameter=" gil" then
2nd query will be execute
here I am getting the problem.. How to pass paramaeters...
|
|
|
|
|
Re: PRO*C [message #305520 is a reply to message #305367] |
Tue, 11 March 2008 03:01 |
user71408
Messages: 585 Registered: November 2007 Location: NE
|
Senior Member |
|
|
Hi ,
please give me one more idea for this issue..
I have select statement like
select A.ename,A.job,A.sal from EMP A where A.EMPNO in
(select B.empno from emp B,emp A where B.hiredate=to_date('1-jun-83','dd-mon-yy')
and a.ename=b.ename
and a.deptno=b.deptno)
How to define it in PRO*C.
I define it as
EXEC SQL < select statement>.
But I need to define bind variables for all the columns . Please help me how to define parameters for this and how to start the program..
Thank you
|
|
|
|
Re: PRO*C [message #305548 is a reply to message #305530] |
Tue, 11 March 2008 04:29 |
user71408
Messages: 585 Registered: November 2007 Location: NE
|
Senior Member |
|
|
Michel,
I wrote the code as follows .But I am not getting.. Pls observe it and give me the solution for this..
#include <stdio.h>
#include <sqlca.h>
void sqlerror();
EXEC SQL BEGIN DECLARE SECTION;
char *connstr = "scott/tiger";
EXEC SQL END DECLARE SECTION;
void main() {
EXEC SQL WHENEVER SQLERROR DO sqlerror();
EXEC SQL WHENEVER SQLWARNING CONTINUE;
EXEC SQL CONNECT :connstr;
EXEC SQL WHENEVER NOTFOUND GOTO notfound;
EXEC SQL select A.ename,A.job,A.sal from EMP A where A.EMPNO in
(select B.empno from emp B,emp A where B.hiredate=to_date('1-jun-83','dd-mon-yy')
and a.ename=b.ename
and a.deptno=b.deptno)
notfound:
printf("Employee record not found in database.\n");
return;
}
void sqlerror() {
printf("Stop Error:\t%25i\n", sqlca.sqlcode);
return;
}
Thank you
|
|
|
Re: PRO*C [message #305607 is a reply to message #305548] |
Tue, 11 March 2008 06:23 |
user71408
Messages: 585 Registered: November 2007 Location: NE
|
Senior Member |
|
|
Hi when I am executing the following code..
#include <stdio.h>
EXEC SQL BEGIN DECLARE SECTION;
char *connstr = "scott/tiger";
EXEC SQL END DECLARE SECTION;
void main()
{
EXEC SQL CONNECT :connstr;
EXEC SQL select A.ename,A.job,A.sal from EMP A where A.EMPNO in
(select B.empno from emp B,emp A where B.hiredate=to_date('1-jun-83','dd-mon-yy')
and a.ename=b.ename
and a.deptno=b.deptno);
}
I am getting the following error
i.e
ERROR IS
sample.pc[2]: EXEC: not found.
sample.pc[3]: char: not found.
sample.pc[4]: EXEC: not found.
sample.pc[6]: 0403-057 Syntax error at line 6 : `(' is not expected.
please give me solution...
|
|
|
|
Re: PRO*C [message #305684 is a reply to message #305646] |
Tue, 11 March 2008 09:41 |
user71408
Messages: 585 Registered: November 2007 Location: NE
|
Senior Member |
|
|
Michel,
when I am running the script
"$sample.pc"
I am getting error as above mentioned.
Thank you.
|
|
|
|
Re: PRO*C [message #305694 is a reply to message #305686] |
Tue, 11 March 2008 10:10 |
user71408
Messages: 585 Registered: November 2007 Location: NE
|
Senior Member |
|
|
Hi,
before compiling it I execute the following
$proc sample.pc
Then I got "sample.c" and "sample.lis"
after that i execute
"$sample.pc" Then I am etting the mentioned errors.
Please give me ideas if any modifications needed..or
please give me sample code for the above mentioned script..
Thank you
|
|
|
|
Re: PRO*C [message #305697 is a reply to message #305695] |
Tue, 11 March 2008 10:26 |
user71408
Messages: 585 Registered: November 2007 Location: NE
|
Senior Member |
|
|
Hi Marcs,
where we'll find ".o" file. I got only .lis,.pc,.c files only.
Please tell me where i had mistake....
Thank u
|
|
|
|
|
|
Re: PRO*C [message #305828 is a reply to message #305819] |
Wed, 12 March 2008 02:44 |
user71408
Messages: 585 Registered: November 2007 Location: NE
|
Senior Member |
|
|
But I have already written the code right?Now i'll send u one code recently i have written. There i am getting only one error.
please correct it..
#include <stdio.h>
#include <sqlca.h>
void sqlerror();
EXEC SQL BEGIN DECLARE SECTION;
char *connstr = "scott/tiger";
int c_change;
EXEC SQL END DECLARE SECTION;
void main() {
EXEC SQL WHENEVER SQLERROR DO sqlerror();
EXEC SQL WHENEVER SQLWARNING CONTINUE;
EXEC SQL CONNECT :connstr;
EXEC SQL WHENEVER NOTFOUND GOTO notfound;
EXEC SQL SELECT cost_change
INTO c_change
FROM sup_head csh,sup_detail csd
WHERE csh.sup_head=csd.sup_detail;
found:
printf("%s is in department %i\n", c_change);
return;
notfound:
printf("costchange record not found in database.\n");
return;
}
void sqlerror() {
printf("Stop Error:\t%25i\n", sqlca.sqlcode);
return;
}
error:
ssk_sample.pc[4]: 0403-057 Syntax error at line 4 : `(' is not expected.
please correct it. Then I will try to solve ...
Thank you
|
|
|
|
Re: PRO*C [message #305836 is a reply to message #305833] |
Wed, 12 March 2008 03:02 |
user71408
Messages: 585 Registered: November 2007 Location: NE
|
Senior Member |
|
|
i got ssk_sample.c and ssk_sample.lis. then i run it at
$ssk_sample.pc
there I am getting the error.
I am doing this one in development side..
any more.. please ask me...
Thank u
[Updated on: Wed, 12 March 2008 03:02] Report message to a moderator
|
|
|