Skip to main content

Posts

Templates versus Inheritance

Programmers sometimes find it tricky to decide whether to use templates or inheritance. Here are some tips to help you make the decision. Use templates when you want to provide identical functionality for different types. For example, if you want to write a generic sorting algorithm that works on any type, use templates. If you want to create a container that can store any type, use templates. The key concept is that the templatized structure or algorithm treats all types the same. When you want to provide different behaviors for related types, use inheritance. For example, use inheritance if you want to provide two different, but similar, containers such as a queue and a priority queue. Inheritance gets quite useful when designing user interface components -- e.g. when your Application Window inherits from general Window (this type of relationship is called is-a relationship and it's one of the major uses of inheritance). Similarly for mathematical applications -- say, yo

what is DIAMOND problem in C++

Ex: Diamond Inheritance Problem in figure form. -------------A ----------> A is the Base Class containing init() ------------/-\ -----------/---\ ----------/-----\ ---------B------C -------> B and C are the derived from A so.. init() is also derived ----------\-----/ both classes -----------\---/ ------------\-/ -------------D-------------> D is derived from B and C (MULTIPLE INHERITANCE), so multiple init() method is also inherited. Here D get ambiguous state to access init() method...i.e init() from B? or init() from C? Sol :: We can resolve this diamond problem by two ways i.e. By using 1) By using :: (Scope resolution operator) w.r.t to the class name 2) By declaring the classes as Virtual Class.

why addition of pointer is not possible

why addition of pointer is not possible Pointer are actually a variable with 2bytes of memories and it stores the address of any another variable ..so value stored in pointer will be the address and not the value of that variable.. for example: suppose int a =5; int *p=&a; and address of a is 115 and tht of p is 225... now the above code states tht value of a = 5; value of p = 115;//address of a

What are benefit of function pointer?

There are many many uses of function pointers ranging from simple ones to complex scenarios. One example in C++ domain is implementation of virtual functions using vtable. vtable is one of the methods to implement virtual functions in C++. This uses function pointers. Other good example are the scenario where you dynamically load a shared library. Once the application loads the library, it calls the functions defined in that library using function pointers. many of the sort algorithms take function pointer as an argument and call that function pointer to perform the comparison between two entities. At an enterprise level, an Application which is a transaction monitor (i.e which support online transactions), communication with difference databases using a well known standard called XA interface. This communication happens using function pointers. Advantage here is that the application need not be aware of how various databases implement their commit or rollback functions.

SQL Injection Attack

SQL Injection Attack  It is a basically a trick to inject SQL command or query as a input mainly in the form of the POST or GET method in the web pages. Most of the websites takes parameter from the form and make SQL query to the database. For a example, in a product detail page of php, it basically takes a parameter product_id from a GET method and get the detail from database using SQL query. With SQL injection attack, a intruder can send a crafted SQL query from the URL of the product detail page and that could possibly do lots of damage to the database. And even in worse scenario, it could even drop the database table as well.e SQL injection is a technique often used to attack a website. This is done by including portions of SQL statements in a web form entry field .

What are the disadvantages of select() on unix

What are the disadvantages of select() on unix One traditional way to write network servers is to have the main server block on accept(), waiting for a connection. Once a connection comes in, the server fork()s, the child process handles the connection and the main server is able to service new incoming requests. With select(), instead of having a process for each request, there is usually only one process that "multi-plexes" all requests, servicing each request as much as it can. So one main advantage of using select() is that your server will only require a single process to handle all requests. Thus, your server will not need shared memory or synchronization primitives for different 'tasks' to communicate. One major disadvantage of using select(), is that your server cannot act like there's only one client, like with a fork()'ing solution. For example, with a fork()'ing solution, after the server fork()s, the child process works with the client

Books to improve English grammar and vocabulary

Books to improve English grammar and vocabulary GRAMMAR 1)COLLINS COBUILD ENGLISH GRAMMAR 2)HOW TO WRITE CORRECT ENGLISH BY R.P SINHA(BOTH IN HINDI AND ENGLISH) 3)ENGLISH GRAMMAR BY TONDON & TONDON 4)HIGH SCHOOL ENGLISH GRAMMAR AND COMPOSITION BY WREN ANS MARTIN 5) PRACTICAL ENGLISH GRAMMAR BY THOMSON AND MARTINET VOCABULARY 1)OXFORD ,WEBSTER,CHAMBERS,CAMBRIDGE AND LONGMAN(ANY ONE MAY BE CHOOSEN) 2)ALL ABOUT WORDS BY MAXWELL NURNBERG 3)WORD POWER MADE EASY BY NORMAN LEWIS 4)SIX WEEKS TO WORD POWER BY WILFED FUNK 5)30 DAYS TO A MORE POWER VOCABULARY BY WILFRED FUNK 6)BARRONS WORD LIST 7)READERS DIGEST

importance of certificate credentials

Importance of certificate credentials There are lots of competition in today’s IT field because of lots of colleges who produces a huge number of engineers. To stand somewhere students have to do some thing extra. Many of the students wants to do career courses in parallel to their studies or after their studies. Suddenly the bunch of question arises like which course to do, from where to do, how to do, who is trustful education provider, etc. Students don’t get in-depth knowledge in any area in their regular studies because they have huge course and they are more concerned to pass their exams. They are not much concerned to have in-depth knowledge in specific field. Companies can’t hire fresher’s for the process with out giving them training. But in the current situation when companies are cutting their cost, they are not hiring fresher’s in bulk. They only hire those students who are having extra specific knowledge.

Java Archive files

Java Archive files allow developers to package many classes into a single file. JAR files also use compression, so this can make applets and applications smaller. Creating a .JAR file is easy. Simple go to the directory your classes are stored in and type :- jar -cf myfile.jar *.class If your application or applet uses packages, then you'll need to do things a little differently. Suppose your classes were in the package mycode.games.Cool Game - you'd change to the directory above mycode and type the following :- jar -cf myfile.jar .\mycode\games\CoolGame\*.class Now, if you have an existing JAR file, and want to extract it, you'd type the following jar -xf myfile.jar Working with JAR files isn't that difficult, especially if you've used the UNIX 'tar' command before. If you're planning on packaging an applet for Internet Explorer, or an application for Microsoft's jview, you might also want to consider .CAB files.

Domain Name Extensions and Meanings

.com..........................commercial .edu..........................educationa l and research .gov..........................government .int............................internat ional organizations .mil...........................military agency .net..........................gateway or host .org.........................non-profit organization

Sharing printer between two PC

Sharing printer between two PC In the first PC where the printer is connected & installed. 1. In windows explorer - Go to Tools>Option>View. 2. Enable "use simple file sharing (recommended). 3. Go to Start>Settings>Printers & Faxes 4. Right click the Printer - click Sharing 5. Click Share this printer and Click List in Directory 7. Click Apply In the second PC where the printer to be installed. 1. Go to Start>Settings>Printers & Faxes 2. Click Add a Printer>Click Next 3. Click Network Printer.>Click Next 4. Click Find a Printer in the Directory>Click Next 5. Click Find now - you will see the Printer listed below 6. Select the Printer>Click OK Your printer will be now installed in the second PC. Do the appropriate settings.

Block usb port in windows 2000 server

  Block usb port in windows 2000 server 1. Run Registry Editor (regedit). 2. Navigate to the following registry key: HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\UsbStor 3. In the right pane, double click on the Start value name. 4. Change the value data to 4 to disable the removable USB mass storage device drive access. 5.To revert and re-enable the drive access for removable USB mass storage device driver, change back the value data for Start to its original default of 3.

how to use idea net setter in linux 10.0 desktop

how to use idea net setter in linux 10.0 desktop plug idea net setter in ubuntu create network connection on the bar set as idea create mobile brodband idea connection open cd rom idea net setter> goto Linux folder> extract file " Mobilepartner.tar.tg" on the desktop after extract files goto driver folder and Ndis driver a file-Ndis install double click on the file and run with terminal then back install file run with terminal then run these files 1.Start mobile partner 2.usb mode through terminol after that goto driver folder and run in terminal mobilepartner then restart your system and login again you enjoy with Idea Net Setter

Create table runtime using c sharp code

Create table runtime using c sharp code try { if (RadioButton1.Checked == true) { string first = TextBox1.Text.ToString(); string last = TextBox3.Text.ToString(); string user = TextBox4.Text.ToString(); string ps = TextBox6.Text.ToString(); string quest = DropDownList1.Text.ToString(); string answ = TextBox7.Text.ToString(); string source = "Data Source=.\\SQLEXPRESS;AttachDbFilename=|DataDirectory|\\dfd.mdf;Integrated Security=True; User Instance=True"; SqlConnection conn = new SqlConnection(source); conn.Open(); SqlCommand cmd = new SqlCommand("INSERT INTO users(fname, lname, uid, pswd, ques, ans) VALUES ('" + first + "', '" + last + "', '" + user + "', '" + ps + "', '" + quest + "', '" + answ + "')", conn); int i = cmd.ExecuteNonQuery(); String sql = "CREATE TABLE " + user + "" +"(Stu

Example of abstract and interface class using c sharp

Example of abstract and interface class using c sharp namespace abstractClassDemo { class Program { static void Main(string[] args) { Car mycar = new Car("Skoda", "Fabia2CX"); mycar.ModelName(); mycar.BodyColor(); mycar.CubicCapacity(); mycar.Mileage(); Console.ReadKey(); } } abstract class Vehicle { string _model = ""; string _type = ""; public Vehicle(string company,string type) { _model = company; _type = type; } public abstract void CubicCapacity(); public abstract void BodyColor(); public abstract void Mileage(); public void ModelName() { Console.WriteLine("Vehicle is " + _type + " and Company is " + _model); } } class Car: Vehicle { public Car(string companyName, string modelName) : base(companyName, modelName) { } public override void BodyColor() { Console.Write("Color is Red."); } pub

Data Decryption using C# Code

Data Decryption using C# Code public static byte[] Decryptor(string secrpcnm, string key) { byte[] b = Convert.FromBase64String(secrpcnm); TripleDES des = CreateDES(key); ICryptoTransform ct = des.CreateDecryptor(); byte[] output = ct.TransformFinalBlock(b, 0, b.Length); return Convert.FromBase64String(Encoding.Unicode.GetString(output)); } static TripleDES CreateDES(string key) { MD5 md5 = new MD5CryptoServiceProvider(); TripleDES des = new TripleDESCryptoServiceProvider(); des.Key=md5.ComputeHash(Encoding.Unicode.GetBytes(key)); des.IV = new byte[des.BlockSize / 8]; return des; } //And to call the functions on the click event of a button:: private void button4_Click(object sender, EventArgs e) { label6.Text = (EncrypCls.Decryptor(label5.Text, "sksdege")).ToString(); }

Re size image in ASP.NET while uploading an image

Re size image in ASP.NET while uploading an image public bool SaveThumbnailImage(System.Web.UI.WebControls.FileUpload fu, string FullSavePath, int HeightMax, int WidthMax) { try { if (fu.HasFile){string tmpSaveDir = pg.Server.MapPath("~/TempUploads/"); if (System.IO.Directory.Exists(tmpSaveDir) == false) { System.IO.Directory.CreateDirectory(tmpSaveDir); } string tmpSavePath = pg.Server.MapPath("~/TempUploads/" + fu.FileName); if (System.IO.File.Exists(tmpSavePath)) { try { System.IO.File.Delete(tmpSavePath); } catch { } } fu.SaveAs(tmpSavePath); System.Drawing.Image img = System.Drawing.Image.FromFile(tmpSavePath); double ratioWidth = (double)img.Width / (double)WidthMax; double ratioHeight = (double)img.Height / (double)HeightMax; double ratio = Math.Max(ratioHeight, ratioWidth); int newWidth = (int)(img.Width / ratio); int newHeight = (int)(img.Height / ratio); System.Drawing.Ima

Encapsulate some code module in the code behind file of c#

Add a new project to you solution as class library. You can find class library under C# windows section. Name it as per your convenience. after adding, you will get a class file, with the name of you supplied. make this class public. Now you can write you logic in this class file, build it. it will create a dll file. add reference by right clicking on you main application project file select "Add reference", path of dll file. in your application, add the namespace of your class file and then call class and its methods. below is a sample class file using System; using System.Data; namespace myEncapsulatedNameSpace { public class myEncapsulatedClass { //property declaration //properties are used for passing values between application layers private string _myName = string.empty; public string myName { get { return _myName; } set { _myName = value; } public string myMethod() { return myName = "sk";

How Tsunami occurs?

How Tsunami occurs? As one plate subducts below another, pressure builds after many years, resulting in a section of the megathrust giving away. As this section gives way. 1 ruptures the ocean floor, resulting in a massive displacement of water, causing a Tsunami. Tsunamis are barely fell as a ripple on the ocean surface, but as the wave reaches land, they increases in size as the water becomes shallower.    World’s worst Tsunamis In Chile, Japan and Russia on February27, 2011, thousands died after an 8.8-magnitude earthquake. Many who survived the quake were killed hours later by a massive tsunami. Waves of up to 1.5 meters [5feet] went on to hit far – flung Pacific regions from the Russian far east and Japan to New Zealand’s Chatham islands. The biggest Tsunami  occurred on July 9, 1958 in Lituya bay, Alaska by a magnitude of 8 earthquake causing massive landslides. Waves reached an unbelievable heights of 1,720 feet, killing more than 36,000 people. We shall pray to god for

Micro organisms

Micro-organisms There are some organisms around us which we cannot see through naked eyes. These organisms are called Micro-organisms.  There are five types of Micro-organisms bacteria, fungi, protozoa, algae and virus. Where do micro-organisms live? Micro-organisms can survive under all types of environment, ranging from ice cold climate to hot springs and deserts to marshy lands. They are also found inside the bodies of animals including humans. fungi   Fungi is a type of micro-organism. There are three types of fungi Bread mould, penicillium, aspergillus. Protozoa There are two types of protozoa Amoeba and paramecium. Diseases like dysentery and malaria are caused by protozoa.  Algae There are two types of algae chlamydomonas and spirogyra. Viruses Virus are microscopic. Diseases caused by viruses are cold, influenza, coughs, polio and chicken pox. 

install xp and windows 7 and run both os once

install xp and windows 7 and run both os once To do this task you should have a software called EasyBCD , you can download it from internet its a free software.After installing your XP into d : install this software then double click on that software add the windows 7 from c : then insert the dvd of win 7 and run start up repair Now you can run both win xp an win 7 at once.

Basic requirements of LAN creation

 Basic requirements of LAN creation 1)  computers  with NIC cards (On board or Add on). 2)  cables and RJ 45 connectors. 3) A Hub or Switch. (Switch is recommended). Connectivity between PC & Switch There are some other things which you have to do to connect PC.s in LAN. 1) Straight cable crimping. color codes are as below. Orange-white, Orange, Green-white, Blue, Blue-white, Green, Brown-white brown. 2).Give IP Address to all PC,s in a single network ID. i.e, 192.168.1.1, 192.168.1.2 etc & Sub net mask is same to all PC. i.e 255.255.255.0. 3) Give any Work group Name to all PC, But it should be same to all PC's. 4) Try to ping the IP with each Other & Then access PC.

Show Hidden files in pendrive on windows XP

Show Hidden files in pendrive on windows XP Open explorer or My computer. Click on Tools -> Folder Options. Now a dialog box opens, In that Click on 'View' tab. Now under advanced setting panel, you can see the following thing: -> Hidden files and folders. -> Don't show hidden files, folders.. -> Show hidden files, folders... Now select the option "Show hidden files,folders and click on OK. Now open your pen drive. Now you will be able to see all the hidden files and folders. If you still can't find anything then it means there are no hidden files in that location.

NTLDR is missing press any key to restart,Check for computer screen blue problem

NTLDR is missing press any key to restart Insert the Window XP Professional CD in the CD-ROM and first boot may be CD-ROM. When write ‘Press any key to boot from CD…’ press ‘Enter’. Than start Window XP Professional setup Window XP Professional Setup Welcome to the setup 1. To set up Window XP now, press ‘ENTER’. 2. To repair a Window XP installation using Recovery Console, press ‘R’. 3. To quit Setup without installing Window XP, press ‘F3’. Microsoft Windows XP(TM) Recovery Console. 1: C:\WINDOWS Which Windows installation would you like to log onto ? (Press ‘1’) Enter Type the Administrator password. (If any) C:\WINDOWS> At C:\WINDOWS> prompt type the following commands: 1. C:\WINDOWS>fixmbr Are you sure you want to write a new MBR? ‘Y’ Enter 2. C:\WINDOWS>fixboot Are you sure you want to write a new bootsector to the partition C:? ‘Y’ Enter 3. C:\WINDOWS>bootcfgΦ/rebuild Add installation to boot list? (Yes/No/All) ‘Y’ Enter Enter

How to format a partition into NTFS -Disk formatting

To format a partition into NTFS you can try below points. There can be two possibilities of bad sectors (1) Your "FAT" or "bootsector" has developed "bad sectors" and it has locked it .There fore it is not allowing system to write partition info it it.Please note that it does not matter for a computer wehter it is last or first.it writes data "randomly". (2) There would be some kinda lock to your in your hdd which is preenting write to it.In NTFS you can lock the parition. Go to Administration Tools and Click Computer Management and select disk management, now you will see the partitions in your system and delete the partition you dont want and create a new partion in free space area.Now format the partition in NTFS. if you'r not able to format that partiton into ntfs you can try converting that with the help of a command go command promt a type the command "convert d: /fs:ntfs" (here d:=drive letter you wana convert)

Disk error press any key to restart

Disk error press any key to restart To resolve this issue on PC you can try this There is some delay coming in to the picture called Hard Disk Pre-Initialization Time. In simple words Hard Disk and it's own BIOS is not capable to cope-up with your motherboard speed/ booting speed. It happens with fewer boards and Seagate Medalist Family disks combination. When you are resetting your system, your HDD is already in "Ready to Boot" state hence the error message is not seen. This is nothing special... there is no magic. I would suggest to rewrite your boot sector. If you have dual boot kind of Operating System then this kind of HDD pre-ini delay strongly comes in to the play. Check your motherboard BIOS/ CMOS settings. Try to see if you can introduce some kind of delay in the Booting Procedure. Something like Disabling Quick Booting, Enabling HDD Pre Delay, etc. It is also advisable to clean format and re-install the OS. Just do simple take the hard disk tool (or

Privilege Levels in processor and Virtual Memory

Privilege Levels in processor and Virtual Memory Privilege Levels: The processor has Ring Levels 0-3, 0 being most privileged, 3 being least privileged. All processes in user land, be it root or non-root, execute in Ring 3. (Ring 1,2 are unused in Linux) A process in Privilege level 3 cannot read/write/execute segments which belong to supervisor (the kernel). So a write to memory locations higher than PAGE_OFFSET (3GB on i386) causes segmentation fault. Same goes for hardware access through in/out or mapped i/o (exceptions are iopl etc). Virtual Memory: Virtual Memory ensures no access to physical RAM pages by processes. Hence you *cannot* under any circumstances write a physical address, Hence there is ZERO chance of even reading kernel data, let alone messing them up.

Where to find the source file of the header netdevice.h

Where to find the source file of the header netdevice.h "cscope" is a very simple to use command line tool. you will have to install it and then use it on the kernel source tree locally. (it will index) However, if you are comfortable with the web version, that's also fine. I find cscope a faster way, so suggested that to you. :) the mechanism hardly matters. Just as an e.g. (I used cscope) Look at the file: drivers/net/82596.c line: 1125 static const struct net_device_ops i596_netdev_ops = { .ndo_open = i596_open, .ndo_stop = i596_close, .ndo_start_xmit = i596_start_xmit, .ndo_set_multicast_list = set_multicast_list, .ndo_tx_timeout = i596_tx_timeout, .ndo_change_mtu = eth_change_mtu, .ndo_set_mac_address = eth_mac_addr, .ndo_validate_addr = eth_validate_addr, }; These are the driver routines for the particular device. Now search for these function definitions in the kernel source tree

how to handle file descriptor on linux and file handler on windows platform

Open files in Linux are represented by struct files_struct (process view) struct file (kernel view)(file descriptor).when a file is opened.links between file descriptor, inode,address pace etc are created(i.e struct file is filled properly ) This is the work of virtual file system.. if code from windows has to be accessed in Linux..(possible because..it support NTFS file system). actually the file system(The NTFS file system is converted into ext form by virtual file system) so it is possible in Linux to access window stuff. On the other hand windows does not support any other file system .so accessing Linux files on windows in not possible.(i mean without any external tool).

print the source and destination address using kernel-2.6.32.9

main() { int pack_socket,n; int len,datasize; char src_addr[20],dst_addr[20],*data; struct sockaddr_ll sa; socklen_t sl; struct iphdr *ip_hdr; char buf[2000]; struct in_addr addr; pack_socket = socket(PF_PACKET,SOCK_DGRAM,htons(ETH_P_ALL)); while(1){ sl = sizeof(struct sockaddr_ll); n = recvfrom(pack_socket,buf,2000,0,(struct sockaddr *)&sa,&sl); //check whether the packet is ip or not. if(ntohs(sa.sll_protocol) == 0x0800){ printf(" IP packet received \n"); ip_hdr = (struct iphdr *) buf; addr.s_addr = ntohl(ip_hdr->saddr); printf("\n Source Addr = %s", inet_ntoa(addr)); addr.s_addr = ntohl(ip_hdr->daddr); } } }

What is Virtual Memory and How it works?

What is Virtual Memory and How it works? Virtual Memory allows multi-user as well as multi-programming computing environment that too for very less RAM. RAM use to be very costly earlier compare to present day. CPU has PC register from where next instruction can be fetched or data can be load/store. Assuming PC being 32 bit register, it can address 4G locations. But practically we put very less RAM, say 128MB only. Assuming Virtual Memory exists, compiler generates code for an application, where compiler is also aware of OS+Architecture. Now code generated by compiler assumes entire 4G location (so large extent) is available for it and it is the only application running on the CPU. So PC register shall always issue address which is one among 4G locations. So this 4G which is in fact physical capacity of PC register of CPU, is used as Virtual Address, as actual RAM is much less (0-128MB only) Now OS uses a table call Page Table along with MMU unit of CPU. Using this it loa

What is WTK

Using WTK you can develop applications that will reside on mobile phone. That means the SMS/MMS application is for the mobile phone. What I want is to develop an application that will reside on the PC and should be able to send and receive MMS/SMS to the cellphones. I had used SMSLib earlier for sending and receiving SMS by connecting my cellphone as a GSM modem to my PC. The only problem with SMSLib is that it doesn't provide the capability to send MMS  and I am not sure if performance wise it is that good.

Example of trigger using procedure language

Example of trigger using procedure language CREATE OR REPLACE TRIGGER Trig_test AFTER INSERT ON EMP1 FOR EACH ROW DECLARE PRAGMA AUTONOMOUS_TRANSACTION; BEGIN test_T; -- Test_T is a Procedure commit; END Trig_test create or replace procedure test_T AS declare v_empno emp.EMPNO%type; cursor c1 is select empno from emp1 where empno is null; BEGIN open c1;loop fetch c1 into v_empno; exit when c1%notfound; update emp1 set empno = empno_seq.nextval where empno is null; end loop; close c1; Exception when others then null; end;

skip a record in a cursor and continue with the next record in oracle

To skip a record in a cursor and continue with the next record you can try below code in oracle or sql. declare cursor cur1 is select * from emp; rec cur1%rowtype; begin open cur1; loop fetch cur1 into rec; dbms_output.put_line(rec.ename||' '||rec.sal); fetch cur1 into rec; exit when cur1%notfound; end loop; close cur1; end;

Sql query to get second maximum salary of employee

Sql query to get second maximum salary of employee 1st Solution:- select min(sal) from emp e where 1 = (select count(*) from emp where e.sal<sal)  In this query duplicate values are not considered hence we may not get 3rd maximum salary because there are two employees with the same salary. to avoid the duplication strictly the query needs some changes 2nd  Solution  :- select min(sal) from emp e where 1 = (select count(distinct sal) from emp where e.sal<sal)  The following query displays the total repeating salaries . to get the complete details of the records just replace "sal" with "*" in the following query 3rd  Solution :- select sal from emp e where 1 = (select count(distinct sal) from emp where  e.sal<sal) This is example of select query to get top 3 maximum from table. select * from (select salaries from SalaryTrans order by salaries desc) where rownum <= 3; or select salary from (select distinct salary from SalaryTrans orde

Pl/Sql program to check for department of employee,Replace string with your column name

Replace string with your column name  Replace '2011-06-20T00:00-04:00' with your column name. SELECT SUBSTR('2011-06-20T00:00-04:00',1,INSTR('2011-06-20T00:00-04:00','T')-1)||' '||SUBSTR('2011-06-20T00:00-04:00',INSTR('2011-06-20T00:00-04:00','T')+1,LENGTH('2011-06-20T00:00-04:00')); Pl/Sql program to check for department of employee create or Replace Function valid_deptid (tmp_deptid departments.Department_id%type) Return Number IS Rtn_Deptno number; begin dbms_output.put_line('Inside Function'); select department_id into rtn_deptno from departments where department_id=tmp_deptid; if sql%FOUND then dbms_output.put_line('Valid Deptno'); end if ; return rtn_deptno; exception when no_data_found then dbms_output.put_line ( ' sorry incorrect departmentno' ) ; return -- it will return the null. it's a good programming pratice ---

call an oracle SQL script from EXCEL

 call an oracle SQL script from EXCEL For example, I'll execute SELECT query. Step 1: Learn name OLEDB provider of data for Oracle. If you established Oracle Client, this provider will be present. To learn a name of the provider, for example, create an empty file with extension *.udl (in Windows, certainly ). Then open its properties. On a page "Provider" you can see the list of providers. Step 2: Open VBA in Excel (Tools - Macro - Visual Basic Editors) and write this Script (Insert - New Module): Sub Macro1() ' Macro1 Macro Dim MyConn As ADODB.Connection Dim MyRst As ADODB.Recordset Dim MyPr As String Dim Ct As Long Set MyConn = New ADODB.Connection MyPr = "Provider=your_OLEDB_provider_name;Password=your_password;Persist Security Info=True;User ID=your_user;Data Source=your_Oracle_server_name" MyConn.Open MyPr Set MyRst = New ADODB.Recordset MyRst.Open "Select * from table_name", MyConn, adOpenStatic

Function and procedure with arguments out

A very simple difference between these two is A Procedure is used to perform an action! A function is used to compute something and then return it to the calling environment. The question is about the out argument. Both have certain usages: Like if you want that the returned value should be returned in an expression: a := b * tax(c); Tax must be a function with a value returning , you cannot use out parameter in such context, moreover when u want your function to return single value in your select statement you cannot use out parameter. On the other hand if you want to return multiple values the function returning value will not be sufficient because a function can return one and only one value.

Maximum parameters in a procedure in PERL

#!/usr/bin/perl open(FOO,">c:/prod_test.sql"); $create = "Create or replace procedure "; $body = "\nbegin\n null;\n"; $statement = $create."foo("; for ($x=0;$x<8188;$x++){ $statement .= "a$x in varchar2,\n "; } $statement .= "done in varchar2)\n as"; print FOO $statement.$body."end;"; close FOO; at 8187 parameters it compiled. at 8188 it gave a program to large error. its  tested body length by adding "null;" to the body 10,000 times and it didn't mind. One other thing is the 2499 character limit per line.

what is the difference between spfile or pfile

what is the difference between spfile or pfile An spfile and a pfile are both init parameter files. The pfile is a readable text file which you can edit directly in Notepad (Windows) or vi (Unix). The pfile's name is initSID.ora. The spfile is a binary file, which means it can't be edited directly (if you try to edit it directly, it'll corrupt the file). The spfile can only be modified by using the "alter system" command. The spfile's name is spfileSID.ora. The spfile is useful to have because it lets you dynamically make changes to some parameters, whereas the pfile does not - you will need to shutdown and start up the instance for any changes you make in the pfile to be applied.

finding null values columns in the table using sql

finding null values columns in the table using sql  declare L_STMT VARCHAR2(32767) := 'SELECT COUNT(1) FROM #1 WHERE #2 IS NULL'; NULL_CNT NUMBER; TBL_NAME VARCHAR2(30) := 'XYZ'; begin FOR I IN (SELECT COLUMN_NAME FROM USER_TABLES WHERE TABLE_NAME = TBL_NAME ORDER BY COLUMN_ID) LOOP L_STMT := REPLACE(L_STMT, '#1',TBL_NAME); L_STMT := REPLACE(L_STMT,'#2',I.COLUMN_NAME); EXECUTE IMMEDIATE L_STMT INTO NULL_CNT; DBMS_OUTPUT.PUT_LINE ('COLUMN OF ' || TBL_NAME ||' : ' ||' NULL COUNT FOR COLUMN '|| I.COLUMN_NAME ||' IS : ' || NULL_CNT; END LOOP; end;