declare

Declare row type variable in PL/pgSQL

旧时模样 提交于 2019-11-29 11:34:59
问题 As I found SELECT * FROM t INTO my_data; works only if: DO $$ DECLARE my_data t%ROWTYPE; BEGIN SELECT * FROM t INTO my_data WHERE id = ?; END $$; Am I right? If I want to get only 2-3 columns instead of all columns. How can I define my_data ? That is, DO $$ DECLARE my_data <WHAT HERE??>; BEGIN SELECT id,name,surname FROM t INTO my_data WHERE id = ?; END $$; 回答1: get only 2-3 columns instead of all columns One way: use a record variable: DO $$ DECLARE _rec record; BEGIN SELECT INTO _rec id,

C90: How do I globally initialize this struct in C without C99 extensions

ぐ巨炮叔叔 提交于 2019-11-29 10:24:26
问题 I was wondering what the best way to initialize this struct is with C90, while still keeping it neat. In my header file, call it test.h, I have the following struct defined: struct s_test_cfg{ char *a[3]; char *b[3]; char *c[3]; } Then I have it declared as an extern struct so that I can initialize it globally in the .c file: extern struct s_test_cfg test_cfg; Now in my .c file, I want to be able to declare something like this globally (obviously what I'm about to write is unsupported in C90)

Can I declare the same variable twice in different for loops in JavaScript? [duplicate]

偶尔善良 提交于 2019-11-29 09:04:38
Possible Duplicate: JavaScript Variable Scope I have a JavaScript function for HTML select options for days: // Show and hide days according to the selected year and month. function show_and_hide_days(fp_form) { var select_year= $(fp_form).find("select.value_year"); var select_month= $(fp_form).find("select.value_month"); var select_day= $(fp_form).find("select.value_day"); var selected_year= $.parse_int($(select_year).val()); var selected_month= $.parse_int($(select_month).val()); var selected_day= $.parse_int($(select_day).val()); var days_in_month= new Date(selected_year, selected_month, 0)

Using variables in Classic ASP parameterized SQL

喜你入骨 提交于 2019-11-29 08:21:35
I'm transitioning from dynamically generated (albeit heavily sanitized) SQL queries, to parameterized SQL, and I'm running into some trouble with the variable names. I'm using Classic ASP, coded in jScript. The code below takes a rating value (1-5) and puts it in the database. First it deletes all of the user's prior ratings for that object, and then writes the new rating into the database. The function has already received and I've parsed the Rating variable (a TinyInt). The UserID and PgID values, both integer, have also been sent. I've already gotten this working by replacing @UserID, @PgID

DllImport vs Declare in VB.NET

末鹿安然 提交于 2019-11-28 20:40:51
I notice in the MSDN documentation that there are multiple ways to declare a reference to a function in an external DLL from within a VB.NET program. The confusing thing is that MSDN claims that you can only use the DllImportAttribute class with Shared Function prototypes " in rare cases ", but I couldn't find the explanation for this statement, while you can simply use the Declare keyword instead. Why are these different, and where would I appropriately use each case? JaredPar Declare is really an attempt to maintain a P/Invoke syntax which would be more familiar to Visual Basic 6.0 users

creating array without declaring the size - java

 ̄綄美尐妖づ 提交于 2019-11-28 18:26:32
i've digging around about the same issue but i couldn't find the same as i had i want to create an array without declaring the size because i don't know how it will be ! to clear the issue i'd like to give you the code that i'm looking up for public class t { private int x[]; private int counter=0; public void add(int num) { this.x[this.counter] = num; this.counter++; } } as you see the user could use the add function to add element to the array 10000 times or only once so it's unknown size Using Java.util.ArrayList or LinkedList is the usual way of doing this. With arrays that's not possible

Can I declare the same variable twice in different for loops in JavaScript? [duplicate]

点点圈 提交于 2019-11-28 02:25:09
问题 Possible Duplicate: JavaScript Variable Scope I have a JavaScript function for HTML select options for days: // Show and hide days according to the selected year and month. function show_and_hide_days(fp_form) { var select_year= $(fp_form).find("select.value_year"); var select_month= $(fp_form).find("select.value_month"); var select_day= $(fp_form).find("select.value_day"); var selected_year= $.parse_int($(select_year).val()); var selected_month= $.parse_int($(select_month).val()); var

Using variables in Classic ASP parameterized SQL

北城余情 提交于 2019-11-28 01:41:08
问题 I'm transitioning from dynamically generated (albeit heavily sanitized) SQL queries, to parameterized SQL, and I'm running into some trouble with the variable names. I'm using Classic ASP, coded in jScript. The code below takes a rating value (1-5) and puts it in the database. First it deletes all of the user's prior ratings for that object, and then writes the new rating into the database. The function has already received and I've parsed the Rating variable (a TinyInt). The UserID and PgID

creating array without declaring the size - java

隐身守侯 提交于 2019-11-27 11:20:36
问题 i've digging around about the same issue but i couldn't find the same as i had i want to create an array without declaring the size because i don't know how it will be ! to clear the issue i'd like to give you the code that i'm looking up for public class t { private int x[]; private int counter=0; public void add(int num) { this.x[this.counter] = num; this.counter++; } } as you see the user could use the add function to add element to the array 10000 times or only once so it's unknown size

SELECT INTO Variable in MySQL DECLARE causes syntax error?

纵然是瞬间 提交于 2019-11-27 10:54:25
I´d like to SELECT a single value into a variable. I´d tried to following: DECLARE myvar INT(4); -- immediately returns some syntax error. SELECT myvalue FROM mytable WHERE anothervalue = 1; -- returns a single integer SELECT myvalue INTO myvar FROM mytable WHERE anothervalue = 1; -- does not work, also tried @myvar Is possible to use DECLARE outside of stored procedures or functions? Maybe I just dont get the concept of user variables... I just tried: SELECT myvalue INTO @var FROM `mytable` WHERE uid = 1; SELECT @var; ...which worked just like it´s supposed to. But if I run each query at a