473,385 Members | 1,944 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

alias name inside the function

i am writing a function to return a table in the select query i am using a join and for some columns i want to give alias name but alias name given within" " is not accepting pls give me some suggestions as soon as possible


select a.answer as "choice",a.answerno as "choiceno",q.questionid,q.answer as "answerno",
q.solution,s.question from answer a , question q, qpselection s where (q.questionid=a.questionid )
and (s.questionid =a.questionid ) and s.qpid =$1

this is the query i tryed to run within the function
Jul 26 '07 #1
2 2789
i am writing a function to return a table in the select query i am using a join and for some columns i want to give alias name but alias name given within" " is not accepting pls give me some suggestions as soon as possible


select a.answer as "choice",a.answerno as "choiceno",q.questionid,q.answer as "answerno",
q.solution,s.question from answer a , question q, qpselection s where (q.questionid=a.questionid )
and (s.questionid =a.questionid ) and s.qpid =$1

this is the query i tryed to run within the function

i got it......

we have to specify the alias name while creating type

for eg:
CREATE TYPE fret AS(choice character varying(5000), choiceno integer, questionid integer,answer integer,solution character varying(5000),question character varying(5000));

and if we write the above select query inside a function the result be shown in the given alias name
Jul 31 '07 #2
michaelb
534 Expert 512MB
kirthikasubramanian,
please read the Posting Guidelines at the top of the forum and remember to use the CODE tags in your future postings.

As for your question, I don't quite understand what column aliases inside a function have to do with defining a new type. Very often functions do not involve any custom types at all.

You are correct that column aliases provided inside the function are not visible when you call it. Considering the function return type (SETOF, I suppose) and how this function is typically called this comes as no surprise.

You can however provide the aliases when you call the function.
I would generally consider it a bad practice, but just for the sake of argument you can do something like this:

Expand|Select|Wrap|Line Numbers
  1. select fld1 as "FIELD ONE", fld2 as "FIELD TWO"  from my_function(); 
  2.  
Aug 2 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

14
by: John | last post by:
Hi all, I am doing the change from having worked in Oracle for a long time to MS SQL server and am frustrated with a couple of simple SQL stmt's. Or at least they have always been easy. The...
5
by: Santiago Ordax Solivellas | last post by:
Hi. We have almost all our tables defined on library lib1 and some on lib2. We have alias defined on lib1 to access tables on lib2 so there is no need to qualify library name. Alias for tables on...
0
by: phdfromic | last post by:
After a SQL 'select .... from tablename alias' the mysql_fetch_field function returns a value $result=>table which will contain the alias, not the actual table name. Is there a way to get the...
6
by: Maxim | last post by:
Hello, everybody! I'd like to make global type alias. If I used c++ I would write the following code to create a global type alias: typedef SomeType MyAlias; I've found that using keyword...
3
by: petermichaux | last post by:
Hi, Is there a way to make one property an alias for another? This would mean that if the value of the original is changed then so is the value of the alias. I tried the following example and it...
9
by: lnatz | last post by:
Hi, I am writing a shell for a class and I have to write some builtins such as alias and cd. I am having some trouble with alias. I anyone could give me some ideas about how to do it I would...
6
by: Maguila007 | last post by:
Hi Is there any way to obtain the name of the function, inside the function which was called. Ex: function something() { alert( "The name of the function you invoke is " ......should
3
by: Jake G | last post by:
Hi, I have elements my page with an "alias" in them e.g. <input type=hidden id="S_SELLOG" name="S_SELLOG" iegAlias="S_SELLOG01" maxlength=1 title="Login/Logout" style="top:0; left:0;"> I am...
1
by: dwasler | last post by:
Try every thing I know to remove this alias I know there been other posting I read each one none seem to work. Thank You DLWasler dwasler@yahoo.com OS Window db2 V 8.2.X
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.